refactoring
This commit is contained in:
parent
caab3ebfd1
commit
b0b91a4fd4
@ -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))
|
||||
|
||||
@ -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]
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user