diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-03-15 20:46:58 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-03-15 20:46:58 +0800 |
commit | b552559036d6a635d51ea27da0b59fa9150ac27f (patch) | |
tree | abf10867b13b3198eaae148176e5637f3da8d9f3 /script/library.lua | |
parent | a508e59114168f89d48b16a9c9c1da9c14df7802 (diff) | |
download | lua-language-server-b552559036d6a635d51ea27da0b59fa9150ac27f.zip |
new setting `Lua.runtime.builtin`
Diffstat (limited to 'script/library.lua')
-rw-r--r-- | script/library.lua | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/script/library.lua b/script/library.lua index c7cecef6..e643e2ec 100644 --- a/script/library.lua +++ b/script/library.lua @@ -4,6 +4,7 @@ local util = require 'utility' local lang = require 'language' local client = require 'provider.client' local lloader = require 'locale-loader' +local fsu = require 'fs-utility' local m = {} @@ -76,6 +77,10 @@ local function createViewDocument(name) end local function compileSingleMetaDoc(script, metaLang) + if not script then + return nil + end + local middleBuf = {} local compileBuf = {} @@ -184,7 +189,7 @@ end local function compileMetaDoc() local langID = lang.id local version = config.config.runtime.version - local metapath = fs.path(METAPATH) / config.config.runtime.meta:gsub('%$%{(.-)%}', { + local metaPath = fs.path(METAPATH) / config.config.runtime.meta:gsub('%$%{(.-)%}', { version = version, language = langID, }) @@ -195,21 +200,26 @@ local function compileMetaDoc() end --log.debug('metaLang:', util.dump(metaLang)) - m.metaPath = metapath:string() + m.metaPath = metaPath:string() m.metaPaths = {} - fs.create_directories(metapath) + fs.create_directories(metaPath) + local out = fsu.dummyFS() local templateDir = ROOT / 'meta' / 'template' - for fullpath in templateDir:list_directory() do - local filename = fullpath:filename() - local metaDoc = compileSingleMetaDoc(util.loadFile(fullpath:string()), metaLang) - local filepath = metapath / filename + for libName, status in pairs(config.config.runtime.builtin) do + if status ~= 'enable' then + goto CONTINUE + end + libName = libName .. '.lua' + local libPath = templateDir / libName + local metaDoc = compileSingleMetaDoc(fsu.loadFile(libPath), metaLang) if metaDoc then - util.saveFile(filepath:string(), metaDoc) - m.metaPaths[#m.metaPaths+1] = filepath:string() - else - fs.remove(filepath) + local outPath = metaPath / libName + out:saveFile(libName, metaDoc) + m.metaPaths[#m.metaPaths+1] = outPath:string() end + ::CONTINUE:: end + fsu.fileSync(out, metaPath) end local function initFromMetaDoc() |