Fix loading of globals from love2d generated documentation.
The first thing to change is to load the love2d docset inside a pcall, because it's not included in the standard `make` build, so we need to not crash if it's not present. Note that we are storing these under libraries.love2d rather than libraries.love-2d, because even tho it's inconsistent with tic-80; I've never seen them use the hyphenated version, and now the name matches the module name. Secondly, we extend the get-global function to work with anything in the server.configuration.libraries table, not just hard-coded to tic-80. Finally, update the manual to reflect the removal of the love2d hypen.
This commit is contained in:
parent
f0c512575e
commit
1c6999ea3f
@ -70,7 +70,7 @@ The default `flsproject.fnl` settings are:
|
||||
{: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"
|
||||
:lua-version "lua54"
|
||||
:libraries {:love-2d false
|
||||
:libraries {:love2d false
|
||||
:tic-80 false}
|
||||
:extra-globals ""
|
||||
:lints {:unused-definition true
|
||||
|
||||
@ -25,9 +25,11 @@
|
||||
table.sort)))))
|
||||
(. lua-versions version))
|
||||
|
||||
(local libraries
|
||||
{:love-2d (require :fennel-ls.docs.generated.love2d)
|
||||
:tic-80 (require :fennel-ls.docs.generated.tic80)})
|
||||
(local libraries {:tic-80 (require :fennel-ls.docs.generated.tic80)})
|
||||
|
||||
;; can't just pcall require because we want to trigger require-as-include
|
||||
(case (pcall #(require :fennel-ls.docs.generated.love2d))
|
||||
(true love2d) (set libraries.love2d love2d))
|
||||
|
||||
(fn get-library [library]
|
||||
(when (not (. libraries library))
|
||||
@ -47,9 +49,13 @@
|
||||
&into result]
|
||||
name)))
|
||||
|
||||
(fn get-library-global [server global-name]
|
||||
(accumulate [g nil library-name enabled? (pairs server.configuration.libraries)
|
||||
&until g]
|
||||
(and enabled? (. (get-library library-name) global-name))))
|
||||
|
||||
(fn get-global [server global-name]
|
||||
(or (and server.configuration.libraries.tic-80
|
||||
(. (get-library :tic-80) global-name))
|
||||
(or (get-library-global server global-name)
|
||||
(. (get-lua-version server.configuration.lua-version) global-name)))
|
||||
|
||||
(fn get-builtin [_server builtin-name]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user