completions for "true" "false" and "nil"
This commit is contained in:
parent
e17ecef292
commit
b7e497228f
@ -7,6 +7,14 @@
|
|||||||
(local navigate (require :fennel-ls.navigate))
|
(local navigate (require :fennel-ls.navigate))
|
||||||
(local {:metadata METADATA} (require :fennel.compiler))
|
(local {:metadata METADATA} (require :fennel.compiler))
|
||||||
|
|
||||||
|
(local hardcoded-completions
|
||||||
|
{:nil {:metadata {:fnl/docstring "Represents the absence of a useful value."
|
||||||
|
:fls/itemKind "Keyword"}}
|
||||||
|
:true {:metadata {:fnl/docstring "A boolean value representing truth."
|
||||||
|
:fls/itemKind "Keyword"}}
|
||||||
|
:false {:metadata {:fnl/docstring "A boolean value representing falsehood."
|
||||||
|
:fls/itemKind "Keyword"}}})
|
||||||
|
|
||||||
(λ textDocument/completion [server _send {: position :textDocument {: uri}}]
|
(λ textDocument/completion [server _send {: position :textDocument {: uri}}]
|
||||||
;; get the file
|
;; get the file
|
||||||
(let [file (files.get-by-uri server uri)
|
(let [file (files.get-by-uri server uri)
|
||||||
@ -48,6 +56,9 @@
|
|||||||
(add-completion-recursively! (.. name "." field) def)))
|
(add-completion-recursively! (.. name "." field) def)))
|
||||||
(set (. seen definition) false)))
|
(set (. seen definition) false)))
|
||||||
|
|
||||||
|
(each [name documentation (pairs hardcoded-completions)]
|
||||||
|
(add-completion! name documentation))
|
||||||
|
|
||||||
(local seen-manglings {})
|
(local seen-manglings {})
|
||||||
|
|
||||||
(each [_ global* (ipairs file.allowed-globals)]
|
(each [_ global* (ipairs file.allowed-globals)]
|
||||||
@ -92,14 +103,15 @@
|
|||||||
results)))
|
results)))
|
||||||
|
|
||||||
(fn completionItem/resolve [server _send completion-item]
|
(fn completionItem/resolve [server _send completion-item]
|
||||||
(let [{: uri : byte} completion-item.data
|
(or (. hardcoded-completions completion-item.label)
|
||||||
file (files.get-by-uri server uri)
|
(let [{: uri : byte} completion-item.data
|
||||||
(_symbol parents) (analyzer.find-symbol file.ast byte)
|
file (files.get-by-uri server uri)
|
||||||
scope (or (accumulate [?find nil _ parent (ipairs parents) &until ?find]
|
(_symbol parents) (analyzer.find-symbol file.ast byte)
|
||||||
(. file.scopes parent))
|
scope (or (accumulate [?find nil _ parent (ipairs parents) &until ?find]
|
||||||
file.scope)]
|
(. file.scopes parent))
|
||||||
(case (analyzer.search-name-and-scope server file completion-item.label scope)
|
file.scope)]
|
||||||
result (doto completion-item (tset :documentation (format.hover-format server completion-item.label result))))))
|
(case (analyzer.search-name-and-scope server file completion-item.label scope)
|
||||||
|
result (doto completion-item (tset :documentation (format.hover-format server completion-item.label result)))))))
|
||||||
|
|
||||||
{: textDocument/completion
|
{: textDocument/completion
|
||||||
: completionItem/resolve}
|
: completionItem/resolve}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user