tricky macro hidden scope completions

it's hard to tell which scope something is in. This makes completions a
little better but it misses docs during good completion
This commit is contained in:
XeroOl 2025-07-30 15:59:43 -05:00
parent dfa42610f7
commit 38cfd9a249
3 changed files with 10 additions and 2 deletions

View File

@ -112,6 +112,7 @@ identifiers are declared / referenced in which places."
(λ symbol-to-expression [ast scope ?reference?]
(assert (sym? ast) "symbols only")
(tset scopes ast scope)
(reference ast scope (if ?reference?
:read
(not (multisym? ast))

View File

@ -57,7 +57,8 @@ is set to true and we report that we support completionItem/resolve."
&until ?find]
(= (. ast 1) symbol)))
;; find the first parent that contains a scope
scope (or (accumulate [?find nil _ parent (ipairs parents) &until ?find]
scope (or (. file.scopes symbol)
(accumulate [?find nil _ parent (ipairs parents) &until ?find]
(. file.scopes parent))
file.scope)
range (case (message.ast->range server file symbol)
@ -157,7 +158,8 @@ is set to true and we report that we support completionItem/resolve."
(let [{: uri : byte} completion-item.data
file (files.get-by-uri server uri)
(_symbol parents) (analyzer.find-symbol file.ast byte)
scope (or (accumulate [?find nil _ parent (ipairs parents) &until ?find]
scope (or (. file.scopes _symbol)
(accumulate [?find nil _ parent (ipairs parents) &until ?find]
(. file.scopes parent))
file.scope)
result (analyzer.search-name-and-scope server file completion-item.label scope)]

View File

@ -178,6 +178,11 @@
{:kind #(= nil $)}
{:label #(= nil $)}])
(check "(case {}
identifier |"
[:identifier]
[]) ; TODO [{:documentation #(= nil $)}])
(each [_ mode (ipairs [true false])]
(check "(fn x [a b c]
\"docstring\"