Skip to content

Commit e760b69

Browse files
committed
拆分成选项
1 parent 2a48dee commit e760b69

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

script/core/diagnostics/unused-function.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ local define = require 'proto.define'
55
local lang = require 'language'
66
local await = require 'await'
77
local client = require 'client'
8+
local util = require 'utility'
89

910
local function isToBeClosed(source)
1011
if not source.attrs then
@@ -105,8 +106,11 @@ return function (uri, callback)
105106
turnBlack(source, black, white, links)
106107
end
107108

109+
local tagSupports = client.getAbility('textDocument.completion.completionItem.tagSupport.valueSet')
110+
local supportUnnecessary = tagSupports and util.arrayHas(tagSupports, define.DiagnosticTag.Unnecessary)
111+
108112
for source in pairs(white) do
109-
if client.isVSCode() then
113+
if supportUnnecessary then
110114
callback {
111115
start = source.start,
112116
finish = source.finish,

script/library.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ m.metaPaths = {}
2222

2323
local function getDocFormater(uri)
2424
local version = config.get(uri, 'Lua.runtime.version')
25-
if client.isVSCode() then
25+
if client.getOption('viewDocument') then
2626
if version == 'Lua 5.1' then
2727
return 'HOVER_NATIVE_DOCUMENT_LUA51'
2828
elseif version == 'Lua 5.2' then

script/plugin.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ local function initPlugin(uri)
195195
m.showError(scp, err)
196196
return
197197
end
198-
if not client.isVSCode() and not checkTrustLoad(scp) then
198+
if not client.getOption('trustByClient') and not checkTrustLoad(scp) then
199199
return
200200
end
201201
local suc, err = xpcall(f, log.error, f, uri, myArgs)

script/provider/provider.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,13 +292,15 @@ m.register 'textDocument/didClose' {
292292
m.register 'textDocument/didChange' {
293293
---@async
294294
function (params)
295+
local fixIndent = require 'core.fix-indent'
295296
local doc = params.textDocument
296297
local changes = params.contentChanges
297298
local uri = files.getRealUri(doc.uri)
298299
local text = files.getOriginText(uri)
299300
if not text then
300301
text = util.loadFile(furi.decode(uri))
301302
files.setText(uri, text, false)
303+
fixIndent(uri, changes)
302304
return
303305
end
304306
local rows = files.getCachedRows(uri)
@@ -307,6 +309,8 @@ m.register 'textDocument/didChange' {
307309
file.version = doc.version
308310
end)
309311
files.setCachedRows(uri, rows)
312+
313+
fixIndent(uri, changes)
310314
end
311315
}
312316

@@ -1059,7 +1063,7 @@ end
10591063

10601064
client.event(function (ev)
10611065
if ev == 'init' then
1062-
if not client.isVSCode() then
1066+
if not client.getOption('useSemanticByRange') then
10631067
m.register 'textDocument/semanticTokens/full' {
10641068
capability = {
10651069
semanticTokensProvider = {

0 commit comments

Comments
 (0)