diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-07-07 15:01:25 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-07-07 15:01:25 +0800 |
commit | a2050f55b58e5990ebfc33ed9ae4db90c7bf3f19 (patch) | |
tree | 4e1c44a806815b2088877f3c49ed0cfa8942e0d9 /script/provider | |
parent | e7b1f98a39b6761659a4187c424ce3dbbb6ff957 (diff) | |
download | lua-language-server-a2050f55b58e5990ebfc33ed9ae4db90c7bf3f19.zip |
cleanup
Diffstat (limited to 'script/provider')
-rw-r--r-- | script/provider/completion.lua | 11 | ||||
-rw-r--r-- | script/provider/diagnostic.lua | 8 | ||||
-rw-r--r-- | script/provider/provider.lua | 48 | ||||
-rw-r--r-- | script/provider/semantic-tokens.lua | 15 |
4 files changed, 34 insertions, 48 deletions
diff --git a/script/provider/completion.lua b/script/provider/completion.lua index 108ea023..227964b3 100644 --- a/script/provider/completion.lua +++ b/script/provider/completion.lua @@ -1,6 +1,7 @@ local proto = require 'proto' local nonil = require 'without-check-nil' local client = require 'client' +local config = require 'config' local isEnable = false @@ -59,6 +60,16 @@ local function disable() }) end +config.watch(function (key, value) + if key == 'Lua.completion.enable' then + if value == true then + enable() + else + disable() + end + end +end) + return { enable = enable, disable = disable, diff --git a/script/provider/diagnostic.lua b/script/provider/diagnostic.lua index 0a857be7..7ded406d 100644 --- a/script/provider/diagnostic.lua +++ b/script/provider/diagnostic.lua @@ -411,4 +411,12 @@ await.watch(function (ev, co) end end) +config.watch(function (key, value, oldValue) + if key:find 'Lua.diagnostics' then + if value ~= oldValue then + m.diagnosticsAll() + end + end +end) + return m diff --git a/script/provider/provider.lua b/script/provider/provider.lua index 5ad5bc0b..138ee1b5 100644 --- a/script/provider/provider.lua +++ b/script/provider/provider.lua @@ -21,47 +21,6 @@ local tm = require 'text-merger' local nonil = require 'without-check-nil' local cfgLoader = require 'config.loader' -local oldConfig = config.dump() -local function applyConfig() - local diagnostics = require 'provider.diagnostic' - local telemetry = require 'service.telemetry' - local newConfig = config.dump() - log.debug('config updated:', util.dump(newConfig)) - - if not util.equal(oldConfig.Lua.runtime, newConfig.Lua.runtime) then - library.init() - workspace.reload() - semantic.refresh() - end - if not util.equal(oldConfig.Lua.diagnostics, newConfig.Lua.diagnostics) then - diagnostics.diagnosticsAll() - end - if not util.equal(oldConfig.Lua.workspace, newConfig.Lua.workspace) - or not util.equal(oldConfig.files, newConfig.files) - then - workspace.reload() - semantic.refresh() - end - - if newConfig.Lua.completion.enable then - completion.enable() - else - completion.disable() - end - if newConfig.Lua.color.mode == 'Semantic' then - semantic.enable() - else - semantic.disable() - end - if newConfig.Lua.window.statusBar then - proto.notify('$/status/show') - else - proto.notify('$/status/hide') - end - telemetry.updateConfig() - oldConfig = newConfig -end - local function updateConfig() local new if CONFIGPATH then @@ -77,15 +36,8 @@ local function updateConfig() end config.update(new) log.debug('loaded config dump:', util.dump(new)) - applyConfig() end -client.watch(function (ev) - if ev == 'updateConfig' then - applyConfig() - end -end) - proto.on('initialize', function (params) client.init(params) library.init() diff --git a/script/provider/semantic-tokens.lua b/script/provider/semantic-tokens.lua index 5e331ebd..567f80e2 100644 --- a/script/provider/semantic-tokens.lua +++ b/script/provider/semantic-tokens.lua @@ -106,6 +106,21 @@ local function refresh() proto.notify('workspace/semanticTokens/refresh', json.null) end +config.watch(function (key, value) + if key == 'Lua.color.mode' then + if value == 'Semantic' then + enable() + else + disable() + end + end + if key:find '^Lua.runtime' + or key:find '^Lua.workspace' + or key:find '^files' then + refresh() + end +end) + return { enable = enable, disable = disable, |