Add settings (untested / undocumented)
This commit is contained in:
parent
566b475ff8
commit
a86c52f33a
@ -159,14 +159,14 @@ Every time the client sends a message, it gets handled by a function in the corr
|
||||
(set file.open? false))
|
||||
|
||||
(λ notifications.workspace/didChangeConfiguration [self send params]
|
||||
(set self.settings params.fennel-ls))
|
||||
;; TODO respect the settings
|
||||
(state.write-config self params.fennel-ls))
|
||||
|
||||
(λ requests.shutdown [self send]
|
||||
"The server still needs to respond to this request, so the program can't close yet. Just wait until notifications.exit"
|
||||
nil)
|
||||
|
||||
(λ notifications.exit [self]
|
||||
"This is the real shutdown request, we can quit now"
|
||||
(os.exit 0))
|
||||
|
||||
{: requests
|
||||
|
||||
@ -1,14 +1,10 @@
|
||||
"Searcher
|
||||
This file has all the logic needed to take the name of a module and find the corresponding URI.
|
||||
I suspect this file is going to be gone after a bit of refactoring."
|
||||
I suspect this file may be gone after a bit of refactoring."
|
||||
|
||||
(local fennel (require :fennel))
|
||||
(local utils (require :fennel-ls.utils))
|
||||
|
||||
"works on my machine >:)"
|
||||
(local luapath "?.lua;src/?.lua")
|
||||
(local fennelpath "?.fnl;src/?.fnl")
|
||||
|
||||
(local sep (package.config:sub 1 1))
|
||||
|
||||
(λ is_absolute [path]
|
||||
@ -39,9 +35,9 @@ I suspect this file is going to be gone after a bit of refactoring."
|
||||
(table.insert result (join (utils.uri->path workspace) path)))))
|
||||
(table.concat result ";")))
|
||||
|
||||
(λ lookup [{: root-uri} mod]
|
||||
(λ lookup [{:config {: fennel-path} : root-uri} mod]
|
||||
(match (or ;; TODO support lua ;; (fennel.searchModule mod (add-workspaces-to-path luapath [root-uri]))
|
||||
(fennel.searchModule mod (add-workspaces-to-path fennelpath [root-uri])))
|
||||
(fennel.searchModule mod (add-workspaces-to-path fennel-path [root-uri])))
|
||||
modname (utils.path->uri modname)
|
||||
nil nil))
|
||||
|
||||
|
||||
@ -9,11 +9,6 @@ object."
|
||||
(local searcher (require :fennel-ls.searcher))
|
||||
(local {: compile} (require :fennel-ls.compiler))
|
||||
|
||||
(λ init-state [self params]
|
||||
(set self.files {})
|
||||
(set self.modules {})
|
||||
(set self.root-uri params.rootUri))
|
||||
|
||||
(λ read-file [uri]
|
||||
(with-open [fd (io.open (utils.uri->path uri))]
|
||||
{:uri uri
|
||||
@ -61,7 +56,36 @@ object."
|
||||
(compile self file)
|
||||
file)))
|
||||
|
||||
{: get-by-uri
|
||||
: get-by-module
|
||||
(local default-config
|
||||
{:fennel-path "./?.fnl;./?/init.fnl;src/?.fnl;src/?/init.fnl"
|
||||
:macro-path "./?.fnl;./?/init-macros.fnl;./?/init.fnl;src/?.fnl;src/?/init-macros.fnl;src/?/init.fnl"
|
||||
:globals ""})
|
||||
|
||||
(λ write-config [self ?config]
|
||||
(if (not ?config)
|
||||
(set self.config default-config) ;; fast path, use all defaults
|
||||
(set self.config
|
||||
{;; fennel-path:
|
||||
;; the path to use to find fennel files using (require) or (include)
|
||||
:fennel-path (or ?config.fennelpath
|
||||
default-config.fennel-path)
|
||||
;; macro-path:
|
||||
;; the path to use to find fennel files using (require-macros) or (include-macros)
|
||||
:macro-path (or ?config.macro-path
|
||||
default-config.fennel-path)
|
||||
;; globals:
|
||||
;; Comma separated list of extra globals that are allowed.
|
||||
:globals (or ?config.globals
|
||||
default-config.globals)})))
|
||||
|
||||
(λ init-state [self params]
|
||||
(set self.files {})
|
||||
(set self.modules {})
|
||||
(set self.root-uri params.rootUri)
|
||||
(write-config self))
|
||||
|
||||
{: get-by-module
|
||||
: get-by-uri
|
||||
: init-state
|
||||
: set-uri-contents
|
||||
: init-state}
|
||||
: write-config}
|
||||
|
||||
@ -56,7 +56,7 @@
|
||||
(check :goto-definition.fnl 35 19 :goto-definition.fnl 34 20 34 35))
|
||||
|
||||
(it "can go to a function in another file when accessed by multisym"
|
||||
(check :goto-definition.fnl 7 7 :foo.fnl 2 4 2 13))
|
||||
(check :goto-definition.fnl 7 7 :./foo.fnl 2 4 2 13))
|
||||
|
||||
(it "goes further if you go to definition on a binding"
|
||||
(check :goto-definition.fnl 31 12 :goto-definition.fnl 23 4 23 5))
|
||||
@ -70,7 +70,7 @@
|
||||
(check :goto-definition.fnl 45 15 :goto-definition.fnl 40 7 40 13))
|
||||
|
||||
(it "works directly on a require/include (require XXX))"
|
||||
(check :goto-definition.fnl 1 5 :bar.fnl 0 0 0 2))
|
||||
(check :goto-definition.fnl 1 5 :./bar.fnl 0 0 0 2))
|
||||
|
||||
(it "goes to the last form of `do` and `let`"
|
||||
(check :goto-definition.fnl 47 13 :goto-definition.fnl 47 30 47 52))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user