diff --git a/src/fennel-ls/compiler.fnl b/src/fennel-ls/compiler.fnl index 221976b..f4b13d3 100644 --- a/src/fennel-ls/compiler.fnl +++ b/src/fennel-ls/compiler.fnl @@ -313,8 +313,9 @@ identifiers are declared / referenced in which places." (error "__NOT_AN_ERROR")))) (local allowed-globals (docs.get-all-globals server)) - (each [_ v (ipairs (utils.split-spaces server.configuration.extra-globals))] - (table.insert allowed-globals v)) + (icollect [extra-global (server.configuration.extra-globals:gmatch "[^ ]+") + &into allowed-globals] + extra-global) (fn parse-ast [parser] (icollect [ok ast parser &until (not ok)] ast)) diff --git a/src/fennel-ls/formatter.fnl b/src/fennel-ls/formatter.fnl index 4c9148f..d7ee563 100644 --- a/src/fennel-ls/formatter.fnl +++ b/src/fennel-ls/formatter.fnl @@ -5,7 +5,6 @@ user code. Fennel-ls doesn't support user-code formatting as of now." (local {: sym? : view} (require :fennel)) -(local {: type=} (require :fennel-ls.utils)) (λ code-block [str] (.. "```fnl\n" str "\n```")) @@ -57,26 +56,26 @@ fntype is one of fn or λ or lambda" body (fn? fntype) (sym? name) - (type= arglist :table) - (type= docstring :string)) + (= (type arglist) :table) + (= (type docstring) :string)) {: fntype : name : arglist : docstring} ;; docstring (where [fntype arglist docstring body] body (fn? fntype) - (type= arglist :table) - (type= docstring :string)) + (= (type arglist) :table) + (= (type docstring) :string)) {: fntype : arglist : docstring} ;; name (where [fntype name arglist] (fn? fntype) (sym? name) - (type= arglist :table)) + (= (type arglist) :table)) {: fntype : name : arglist} ;; none (where [fntype arglist] (fn? fntype) - (type= arglist :table)) + (= (type arglist) :table)) {: fntype : arglist})) (λ hover-format [result] diff --git a/src/fennel-ls/utils.fnl b/src/fennel-ls/utils.fnl index 9e63351..1f8e310 100644 --- a/src/fennel-ls/utils.fnl +++ b/src/fennel-ls/utils.fnl @@ -176,22 +176,13 @@ WARNING: this is only used in the test code, not in the real language server" symbol (pick-values 1 (symbol:match "[^.:]*")))) -(λ type= [val typ] - (= (type val) typ)) - (λ uniq-by [list key-fn] - (let [result [] - seen {}] - (each [_ new-item (ipairs list)] + (let [seen {}] + (icollect [_ new-item (ipairs list)] (let [key (key-fn new-item)] (when (not (. seen key)) (tset seen key true) - (table.insert result new-item)))) - result)) - -(λ split-spaces [str] - (icollect [m (str:gmatch "[^ ]+")] - m)) + new-item))))) (local path-sep (package.config:sub 1 1)) @@ -226,8 +217,6 @@ WARNING: this is only used in the test code, not in the real language server" : multi-sym-base : get-ast-info : uniq-by - : type= - : split-spaces : absolute-path? : path-join : path-sep diff --git a/test/misc.fnl b/test/misc.fnl index 0e9d576..67f47cb 100644 --- a/test/misc.fnl +++ b/test/misc.fnl @@ -43,15 +43,6 @@ (create-client "(let [map {}] (set (. map (tostring :a)) :b))") nil) -(fn test-split-spaces [] - (faith.= [] (utils.split-spaces "")) - (faith.= ["foo"] (utils.split-spaces "foo")) - (faith.= ["foo"] (utils.split-spaces " foo ")) - (faith.= ["foo-bar" "bar" "baz"] (utils.split-spaces "foo-bar bar baz")) - (faith.= ["foo-bar" "bar" "baz"] (utils.split-spaces " foo-bar bar baz ")) - nil) - {: test-multi-sym-split : test-find-symbol - : test-failure - : test-split-spaces} + : test-failure}