Missing Lua versions or libraries cause warnings, not crashes.
Unfortunately the experience here is not great, at least in emacs; the spec states that the server may send showMessage during initialization, but eglot displays these messages only for a brief flash, quickly replacing them with the "Connected!" message. We probably need a different solution here but it might get ugly; like some kind of outbound queue.
This commit is contained in:
parent
3e4b96ff27
commit
bc0898510e
@ -31,12 +31,7 @@
|
|||||||
(set lua-versions.lua54 (. lua-versions "lua5.4"))
|
(set lua-versions.lua54 (. lua-versions "lua5.4"))
|
||||||
|
|
||||||
(fn get-lua-version [version]
|
(fn get-lua-version [version]
|
||||||
(when (not (. lua-versions version))
|
(or (. lua-versions version) lua-versions.lua54))
|
||||||
(error (.. "fennel-ls doesn't know about lua version " version "\n"
|
|
||||||
"The known versions are: "
|
|
||||||
(fennel.view (doto (icollect [key (pairs lua-versions)] key)
|
|
||||||
table.sort)))))
|
|
||||||
(. lua-versions version))
|
|
||||||
|
|
||||||
;; work around a mistake in Lua's own manual
|
;; work around a mistake in Lua's own manual
|
||||||
(set lua-versions.lua51.package.fields.config
|
(set lua-versions.lua51.package.fields.config
|
||||||
@ -57,12 +52,13 @@
|
|||||||
|
|
||||||
(λ load-library [name]
|
(λ load-library [name]
|
||||||
(let [path (.. data-dir name docset-ext)]
|
(let [path (.. data-dir name docset-ext)]
|
||||||
(case (io.open path :r)
|
(case (io.open path)
|
||||||
nil (error (string.format "Could not find docset for library %s at %s"
|
|
||||||
name path))
|
|
||||||
f (let [docs (fennel.load-code (f:read :a) {})]
|
f (let [docs (fennel.load-code (f:read :a) {})]
|
||||||
(f:close)
|
(f:close)
|
||||||
(docs)))))
|
(docs))
|
||||||
|
_ {:status :not-found
|
||||||
|
:msg (string.format "Could not find docset for library %s at %s"
|
||||||
|
name path)})))
|
||||||
|
|
||||||
(λ get-library [name]
|
(λ get-library [name]
|
||||||
(when (not (. libraries name))
|
(when (not (. libraries name))
|
||||||
@ -97,10 +93,14 @@
|
|||||||
|
|
||||||
(λ validate-config [configuration invalid]
|
(λ validate-config [configuration invalid]
|
||||||
(when (not (. lua-versions configuration.lua-version))
|
(when (not (. lua-versions configuration.lua-version))
|
||||||
(invalid (.. "unknown lua version: " configuration.lua-version)))
|
(invalid (.. "fennel-ls doesn't know about lua version "
|
||||||
|
configuration.lua-version
|
||||||
|
"\nThe known versions are: "
|
||||||
|
(table.concat (icollect [k (pairs lua-versions)] k) ", "))
|
||||||
|
:WARN))
|
||||||
(each [library-name (pairs configuration.libraries)]
|
(each [library-name (pairs configuration.libraries)]
|
||||||
(case (pcall get-library library-name)
|
(case (get-library library-name)
|
||||||
(nil msg) (invalid msg))))
|
{:status :not-found : msg} (invalid msg :WARN))))
|
||||||
|
|
||||||
{: get-global
|
{: get-global
|
||||||
: get-builtin
|
: get-builtin
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user