From 91d4e1e410c8d26bf39478d1c79b46794d1f3d4b Mon Sep 17 00:00:00 2001 From: XeroOl Date: Fri, 2 Jun 2023 18:10:35 -0500 Subject: [PATCH] Multivals ruining everything --- src/fennel-ls/compiler.fnl | 10 ++++++++++ src/fennel-ls/handlers.fnl | 4 ++-- test/completion-test.fnl | 9 ++++----- test/hover-test.fnl | 5 ++++- test/test-project/hover.fnl | 3 +++ 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/fennel-ls/compiler.fnl b/src/fennel-ls/compiler.fnl index f49a0f9..2afde06 100644 --- a/src/fennel-ls/compiler.fnl +++ b/src/fennel-ls/compiler.fnl @@ -37,6 +37,9 @@ later by fennel-ls.language to answer requests from the client." (tset self key val) val))}) +(λ is-values? [?ast] + (and (list? ?ast) (= (sym :values) (. ?ast 1)))) + (λ compile [self file] "Compile the file, and record all the useful information from the compiler into the file object" ;; The useful information being recorded: @@ -107,6 +110,13 @@ later by fennel-ls.language to answer requests from the client." (. keys i)))}] (tset (. definitions-by-scope scope) (tostring binding) definition) (tset definitions binding definition)) + (list? binding) + (if (and (is-values? ?definition) + (= (length binding) + (- (length ?definition) 1))) + (for [i 1 (length binding)] + (define (. ?definition (+ i 1)) (. binding i) scope)) + (recurse (. binding 1) keys)) (= :table (type binding)) (each [k v (iter binding)] (table.insert keys k) diff --git a/src/fennel-ls/handlers.fnl b/src/fennel-ls/handlers.fnl index f57ae97..8459c6d 100644 --- a/src/fennel-ls/handlers.fnl +++ b/src/fennel-ls/handlers.fnl @@ -133,7 +133,7 @@ Every time the client sends a message, it gets handled by a function in the corr :Snippet 15 :Color 16 :File 17 :Reference 18 :Folder 19 :EnumMember 20 :Constant 21 :Struct 22 :Event 23 :Operator 24 :TypeParameter 25}) -(λ make-completionitem [self file name scope] +(λ make-completion-item [self file name scope] ;; TODO consider passing stop-early? (case (language.search-name-and-scope self file name scope) def (formatter.completion-item-format name def))) @@ -147,7 +147,7 @@ Every time the client sends a message, it gets handled by a function in the corr ?parent (. parents 1) result [] in-call-position? (and ?parent (= ?symbol (. ?parent 1)))] - (collect-scope scope :manglings #(make-completionitem self file $ scope) result) + (collect-scope scope :manglings #(make-completion-item self file $ scope) result) (when in-call-position? (collect-scope scope :macros #{:label $ :kind kinds.Keyword} result) (collect-scope scope :specials #{:label $ :kind kinds.Keyword} result)) diff --git a/test/completion-test.fnl b/test/completion-test.fnl index 98e019d..42292d5 100644 --- a/test/completion-test.fnl +++ b/test/completion-test.fnl @@ -114,11 +114,10 @@ (let [client (doto (create-client) (: :open-file! filename "(fn xyzzy [x y z] \"docstring\" nil)\n(xyzz")) [{:result [completion]}] (client:completion filename 1 5)] - (print (view completion)) - (assert completion.label "completion label") - (assert completion.kind "completion kind") - ;; (assert (?. completion :labelDetails :description) "fully qualified names or file path") - (assert completion.documentation "completion documentation"))))) + ;; TODO this seems a little bit weird to assert + (is.same :xyzzy completion.label "the first completion should be xyzzy") + (assert completion.kind "completion kind should be present") + (assert completion.documentation "completion documentation should be present"))))) ;; (it "offers rich information about macro completions") ;; (it "offers rich information about variable completions") diff --git a/test/hover-test.fnl b/test/hover-test.fnl index 72dd269..a1d9eaf 100644 --- a/test/hover-test.fnl +++ b/test/hover-test.fnl @@ -46,4 +46,7 @@ (it "hovers over literally the very first character" (let [self (create-client) message (self:hover (.. ROOT-URI "/hover.fnl") 0 0)] - (is-matching message [{:jsonrpc "2.0" :id 2}] "")))) + (is-matching message [{:jsonrpc "2.0" :id 2}] ""))) + + (it "can go backward through (case)" + (check "hover.fnl" 22 22 "```fnl\n{:AB :CD}\n```"))) diff --git a/test/test-project/hover.fnl b/test/test-project/hover.fnl index 6070a3c..cdb98cc 100644 --- a/test/test-project/hover.fnl +++ b/test/test-project/hover.fnl @@ -18,3 +18,6 @@ nil) (lambda-fn 1 2) + +(case {:x [10 {:AB :CD}]} + {:x [_ val]} (print val))