From 7313599907cbaee229a4dac4c46a09465b70b392 Mon Sep 17 00:00:00 2001 From: Phil Hagelberg Date: Sun, 19 Oct 2025 13:19:46 -0700 Subject: [PATCH] Revert "Enable legacy-multival lint on fennel-ls itself and fix self-lints." This reverts commit bf17771babf70ca5941deb9e0cbff86a9b7c1ca4. --- flsproject.fnl | 3 +-- src/fennel-ls/analyzer.fnl | 4 ++-- src/fennel-ls/compiler.fnl | 6 +++--- src/fennel-ls/completion.fnl | 4 ++-- src/fennel-ls/dispatch.fnl | 18 +++++++++--------- src/fennel-ls/json-rpc.fnl | 9 +++++---- src/fennel-ls/message.fnl | 6 +++--- src/fennel-ls/utils.fnl | 6 +++--- test/init.fnl | 7 ++++--- test/misc.fnl | 4 ++-- test/utils/init.fnl | 14 +++++++------- 11 files changed, 41 insertions(+), 40 deletions(-) diff --git a/flsproject.fnl b/flsproject.fnl index 4c5bc5d..38fb917 100644 --- a/flsproject.fnl +++ b/flsproject.fnl @@ -1,4 +1,3 @@ {:lua-version "intersection" - :lints {:not-enough-arguments true - :legacy-multival true} + :lints {:not-enough-arguments true} :fennel-path "./?.fnl;./?/init.fnl;src/?.fnl;src/?/init.fnl;deps/?.fnl;deps/?/init.fnl"} diff --git a/src/fennel-ls/analyzer.fnl b/src/fennel-ls/analyzer.fnl index ff9f8f3..d9ca89c 100644 --- a/src/fennel-ls/analyzer.fnl +++ b/src/fennel-ls/analyzer.fnl @@ -281,13 +281,13 @@ initialization-opts: {:stack ?list[ast] (table.insert parents ast) (if (or (sequence? ast) (list? ast)) - (accumulate [result nil + (accumulate [(result _parent) nil _ child (ipairs ast) &until result] (if (contains? child byte) (recurse child))) (and (not (sym? ast)) (not (varg? ast))) - (accumulate [result nil + (accumulate [(result _parent) nil key value (pairs ast) &until result] (if (contains? key byte) diff --git a/src/fennel-ls/compiler.fnl b/src/fennel-ls/compiler.fnl index eefa0aa..64b86fd 100644 --- a/src/fennel-ls/compiler.fnl +++ b/src/fennel-ls/compiler.fnl @@ -381,9 +381,9 @@ identifiers are declared / referenced in which places." : compiler-env : warn} filter-errors (fn _filter-errors [component ...] - (case [...] - [true ?item1 ?item2] (values ?item1 ?item2) - (where (or [nil err] [false err]) (not (err:find "^[^\n]-__NOT_AN_ERROR\n"))) + (case ... + (true ?item1 ?item2) (values ?item1 ?item2) + (where (or (nil err) (false err)) (not (err:find "^[^\n]-__NOT_AN_ERROR\n"))) (if (os.getenv :DEV) (error (.. "\nYou have crashed fennel-ls (or the fennel " component ") with the following message\n:" err "\n\n^^^ the error message above here is the root problem\n\n")) diff --git a/src/fennel-ls/completion.fnl b/src/fennel-ls/completion.fnl index 8129510..60486eb 100644 --- a/src/fennel-ls/completion.fnl +++ b/src/fennel-ls/completion.fnl @@ -50,7 +50,7 @@ we support completionItem/resolve." file {:text (.. (file.text:sub 1 (- byte 1)) "|" (file.text:sub byte)) :uri file.uri} _ (compiler.compile server file) ;; find what ast objects are under the cursor - [symbol parents] [(analyzer.find-symbol server file byte)] + (symbol parents) (analyzer.find-symbol server file byte) ;; check what context I'm in in-call-position? (or (and (fennel.list? (. parents 1)) (= symbol (. parents 1 1))) @@ -161,7 +161,7 @@ we support completionItem/resolve." (fn completionItem/resolve [server _send completion-item] (let [{: uri : byte} completion-item.data file (files.get-by-uri server uri) - [_symbol parents] [(analyzer.find-symbol server file byte)] + (_symbol parents) (analyzer.find-symbol server file byte) scope (or (. file.scopes _symbol) (accumulate [?find nil _ parent (ipairs parents) &until ?find] (. file.scopes parent)) diff --git a/src/fennel-ls/dispatch.fnl b/src/fennel-ls/dispatch.fnl index 6364090..ced13d4 100644 --- a/src/fennel-ls/dispatch.fnl +++ b/src/fennel-ls/dispatch.fnl @@ -14,9 +14,9 @@ In general, this involves: ;; The return value of the request is sent back to the server. (case (. handlers.requests method) callback - (case [(callback server send ?params)] - [nil err] (send (message.create-error :InternalError err id)) - [?response] (send (message.create-response id ?response))) + (case (callback server send ?params) + (nil err) (send (message.create-error :InternalError err id)) + ?response (send (message.create-response id ?response))) nil (send (message.create-error @@ -48,16 +48,16 @@ Takes: * `send`, which is a callback for sending responses, and * `msgs`, which is a list of incoming messages." (each [_ msg (ipairs batch)] - (case [msg (type msg)] - [{:jsonrpc "2.0" : id : method :params ?params}] + (case (values msg (type msg)) + {:jsonrpc "2.0" : id : method :params ?params} (handle-request server send id method ?params) - [{:jsonrpc "2.0" : method :params ?params}] + {:jsonrpc "2.0" : method :params ?params} (handle-notification server send method ?params) - [{:jsonrpc "2.0" : id : result}] + {:jsonrpc "2.0" : id : result} (handle-response server send id result) - [{:jsonrpc "2.0" : id :error err}] + {:jsonrpc "2.0" : id :error err} (handle-bad-response server send id err) - [str :string] + (str :string) (send (message.create-error :ParseError str)) _ (send (message.create-error :BadMessage nil msg.id))) diff --git a/src/fennel-ls/json-rpc.fnl b/src/fennel-ls/json-rpc.fnl index bb5c049..086c1b7 100644 --- a/src/fennel-ls/json-rpc.fnl +++ b/src/fennel-ls/json-rpc.fnl @@ -24,7 +24,7 @@ on the empty table to tell dkjson to serialize as {}." nil nil ;; I've hit end of stream, return nil instead of a header line (case (line:match "^(.-)\r?$") ;; strip trailing \r "" header ;; base case. empty line marks end of header - line (let [[k v] [(line:match "^(.-): (.-)$")]] + line (let [(k v) (line:match "^(.-): (.-)$")] (if (not (and k v)) (error (.. "fennel-ls encountered a malformed json-rpc header: \"" line "\""))) (tset header k v) @@ -49,9 +49,10 @@ If there aren't enough bytes, return nil" (λ read [in] "Reads and parses a JSON-RPC message from the input stream Returns a table with the message if it succeeded, or a string with the parse error if it fails." - (let [[?result _?err-pos ?err] [(-?>> (read-header in) - (read-content in) - decode)]] + (let [(?result _?err-pos ?err) + (-?>> (read-header in) + (read-content in) + decode)] (or ?result ?err))) (λ write [out msg] diff --git a/src/fennel-ls/message.fnl b/src/fennel-ls/message.fnl index 3b160c2..03cabd0 100644 --- a/src/fennel-ls/message.fnl +++ b/src/fennel-ls/message.fnl @@ -95,9 +95,9 @@ LSP json objects." (λ multisym->range [server file ast n] (let [spl (utils.multi-sym-split ast)] - (case [(utils.get-ast-info ast :bytestart) - (utils.get-ast-info ast :byteend)] - [bytestart byteend] + (case (values (utils.get-ast-info ast :bytestart) + (utils.get-ast-info ast :byteend)) + (bytestart byteend) (let [bytesubstart (faccumulate [b bytestart i 1 (- n 1)] (+ b (length (. spl i)) 1)) diff --git a/src/fennel-ls/utils.fnl b/src/fennel-ls/utils.fnl index c3c95b8..037d3a8 100644 --- a/src/fennel-ls/utils.fnl +++ b/src/fennel-ls/utils.fnl @@ -39,7 +39,7 @@ These functions are all pure functions, which makes me happy." (var o8 0) (var o16 0) (while (< o8 unit8) - (let [[a8 a16] [(utf (str:byte (+ 1 o8)))]] + (let [(a8 a16) (utf (str:byte (+ 1 o8)))] (set o8 (+ o8 a8)) (set o16 (+ o16 a16)))) (if (= o8 unit8) @@ -52,7 +52,7 @@ These functions are all pure functions, which makes me happy." (var o8 0) (var o16 0) (while (< o16 unit16) - (let [[a8 a16] [(utf (str:byte (+ 1 o8)))]] + (let [(a8 a16) (utf (str:byte (+ 1 o8)))] (set o8 (+ o8 a8)) (set o16 (+ o16 a16)))) (if (= o16 unit16) @@ -220,7 +220,7 @@ These functions are all pure functions, which makes me happy." (not (str:find "[^!#$%&*+/0-9<=>?A-Z\\^_a-z|\128-\255-]")))) (fn find [t x ?k] - (match [(next t ?k)] [k x] k [k y_] (find t x k))) + (match (next t ?k) (k x) k (k y_) (find t x k))) {: version : uri->path diff --git a/test/init.fnl b/test/init.fnl index bef4196..d8b7540 100644 --- a/test/init.fnl +++ b/test/init.fnl @@ -4,9 +4,10 @@ (set debug.getinfo (or fennel.getinfo debug.getinfo)) (set debug.traceback (or fennel.traceback debug.traceback)) -(case [(string.match (or (os.getenv "FAITH_TEST") "") "([^ ]+) ?([^ ]*)")] - [module ""] (faith.run [module]) - [module function] (do +(case (string.match (or (os.getenv "FAITH_TEST") "") + "([^ ]+) ?([^ ]*)") + (module "") (faith.run [module]) + (module function) (do (tset package.loaded module {function (. (require module) function)}) (faith.run [module])) diff --git a/test/misc.fnl b/test/misc.fnl index f72aec4..ace6775 100644 --- a/test/misc.fnl +++ b/test/misc.fnl @@ -24,7 +24,7 @@ (fn test-find-symbol [] (let [{: server : uri} (create-client "(match [1 2 4] [1 2 sym-one] sym-one)") file (. server.files uri) - [symbol parents] [(analyzer.find-symbol server file 23)]] + (symbol parents) (analyzer.find-symbol server file 23)] (faith.= symbol (fennel.sym :sym-one)) (faith.= "[[1 2 sym-one] (match [1 2 4] [1 2 sym-one] sym-one) [(match [1 2 4] [1 2 sym-one] sym-one)]]" @@ -33,7 +33,7 @@ (let [{: server : uri} (create-client "(match [1 2 4] [1 2 sym-one] sym-one)") file (. server.files uri) - [symbol parents] [(analyzer.find-symbol server file 18)]] + (symbol parents) (analyzer.find-symbol server file 18)] (faith.= symbol nil) (faith.= "[[1 2 sym-one] (match [1 2 4] [1 2 sym-one] sym-one) [(match [1 2 4] [1 2 sym-one] sym-one)]]" diff --git a/test/utils/init.fnl b/test/utils/init.fnl index 3e58270..cf27e62 100644 --- a/test/utils/init.fnl +++ b/test/utils/init.fnl @@ -18,10 +18,10 @@ encoding (or ?encoding default-encoding)] (while (case - (case [(text:find "|") (text:find "==")] - (where [| ==] (< | ==)) [| "|"] - [_ ==] [== "=="] - [| _] [| "|"]) + (case (values (text:find "|") (text:find "==")) + (where (| ==) (< | ==)) [| "|"] + (_ ==) [== "=="] + (| _) [| "|"]) [i "|"] (do (set text (.. (text:sub 1 (- i 1)) (text:sub (+ i 1)))) @@ -44,9 +44,9 @@ (fn create-client [file-contents ?opts ?config] ;; TODO big function, split up (let [opts (or ?opts {}) - [provide-root-uri file-contents] (if (= (type file-contents) :table) - [true file-contents] - [false {:main.fnl file-contents}]) + (provide-root-uri file-contents) (if (= (type file-contents) :table) + (values true file-contents) + (values false {:main.fnl file-contents})) server {:preload (if provide-root-uri {})} client (doto {: server :prev-id 1}