diff --git a/src/fennel-ls/compiler.fnl b/src/fennel-ls/compiler.fnl index bfe141c..4908047 100644 --- a/src/fennel-ls/compiler.fnl +++ b/src/fennel-ls/compiler.fnl @@ -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)) diff --git a/src/fennel-ls/completion.fnl b/src/fennel-ls/completion.fnl index 68579bc..8523a69 100644 --- a/src/fennel-ls/completion.fnl +++ b/src/fennel-ls/completion.fnl @@ -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)] diff --git a/test/completion.fnl b/test/completion.fnl index 125f804..58fa148 100644 --- a/test/completion.fnl +++ b/test/completion.fnl @@ -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\"