diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-02-09 19:05:58 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-02-09 19:05:58 +0800 |
commit | 3f0d26ef525cc81da24d55706fb079fa5a97b56e (patch) | |
tree | 886806e5b151f80271980fed427bfd876b6fb9d3 /script | |
parent | 5ad56c9ccfef9dfbe18a8846d1303b4668077b55 (diff) | |
download | lua-language-server-3f0d26ef525cc81da24d55706fb079fa5a97b56e.zip |
cleanup
Diffstat (limited to 'script')
-rw-r--r-- | script/brave/init.lua | 2 | ||||
-rw-r--r-- | script/client.lua | 4 | ||||
-rw-r--r-- | script/core/code-action.lua | 7 | ||||
-rw-r--r-- | script/core/command/jsonToLua.lua | 6 | ||||
-rw-r--r-- | script/core/command/setConfig.lua | 2 | ||||
-rw-r--r-- | script/core/completion/completion.lua | 2 | ||||
-rw-r--r-- | script/provider/diagnostic.lua | 22 |
7 files changed, 24 insertions, 21 deletions
diff --git a/script/brave/init.lua b/script/brave/init.lua index 24c2e412..9cad8c4e 100644 --- a/script/brave/init.lua +++ b/script/brave/init.lua @@ -1,4 +1,4 @@ -local brave = require 'brave.brave' +local brave = require 'brave.brave' require 'brave.work' return brave diff --git a/script/client.lua b/script/client.lua index 86b13179..9074239a 100644 --- a/script/client.lua +++ b/script/client.lua @@ -250,7 +250,9 @@ local function tryModifyRC(uri, finalChanges, create) end local scp = scope.getScope(uri) local rc = scp:get('lastRCConfig') or { - ['$schema'] = lang.id == 'zh-cn' and [[https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema-zh-cn.json]] or [[https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json]] + ['$schema'] = lang.id == 'zh-cn' + and [[https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema-zh-cn.json]] + or [[https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json]] } local suc = applyConfig(rc, uri, finalChanges) if not suc then diff --git a/script/core/code-action.lua b/script/core/code-action.lua index b2a6fac9..f96e341a 100644 --- a/script/core/code-action.lua +++ b/script/core/code-action.lua @@ -43,13 +43,13 @@ local function checkDisableByLuaDocInsert(uri, row, mode, code) end local function disableDiagnostic(uri, code, start, results) - local row = guide.rowColOf(start) + local row = guide.rowColOf(start) results[#results+1] = { title = lang.script('ACTION_DISABLE_DIAG', code), kind = 'quickfix', command = { - title = lang.script.COMMAND_DISABLE_DIAG, - command = 'lua.setConfig', + title = lang.script.COMMAND_DISABLE_DIAG, + command = 'lua.setConfig', arguments = { { key = 'Lua.diagnostics.disable', @@ -174,7 +174,6 @@ local function solveSyntaxByChangeVersion(uri, err, results) end local function solveSyntaxByAddDoEnd(uri, err, results) - local text = files.getText(uri) results[#results+1] = { title = lang.script.ACTION_ADD_DO_END, kind = 'quickfix', diff --git a/script/core/command/jsonToLua.lua b/script/core/command/jsonToLua.lua index d29ad608..fb0fc6c9 100644 --- a/script/core/command/jsonToLua.lua +++ b/script/core/command/jsonToLua.lua @@ -14,9 +14,9 @@ return function (data) if not text then return end - local start = guide.positionToOffset(state, data.start) - local finish = guide.positionToOffset(state, data.finish) - local jsonStr = text:sub(start + 1, finish) + local start = guide.positionToOffset(state, data.start) + local finish = guide.positionToOffset(state, data.finish) + local jsonStr = text:sub(start + 1, finish) local suc, res = pcall(json.decode, jsonStr) if not suc then proto.notify('window/showMessage', { diff --git a/script/core/command/setConfig.lua b/script/core/command/setConfig.lua index e3eb0d0a..4587dd47 100644 --- a/script/core/command/setConfig.lua +++ b/script/core/command/setConfig.lua @@ -1,5 +1,5 @@ local client = require 'client' return function (data) - client.setConfig {data} + client.setConfig { data } end diff --git a/script/core/completion/completion.lua b/script/core/completion/completion.lua index 680b9a23..a8000c91 100644 --- a/script/core/completion/completion.lua +++ b/script/core/completion/completion.lua @@ -75,7 +75,7 @@ local function findNearestTableField(state, position) if not soffset then return nil end - local symbol = text:sub(soffset, soffset) + local symbol = text:sub(soffset, soffset) if symbol == '}' then return nil end diff --git a/script/provider/diagnostic.lua b/script/provider/diagnostic.lua index d0de0962..32b6fc6f 100644 --- a/script/provider/diagnostic.lua +++ b/script/provider/diagnostic.lua @@ -28,7 +28,7 @@ end local function buildSyntaxError(uri, err) local text = files.getText(uri) - local message = lang.script('PARSER_'..err.type, err.info) + local message = lang.script('PARSER_' .. err.type, err.info) if err.version then local version = err.info and err.info.version or config.get(uri, 'Lua.runtime.version') @@ -45,7 +45,7 @@ local function buildSyntaxError(uri, err) for _, rel in ipairs(related) do local rmessage if rel.message then - rmessage = lang.script('PARSER_'..rel.message) + rmessage = lang.script('PARSER_' .. rel.message) else rmessage = text:sub(rel.start, rel.finish) end @@ -63,8 +63,9 @@ local function buildSyntaxError(uri, err) severity = define.DiagnosticSeverity[err.level], source = lang.script.DIAG_SYNTAX_CHECK, message = message, - relatedInformation = relatedInformation, data = 'syntax', + + relatedInformation = relatedInformation, } end @@ -77,7 +78,7 @@ local function buildDiagnostic(uri, diag) if diag.related then relatedInformation = {} for _, rel in ipairs(diag.related) do - local rtext = files.getText(rel.uri) + local rtext = files.getText(rel.uri) relatedInformation[#relatedInformation+1] = { message = rel.message or rtext:sub(rel.start, rel.finish), location = converter.location(rel.uri, converter.packRange(rel.uri, rel.start, rel.finish)) @@ -93,6 +94,7 @@ local function buildDiagnostic(uri, diag) code = diag.code, tags = diag.tags, data = diag.data, + relatedInformation = relatedInformation, } end @@ -292,12 +294,17 @@ function m.refresh(uri) end await.close('diag:' .. uri) await.call(function () ---@async - m.diagnosticsScope(uri) if uri then await.setID('diag:' .. uri) await.sleep(0.1) xpcall(m.doDiagnostic, log.error, uri) end + local delay = config.get(uri, 'Lua.diagnostics.workspaceDelay') / 1000 + if delay < 0 then + return + end + await.sleep(math.max(delay, 0.2)) + m.diagnosticsScope(uri) end) end @@ -357,15 +364,10 @@ function m.diagnosticsScope(uri, force) m.clearAll() return end - local delay = config.get(uri, 'Lua.diagnostics.workspaceDelay') / 1000 - if not force and delay < 0 then - return - end local scp = scope.getScope(uri) local id = 'diagnosticsScope:' .. scp:getName() await.close(id) await.call(function () ---@async - await.sleep(math.max(delay, 0.2)) while loading.count() > 0 do await.sleep(1.0) end |