diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2024-07-30 17:22:02 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2024-07-30 17:22:02 +0800 |
commit | e760b69c8104d0bf6ef17f6f033265908557743d (patch) | |
tree | 3d4779c43fedbd5eb57f44996f18729283790c68 | |
parent | 2a48dee3f216992150f05e288fa6a439c864f0b8 (diff) | |
download | lua-language-server-e760b69c8104d0bf6ef17f6f033265908557743d.zip |
拆分成选项
-rw-r--r-- | script/core/diagnostics/unused-function.lua | 6 | ||||
-rw-r--r-- | script/library.lua | 2 | ||||
-rw-r--r-- | script/plugin.lua | 2 | ||||
-rw-r--r-- | script/provider/provider.lua | 6 |
4 files changed, 12 insertions, 4 deletions
diff --git a/script/core/diagnostics/unused-function.lua b/script/core/diagnostics/unused-function.lua index a873375f..1145036d 100644 --- a/script/core/diagnostics/unused-function.lua +++ b/script/core/diagnostics/unused-function.lua @@ -5,6 +5,7 @@ local define = require 'proto.define' local lang = require 'language' local await = require 'await' local client = require 'client' +local util = require 'utility' local function isToBeClosed(source) if not source.attrs then @@ -105,8 +106,11 @@ return function (uri, callback) turnBlack(source, black, white, links) end + local tagSupports = client.getAbility('textDocument.completion.completionItem.tagSupport.valueSet') + local supportUnnecessary = tagSupports and util.arrayHas(tagSupports, define.DiagnosticTag.Unnecessary) + for source in pairs(white) do - if client.isVSCode() then + if supportUnnecessary then callback { start = source.start, finish = source.finish, diff --git a/script/library.lua b/script/library.lua index cfc7e328..49e39470 100644 --- a/script/library.lua +++ b/script/library.lua @@ -22,7 +22,7 @@ m.metaPaths = {} local function getDocFormater(uri) local version = config.get(uri, 'Lua.runtime.version') - if client.isVSCode() then + if client.getOption('viewDocument') then if version == 'Lua 5.1' then return 'HOVER_NATIVE_DOCUMENT_LUA51' elseif version == 'Lua 5.2' then diff --git a/script/plugin.lua b/script/plugin.lua index b8ecfb6a..ec55875e 100644 --- a/script/plugin.lua +++ b/script/plugin.lua @@ -195,7 +195,7 @@ local function initPlugin(uri) m.showError(scp, err) return end - if not client.isVSCode() and not checkTrustLoad(scp) then + if not client.getOption('trustByClient') and not checkTrustLoad(scp) then return end local suc, err = xpcall(f, log.error, f, uri, myArgs) diff --git a/script/provider/provider.lua b/script/provider/provider.lua index 2e2fb5eb..3c9782c1 100644 --- a/script/provider/provider.lua +++ b/script/provider/provider.lua @@ -292,6 +292,7 @@ m.register 'textDocument/didClose' { m.register 'textDocument/didChange' { ---@async function (params) + local fixIndent = require 'core.fix-indent' local doc = params.textDocument local changes = params.contentChanges local uri = files.getRealUri(doc.uri) @@ -299,6 +300,7 @@ m.register 'textDocument/didChange' { if not text then text = util.loadFile(furi.decode(uri)) files.setText(uri, text, false) + fixIndent(uri, changes) return end local rows = files.getCachedRows(uri) @@ -307,6 +309,8 @@ m.register 'textDocument/didChange' { file.version = doc.version end) files.setCachedRows(uri, rows) + + fixIndent(uri, changes) end } @@ -1059,7 +1063,7 @@ end client.event(function (ev) if ev == 'init' then - if not client.isVSCode() then + if not client.getOption('useSemanticByRange') then m.register 'textDocument/semanticTokens/full' { capability = { semanticTokensProvider = { |