summaryrefslogtreecommitdiff
path: root/script/provider
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-11-25 21:38:57 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-11-25 21:38:57 +0800
commit5ec8ad22d27051507c55d49d6144f08132976215 (patch)
tree75c843f738c0283eb19516293f857d29560d9b3c /script/provider
parent24f4dfa889cc66bd05223e5d8d36fa19865c772b (diff)
downloadlua-language-server-5ec8ad22d27051507c55d49d6144f08132976215.zip
cleanup
Diffstat (limited to 'script/provider')
-rw-r--r--script/provider/completion.lua4
-rw-r--r--script/provider/diagnostic.lua16
-rw-r--r--script/provider/provider.lua27
-rw-r--r--script/provider/semantic-tokens.lua2
4 files changed, 25 insertions, 24 deletions
diff --git a/script/provider/completion.lua b/script/provider/completion.lua
index ec31858a..8e529e95 100644
--- a/script/provider/completion.lua
+++ b/script/provider/completion.lua
@@ -13,7 +13,7 @@ local function allWords()
list[#list+1] = c
mark[c] = true
end
- local postfix = config.get 'Lua.completion.postfix'
+ local postfix = config.get(nil, 'Lua.completion.postfix')
if postfix ~= '' and not mark[postfix] then
list[#list+1] = postfix
mark[postfix] = true
@@ -76,7 +76,7 @@ config.watch(function (key, value)
end
end
if key == 'Lua.completion.postfix' then
- if config.get 'Lua.completion.enable' then
+ if config.get(nil, 'Lua.completion.enable') then
disable()
enable()
end
diff --git a/script/provider/diagnostic.lua b/script/provider/diagnostic.lua
index ca4bcdb8..5630d44f 100644
--- a/script/provider/diagnostic.lua
+++ b/script/provider/diagnostic.lua
@@ -29,7 +29,7 @@ local function buildSyntaxError(uri, err)
local message = lang.script('PARSER_'..err.type, err.info)
if err.version then
- local version = err.info and err.info.version or config.get 'Lua.runtime.version'
+ local version = err.info and err.info.version or config.get(nil, 'Lua.runtime.version')
message = message .. ('(%s)'):format(lang.script('DIAG_NEED_VERSION'
, concat(err.version, '/')
, version
@@ -159,7 +159,7 @@ function m.syntaxErrors(uri, ast)
pcall(function ()
for _, err in ipairs(ast.errs) do
- if not config.get 'Lua.diagnostics.disable'[err.type:lower():gsub('_', '-')] then
+ if not config.get(nil, 'Lua.diagnostics.disable')[err.type:lower():gsub('_', '-')] then
results[#results+1] = buildSyntaxError(uri, err)
end
end
@@ -189,11 +189,11 @@ end
---@async
function m.doDiagnostic(uri)
- if not config.get 'Lua.diagnostics.enable' then
+ if not config.get(nil, 'Lua.diagnostics.enable') then
return
end
if files.isLibrary(uri) then
- local status = config.get 'Lua.diagnostics.libraryFiles'
+ local status = config.get(nil, 'Lua.diagnostics.libraryFiles')
if status == 'Disable' then
return
elseif status == 'Opened' then
@@ -203,7 +203,7 @@ function m.doDiagnostic(uri)
end
end
if ws.isIgnored(uri) then
- local status = config.get 'Lua.diagnostics.ignoredFiles'
+ local status = config.get(nil, 'Lua.diagnostics.ignoredFiles')
if status == 'Disable' then
return
elseif status == 'Opened' then
@@ -333,14 +333,14 @@ local function askForDisable()
end
function m.diagnosticsAll(force)
- if not force and not config.get 'Lua.diagnostics.enable' then
+ if not force and not config.get(nil, 'Lua.diagnostics.enable') then
m.clearAll()
return
end
if not m._start then
return
end
- local delay = config.get 'Lua.diagnostics.workspaceDelay' / 1000
+ local delay = config.get(nil, 'Lua.diagnostics.workspaceDelay') / 1000
if not force and delay < 0 then
return
end
@@ -393,7 +393,7 @@ function m.checkWorkspaceDiag()
if not await.hasID 'diagnosticsAll' then
return
end
- local speedRate = config.get 'Lua.diagnostics.workspaceRate'
+ local speedRate = config.get(nil, 'Lua.diagnostics.workspaceRate')
if speedRate <= 0 or speedRate >= 100 then
return
end
diff --git a/script/provider/provider.lua b/script/provider/provider.lua
index c0cee9c7..0991b690 100644
--- a/script/provider/provider.lua
+++ b/script/provider/provider.lua
@@ -27,36 +27,37 @@ end
---@async
local function updateConfig()
- local merged = {}
+ local baseConfig = {}
local cfg = cfgLoader.loadLocalConfig(CONFIGPATH)
if cfg then
log.debug('load config from local', CONFIGPATH)
-- watch directory
filewatch.watch(workspace.getAbsolutePath(CONFIGPATH):gsub('[^/\\]+$', ''))
- mergeConfig(merged, cfg)
+ mergeConfig(baseConfig, cfg)
+
end
local rc = cfgLoader.loadRCConfig('.luarc.json')
if rc then
log.debug('load config from luarc')
- mergeConfig(merged, rc)
+ mergeConfig(baseConfig, rc)
end
local clientConfig = cfgLoader.loadClientConfig()
if clientConfig then
log.debug('load config from client')
- mergeConfig(merged, clientConfig)
+ mergeConfig(baseConfig, clientConfig)
end
- for k, v in pairs(merged) do
+ for k, v in pairs(baseConfig) do
if v == json.null then
- merged[k] = nil
+ baseConfig[k] = nil
end
end
- config.update(merged)
- log.debug('loaded config dump:', util.dump(merged))
+ config.update(workspace.rootUri,baseConfig)
+ log.debug('loaded config dump:', util.dump(baseConfig))
end
---@class provider
@@ -498,7 +499,7 @@ m.register 'textDocument/completion' {
return nil
end
local triggerCharacter = params.context and params.context.triggerCharacter
- if config.get 'editor.acceptSuggestionOnEnter' ~= 'off' then
+ if config.get(nil, 'editor.acceptSuggestionOnEnter') ~= 'off' then
if triggerCharacter == '\n'
or triggerCharacter == '{'
or triggerCharacter == ',' then
@@ -627,7 +628,7 @@ m.register 'textDocument/signatureHelp' {
abortByFileUpdate = true,
---@async
function (params)
- if not config.get 'Lua.signatureHelp.enable' then
+ if not config.get(nil, 'Lua.signatureHelp.enable') then
return nil
end
workspace.awaitReady()
@@ -956,7 +957,7 @@ m.register '$/requestHint' {
---@async
function (params)
local core = require 'core.hint'
- if not config.get 'Lua.hint.enable' then
+ if not config.get(nil, 'Lua.hint.enable') then
return
end
workspace.awaitReady()
@@ -979,7 +980,7 @@ m.register '$/requestHint' {
do
---@async
local function updateHint(uri)
- if not config.get 'Lua.hint.enable' then
+ if not config.get(nil, 'Lua.hint.enable') then
return
end
local id = 'updateHint' .. uri
@@ -1026,7 +1027,7 @@ do
end
local function refreshStatusBar()
- local value = config.get 'Lua.window.statusBar'
+ local value = config.get(nil, 'Lua.window.statusBar')
if value then
proto.notify('$/status/show')
else
diff --git a/script/provider/semantic-tokens.lua b/script/provider/semantic-tokens.lua
index 68db9b7f..759a9885 100644
--- a/script/provider/semantic-tokens.lua
+++ b/script/provider/semantic-tokens.lua
@@ -47,7 +47,7 @@ local function enable()
},
}
})
- if config.get 'editor.semanticHighlighting.enabled' == 'configuredByTheme' and not dontShowAgain then
+ if config.get(nil, 'editor.semanticHighlighting.enabled') == 'configuredByTheme' and not dontShowAgain then
proto.request('window/showMessageRequest', {
type = define.MessageType.Info,
message = lang.script.WINDOW_CHECK_SEMANTIC,