From e22f2bba01c49bf0fd179303fbfad992c905d02e Mon Sep 17 00:00:00 2001 From: XeroOl Date: Wed, 24 Apr 2024 15:46:25 -0500 Subject: [PATCH] small refactor --- Adding-a-Lint-Rule.md | 4 ++-- src/fennel-ls/compiler.fnl | 1 + src/fennel-ls/handlers.fnl | 12 ++++++------ src/fennel-ls/lint.fnl | 1 - 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Adding-a-Lint-Rule.md b/Adding-a-Lint-Rule.md index 63f292e..92138e2 100644 --- a/Adding-a-Lint-Rule.md +++ b/Adding-a-Lint-Rule.md @@ -1,8 +1,8 @@ # Creating a new lint To start, you can set up all the plumbing: -1. Go into `src/fennel-ls/diagnostics.fnl` and create a new function. -2. At the bottom of `src/fennel-ls/diagnostics.fnl`, add an if statement in the +1. Go into `src/fennel-ls/lint.fnl` and create a new function. +2. At the bottom of `src/fennel-ls/lint.fnl`, add an if statement in the `check` function. * Choose which `each` loop to put your function in, so your lint can be applied to right thing. diff --git a/src/fennel-ls/compiler.fnl b/src/fennel-ls/compiler.fnl index fcc4e70..1515cd7 100644 --- a/src/fennel-ls/compiler.fnl +++ b/src/fennel-ls/compiler.fnl @@ -233,6 +233,7 @@ identifiers are declared / referenced in which places." (or (= 1 (msg:find "unknown identifier")) (= 1 (msg:find "local %S+ was overshadowed by a special form or macro")) (= 1 (msg:find "expected var ")) + (= 1 (msg:find "expected local ")) (= 1 (msg:find "cannot call literal value")) (= 1 (msg:find "unexpected vararg")) (= 1 (msg:find "expected closing delimiter")) diff --git a/src/fennel-ls/handlers.fnl b/src/fennel-ls/handlers.fnl index fa5983c..ae0d3f3 100644 --- a/src/fennel-ls/handlers.fnl +++ b/src/fennel-ls/handlers.fnl @@ -132,7 +132,7 @@ Every time the client sends a message, it gets handled by a function in the corr (λ make-completion-item [self file name scope] (case (language.search-name-and-scope self file name scope) def (formatter.completion-item-format name def) - _ {:label name :textEdit {:newText name}})) + _ {:label name})) (λ scope-completion [self file byte ?symbol parents] (let [scope (or (accumulate [result nil @@ -162,7 +162,7 @@ Every time the client sends a message, it gets handled by a function in the corr (case (values definition (type definition)) ;; fields of a string are hardcoded to "string" (_str :string) (icollect [label _ (pairs string)] - {: label :kind kinds.Field :textEdit {:newText label}}) + {: label :kind kinds.Field}) ;; fields of a table (tbl :table) (let [keys []] (icollect [label _ (pairs tbl) &into keys] @@ -174,7 +174,7 @@ Every time the client sends a message, it gets handled by a function in the corr (if (= (type label) :string) (case (language.search-ast self file tbl [label] {}) def (formatter.completion-item-format label def) - _ {: label :kind kinds.Field :textEdit {:newText label}}))))) + _ {: label :kind kinds.Field}))))) {: metadata : fields} (icollect [label info (pairs fields)] (formatter.completion-item-format label info)) @@ -192,16 +192,16 @@ Every time the client sends a message, it gets handled by a function in the corr ?completions (scope-completion self file byte ?symbol parents)] (if ?completions (each [_ completion (ipairs ?completions)] - (set completion.textEdit.range input-range))) + (set completion.textEdit {:newText completion.label :range input-range}))) ?completions) ;; completion from field [_a _b &as split] (let [input-range (message.multisym->range self file ?symbol -1) - ?completions (field-completion self file ?symbol split input-range)] + ?completions (field-completion self file ?symbol split)] (if ?completions (each [_ completion (ipairs ?completions)] - (set completion.textEdit.range input-range))) + (set completion.textEdit {:newText completion.label :range input-range}))) ?completions)))) diff --git a/src/fennel-ls/lint.fnl b/src/fennel-ls/lint.fnl index 5044030..3ebbc83 100644 --- a/src/fennel-ls/lint.fnl +++ b/src/fennel-ls/lint.fnl @@ -121,7 +121,6 @@ the `file.diagnostics` field, filling it with diagnostics." :quickfix #[{:range (message.ast->range self file call) :newText (view identity)}]})))) - (λ multival-in-middle-of-call [self file fun call arg index] "generally, values and unpack are signs that the user is trying to do something with multiple values. However, multiple values will get