summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-03-15 21:07:14 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-03-15 21:07:14 +0800
commit9bde1d4431a466e894a81b533a3a037b9e574305 (patch)
tree6ce24ce672fbdf97c0a1592f461d5df4e562e259
parentb552559036d6a635d51ea27da0b59fa9150ac27f (diff)
downloadlua-language-server-9bde1d4431a466e894a81b533a3a037b9e574305.zip
improve setting
-rw-r--r--script/config.lua18
-rw-r--r--script/library.lua12
-rw-r--r--script/proto/define.lua17
3 files changed, 25 insertions, 22 deletions
diff --git a/script/config.lua b/script/config.lua
index e34b1ca4..5273e0cd 100644
--- a/script/config.lua
+++ b/script/config.lua
@@ -126,23 +126,7 @@ local ConfigTemplate = {
nonstandardSymbol = {{}, Str2Hash ';'},
plugin = {'.vscode/lua/plugin.lua', String},
fileEncoding = {'utf8', String},
- builtin = {{
- ['basic'] = 'enable',
- ['bit'] = 'enable',
- ['bit32'] = 'enable',
- ['builtin'] = 'enable',
- ['coroutine'] = 'enable',
- ['debug'] = 'enable',
- ['ffi'] = 'enable',
- ['io'] = 'enable',
- ['jit'] = 'enable',
- ['math'] = 'enable',
- ['os'] = 'enable',
- ['package'] = 'enable',
- ['string'] = 'enable',
- ['table'] = 'enable',
- ['utf8'] = 'enable',
- }, Hash(String, String)},
+ builtin = {{}, Hash(String, String)},
},
diagnostics = {
enable = {true, Boolean},
diff --git a/script/library.lua b/script/library.lua
index e643e2ec..a2b400bf 100644
--- a/script/library.lua
+++ b/script/library.lua
@@ -5,6 +5,7 @@ local lang = require 'language'
local client = require 'provider.client'
local lloader = require 'locale-loader'
local fsu = require 'fs-utility'
+local define = require "proto.define"
local m = {}
@@ -76,7 +77,7 @@ local function createViewDocument(name)
return ('[%s](%s)'):format(lang.script.HOVER_VIEW_DOCUMENTS, lang.script(fmt, 'pdf-' .. name))
end
-local function compileSingleMetaDoc(script, metaLang)
+local function compileSingleMetaDoc(script, metaLang, status)
if not script then
return nil
end
@@ -170,7 +171,7 @@ local function compileSingleMetaDoc(script, metaLang)
util.saveFile((ROOT / 'log' / 'middleScript.lua'):string(), middleScript)
assert(load(middleScript, middleScript, 't', env))()
- if disable then
+ if disable and status == 'default' then
return nil
end
return table.concat(compileBuf)
@@ -205,13 +206,14 @@ local function compileMetaDoc()
fs.create_directories(metaPath)
local out = fsu.dummyFS()
local templateDir = ROOT / 'meta' / 'template'
- for libName, status in pairs(config.config.runtime.builtin) do
- if status ~= 'enable' then
+ for libName, status in pairs(define.BuiltIn) do
+ status = config.config.runtime.builtin[libName] or status
+ if status == 'disable' then
goto CONTINUE
end
libName = libName .. '.lua'
local libPath = templateDir / libName
- local metaDoc = compileSingleMetaDoc(fsu.loadFile(libPath), metaLang)
+ local metaDoc = compileSingleMetaDoc(fsu.loadFile(libPath), metaLang, status)
if metaDoc then
local outPath = metaPath / libName
out:saveFile(libName, metaDoc)
diff --git a/script/proto/define.lua b/script/proto/define.lua
index 55f477b6..6bc3b891 100644
--- a/script/proto/define.lua
+++ b/script/proto/define.lua
@@ -267,5 +267,22 @@ m.TokenTypes = {
["label"] = 18,
}
+m.BuiltIn = {
+ ['basic'] = 'default',
+ ['bit'] = 'default',
+ ['bit32'] = 'default',
+ ['builtin'] = 'default',
+ ['coroutine'] = 'default',
+ ['debug'] = 'default',
+ ['ffi'] = 'default',
+ ['io'] = 'default',
+ ['jit'] = 'default',
+ ['math'] = 'default',
+ ['os'] = 'default',
+ ['package'] = 'default',
+ ['string'] = 'default',
+ ['table'] = 'default',
+ ['utf8'] = 'default',
+}
return m