Remove error response when hovering over nothing

This commit is contained in:
XeroOl 2022-09-07 21:19:36 -05:00
parent 0d8b927929
commit 06a6e8c7ea
No known key found for this signature in database
GPG Key ID: 9DD4B4B4DAED0322
6 changed files with 20 additions and 8 deletions

View File

@ -37,7 +37,7 @@ Features / To Do List / Things I would enjoy patches for:
- [ ] from macros (only on first form in a list)
- [ ] from specials (only on first form in a list)
- [X] "dot completion" for table fields
- [ ] dot completion is aware of a string's fields
- [ ] dot completion is aware of a stdlib
- [ ] from anywhere else that I'm forgetting right now
- [ ] actually compliant rules about lexical scope (only see things declared before, not after)
- [ ] show docs/icons on each suggestion

View File

@ -89,7 +89,8 @@ Every time the client sends a message, it gets handled by a function in the corr
(match-try (language.find-symbol file.ast byte)
symbol (language.search-main self file symbol {})
result {:contents {:kind "markdown"
:value (formatter.hover-format result)}})))
:value (formatter.hover-format result)}}
(catch _ nil))))
(λ collect-scope [scope typ callback ?target]
(let [result (or ?target [])]
@ -150,6 +151,7 @@ Every time the client sends a message, it gets handled by a function in the corr
(send (message.diagnostics file)))
(λ notifications.textDocument/didClose [self send {:textDocument {: uri}}]
;; TODO reload from disk if we didn't get a didSave
(local file (state.get-by-uri self uri))
(set file.open? false))

View File

@ -57,7 +57,8 @@ the data provided by compiler.fnl."
[-require- mod]
(let [newfile (state.get-by-module self mod)
newitem (. newfile.ast (length newfile.ast))]
(search self newfile newitem stack opts))
(if newfile
(search self newfile newitem stack opts)))
; A . form indexes into item 1 with the other items
[-dot- & split]
(search self file (. split 1)

View File

@ -40,7 +40,7 @@ I suspect this file is going to be gone after a bit of refactoring."
(table.concat result ";")))
(λ lookup [{: root-uri} mod]
(match (or (fennel.searchModule mod (add-workspaces-to-path luapath [root-uri]))
(match (or ;; TODO support lua ;; (fennel.searchModule mod (add-workspaces-to-path luapath [root-uri]))
(fennel.searchModule mod (add-workspaces-to-path fennelpath [root-uri])))
modname (utils.path->uri modname)
nil nil))

View File

@ -42,9 +42,7 @@ object."
uri
(do
(tset self.modules module uri)
(get-by-uri self uri))
nil
(error (.. "cannot find module " module)))))
(get-by-uri self uri)))))
(λ set-uri-contents [self uri text]
(match (. self.files uri)

View File

@ -44,4 +44,15 @@
(check "hover.fnl" 12 9 "```fnl\nnil\n```"))
(it "hovers over λ function"
(check "hover.fnl" 18 6 "```fnl\n(fn lambda-fn [arg1 arg2] ...)\n```\ndocstring")))
(check "hover.fnl" 18 6 "```fnl\n(fn lambda-fn [arg1 arg2] ...)\n```\ndocstring"))
(it "hovers over literally the very first character"
(local state (doto [] setup-server))
(let [message (dispatch.handle* state
(message.create-request 2 "textDocument/hover"
{:position {:character 0 :line 0}
:textDocument {:uri (.. ROOT-URI "/hover.fnl")}}))]
(is-matching
message
[{:jsonrpc "2.0" :id 2}]
""))))