diff --git a/src/fennel-ls/formatter.fnl b/src/fennel-ls/formatter.fnl index 1a87cfe..864ef55 100644 --- a/src/fennel-ls/formatter.fnl +++ b/src/fennel-ls/formatter.fnl @@ -109,7 +109,7 @@ fntype is one of fn or λ or lambda" {:fntype _} {: label :kind (if (label:find ":") kinds.Method kinds.Function)} _ {: label - :kind kinds.Variable}) + :kind (. kinds (?. result :metadata :fls/itemKind))}) (tset :documentation (hover-format result)))) {: hover-format diff --git a/test/completion.fnl b/test/completion.fnl index 653eb4b..4dd7aec 100644 --- a/test/completion.fnl +++ b/test/completion.fnl @@ -71,8 +71,7 @@ (expected completions)))) (fn test-global [] - ;; TODO shouldn't this kind be Function? - (check "(" [{:label :setmetatable :kind kinds.Variable}] []) + (check "(" [{:label :setmetatable :kind kinds.Function}] []) (check "(" [:_G :debug :table :io :getmetatable :setmetatable :_VERSION :ipairs :pairs :next] [:this-is-not-a-global]) (check "#nil\n(" [:_G :debug :table :io :getmetatable :setmetatable :_VERSION :ipairs :pairs :next] []) (check "(if ge" [:getmetatable] []) diff --git a/tools/get-docs/love2d.fnl b/tools/get-docs/love2d.fnl index 5fcf4c3..3418392 100644 --- a/tools/get-docs/love2d.fnl +++ b/tools/get-docs/love2d.fnl @@ -8,13 +8,14 @@ ; ; UTILS ; ----- -(fn build-lsp-value [name ?args ?docstring ?fields] +(fn build-lsp-value [name ?args ?docstring ?fields ?kind] "Takes ... and returns a table to be used with the LSP." (let [lsp-value {:binding name} ?metadata (or ?args ?docstring)] (when ?metadata (set lsp-value.metadata {})) (when ?args (set lsp-value.metadata.fnl/arglist ?args)) (when ?docstring (set lsp-value.metadata.fnl/docstring ?docstring)) + (when ?kind (set lsp-value.metadata.fls/itemKind ?kind)) (when ?fields (set lsp-value.fields ?fields)) lsp-value)) @@ -69,7 +70,7 @@ ?args (?. first-variant :args) ?returns (or (?. first-variant :returns) "") docstring (.. description ?returns)] - (values name (build-lsp-value binding ?args docstring))))) + (values name (build-lsp-value binding ?args docstring nil :Function))))) (fn module-list->lsp-table [modules ?namespace] (collect [_i module (ipairs modules)] @@ -84,7 +85,7 @@ {}) module-keys (if ?modules (module-list->lsp-table ?modules binding) {}) fields (merge function-keys module-keys)] - (values name (build-lsp-value binding nil ?docstring fields))))) + (values name (build-lsp-value binding nil ?docstring fields :Module))))) (fn love-api->lsp-table [love-api] (let [root-module {:description (.. "LÖVE is a framework for making 2D " diff --git a/tools/get-docs/lua-manual.fnl b/tools/get-docs/lua-manual.fnl index 3fd84d9..2af811d 100644 --- a/tools/get-docs/lua-manual.fnl +++ b/tools/get-docs/lua-manual.fnl @@ -133,13 +133,15 @@ description (html-to-markdown description) name (signature:match "[^() ]+") key (name:match "[^.:]+$") - ?module (and (name:find "[.:]") (name:match "^[^.:]+"))] + ?module (and (name:find "[.:]") (name:match "^[^.:]+")) + kind (if (signature:find "[()]") :Function :Variable)] (values ?module key {:binding (signature:match "[^() ]+") :metadata {:fnl/docstring description - :fnl/arglist signature-list}}))) + :fnl/arglist signature-list + :fls/itemKind kind}}))) (fn parse-h2-section [html] "parse a section that starts with an h2 tag. These are the main modules." @@ -169,7 +171,8 @@ (values module-name {:binding module-name :fields {} - :metadata {:fnl/docstring description}}))) + :metadata {:fnl/docstring description + :fls/itemKind :Module}}))) (fn parse [input] (let [version (input:match "Lua .- Reference Manual") diff --git a/tools/get-docs/tic80.fnl b/tools/get-docs/tic80.fnl index 7dfad62..60408ea 100644 --- a/tools/get-docs/tic80.fnl +++ b/tools/get-docs/tic80.fnl @@ -25,7 +25,8 @@ "([_%w]+)%s+`([^`]+)`%s(.-)\n### ")] (let [arglist (markdown->arglist args)] (values name {:metadata {:fnl/arglist arglist - :fnl/docstring docs} + :fnl/docstring docs + :fls/itemKind :Function} :binding name}))))) (fn convert [contents]