summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCppCXY <812125110@qq.com>2022-02-21 15:05:24 +0800
committerCppCXY <812125110@qq.com>2022-02-21 15:05:24 +0800
commite518eed9efd99c46b79c9413c5f34a0f675ab9e6 (patch)
tree72c174b6f11e9965ac85dbc0d0d92db78e6262bd
parentbfcbdd35745ff1fc821781ec2153edfe87c63767 (diff)
parent61498917bb2d6686b97c6193b2f713f099faf769 (diff)
downloadlua-language-server-e518eed9efd99c46b79c9413c5f34a0f675ab9e6.zip
解决冲突
-rw-r--r--.vscode/settings.json1
m---------3rd/EmmyLuaCodeStyle0
-rw-r--r--script/config/config.lua2
-rw-r--r--script/global.d.lua6
-rw-r--r--script/provider/capability.lua91
-rw-r--r--script/provider/provider.lua100
6 files changed, 136 insertions, 64 deletions
diff --git a/.vscode/settings.json b/.vscode/settings.json
index f8ca82c5..0260f483 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -1,6 +1,7 @@
// Just some comment
{
"Lua.misc.parameters": [
+ "--preview",
"--develop=true",
"--dbgport=11413",
]
diff --git a/3rd/EmmyLuaCodeStyle b/3rd/EmmyLuaCodeStyle
-Subproject af4cbbdf1da3c5227525288cb88a04f66129829
+Subproject 3271ec9a73946409902d3348b3bba858d442be3
diff --git a/script/config/config.lua b/script/config/config.lua
index a430d623..8c06278f 100644
--- a/script/config/config.lua
+++ b/script/config/config.lua
@@ -208,7 +208,7 @@ local Template = {
['Lua.hint.arrayIndex'] = Type.Boolean >> 'Auto',
['Lua.window.statusBar'] = Type.Boolean >> true,
['Lua.window.progressBar'] = Type.Boolean >> true,
- ['Lua.format.enable'] = Type.Boolean >> false,
+ ['Lua.format.enable'] = Type.Boolean >> true,
['Lua.format.defaultConfig'] = Type.Hash(Type.String, Type.String)
>> {},
['Lua.IntelliSense.traceLocalSet'] = Type.Boolean >> false,
diff --git a/script/global.d.lua b/script/global.d.lua
index 0435293e..ad4fb364 100644
--- a/script/global.d.lua
+++ b/script/global.d.lua
@@ -33,3 +33,9 @@ FOOTPRINT = false
---trace rpc, use command line: --rpclog=true
---@type boolean
RPCLOG = false
+
+--enable preview features.
+--
+--the current version is `formatting`
+---@type boolean
+PREVIEW = false
diff --git a/script/provider/capability.lua b/script/provider/capability.lua
index e012f4b4..ba5690bf 100644
--- a/script/provider/capability.lua
+++ b/script/provider/capability.lua
@@ -7,17 +7,6 @@ local define = require 'proto.define'
require 'provider.semantic-tokens'
require 'provider.formatting'
-local function toArray(map)
- local array = {}
- for k in pairs(map) do
- array[#array+1] = k
- end
- table.sort(array, function (a, b)
- return map[a] < map[b]
- end)
- return array
-end
-
local m = {}
local function testFileEvents(initer)
@@ -58,8 +47,27 @@ local function testFileEvents(initer)
}
end
-function m.getIniter()
- local initer = {
+m.fillings = {}
+
+local function mergeFillings(provider)
+ for _, filling in ipairs(m.fillings) do
+ for k, v in pairs(filling) do
+ if type(v) == 'table' then
+ if not provider[k] then
+ provider[k] = {}
+ end
+ for kk, vv in pairs(v) do
+ provider[k][kk] = vv
+ end
+ else
+ provider[k] = v
+ end
+ end
+ end
+end
+
+function m.getProvider()
+ local provider = {
offsetEncoding = client.getOffsetEncoding(),
-- 文本同步方式
textDocumentSync = {
@@ -68,53 +76,6 @@ function m.getIniter()
-- 文本增量更新
change = 2,
},
-
- hoverProvider = true,
- definitionProvider = true,
- typeDefinitionProvider = true,
- referencesProvider = true,
- renameProvider = {
- prepareProvider = true,
- },
- documentSymbolProvider = true,
- workspaceSymbolProvider = true,
- documentHighlightProvider = true,
- codeActionProvider = {
- codeActionKinds = {
- '',
- 'quickfix',
- 'refactor.rewrite',
- 'refactor.extract',
- },
- resolveProvider = false,
- },
- signatureHelpProvider = {
- triggerCharacters = { '(', ',' },
- },
- executeCommandProvider = {
- commands = {
- 'lua.removeSpace',
- 'lua.solve',
- 'lua.jsonToLua',
- 'lua.setConfig',
- 'lua.autoRequire',
- },
- },
- foldingRangeProvider = true,
- documentOnTypeFormattingProvider = {
- firstTriggerCharacter = '\n',
- moreTriggerCharacter = nil, -- string[]
- },
- semanticTokensProvider = {
- legend = {
- tokenTypes = toArray(define.TokenTypes),
- tokenModifiers = toArray(define.TokenModifiers),
- },
- range = true,
- full = false,
- },
- documentFormattingProvider = true,
- documentRangeFormattingProvider = true
}
--testFileEvents()
@@ -122,14 +83,20 @@ function m.getIniter()
nonil.enable()
if not client.info.capabilities.textDocument.completion.dynamicRegistration
or not client.info.capabilities.workspace.configuration then
- initer.completionProvider = {
+ provider.completionProvider = {
resolveProvider = true,
triggerCharacters = completion.allWords(),
}
end
nonil.disable()
- return initer
+ mergeFillings(provider)
+
+ return provider
+end
+
+function m.filling(t)
+ m.fillings[#m.fillings+1] = t
end
return m
diff --git a/script/provider/provider.lua b/script/provider/provider.lua
index 7d628306..f5bace80 100644
--- a/script/provider/provider.lua
+++ b/script/provider/provider.lua
@@ -61,6 +61,12 @@ m.attributes = {}
function m.register(method)
return function (attrs)
m.attributes[method] = attrs
+ if attrs.preview and not PREVIEW then
+ return
+ end
+ if attrs.capability then
+ cap.filling(attrs.capability)
+ end
proto.on(method, attrs[1])
end
end
@@ -101,7 +107,7 @@ m.register 'initialize' {
end
return {
- capabilities = cap.getIniter(),
+ capabilities = cap.getProvider(),
serverInfo = {
name = 'sumneko.lua',
},
@@ -261,6 +267,9 @@ m.register 'textDocument/didChange' {
}
m.register 'textDocument/hover' {
+ capability = {
+ hoverProvider = true,
+ },
abortByFileUpdate = true,
---@async
function (params)
@@ -299,6 +308,9 @@ m.register 'textDocument/hover' {
}
m.register 'textDocument/definition' {
+ capability = {
+ definitionProvider = true,
+ },
abortByFileUpdate = true,
---@async
function (params)
@@ -338,6 +350,9 @@ m.register 'textDocument/definition' {
}
m.register 'textDocument/typeDefinition' {
+ capability = {
+ typeDefinitionProvider = true,
+ },
abortByFileUpdate = true,
---@async
function (params)
@@ -377,6 +392,9 @@ m.register 'textDocument/typeDefinition' {
}
m.register 'textDocument/references' {
+ capability = {
+ referencesProvider = true,
+ },
abortByFileUpdate = true,
---@async
function (params)
@@ -404,6 +422,9 @@ m.register 'textDocument/references' {
}
m.register 'textDocument/documentHighlight' {
+ capability = {
+ documentHighlightProvider = true,
+ },
abortByFileUpdate = true,
function (params)
local core = require 'core.highlight'
@@ -428,6 +449,11 @@ m.register 'textDocument/documentHighlight' {
}
m.register 'textDocument/rename' {
+ capability = {
+ renameProvider = {
+ prepareProvider = true,
+ },
+ },
abortByFileUpdate = true,
---@async
function (params)
@@ -631,6 +657,11 @@ m.register 'completionItem/resolve' {
}
m.register 'textDocument/signatureHelp' {
+ capability = {
+ signatureHelpProvider = {
+ triggerCharacters = { '(', ',' },
+ },
+ },
abortByFileUpdate = true,
---@async
function (params)
@@ -677,6 +708,9 @@ m.register 'textDocument/signatureHelp' {
}
m.register 'textDocument/documentSymbol' {
+ capability = {
+ documentSymbolProvider = true,
+ },
abortByFileUpdate = true,
---@async
function (params)
@@ -723,6 +757,17 @@ m.register 'textDocument/documentSymbol' {
}
m.register 'textDocument/codeAction' {
+ capability = {
+ codeActionProvider = {
+ codeActionKinds = {
+ '',
+ 'quickfix',
+ 'refactor.rewrite',
+ 'refactor.extract',
+ },
+ resolveProvider = false,
+ },
+ },
abortByFileUpdate = true,
function (params)
local core = require 'core.code-action'
@@ -757,6 +802,17 @@ m.register 'textDocument/codeAction' {
}
m.register 'workspace/executeCommand' {
+ capability = {
+ executeCommandProvider = {
+ commands = {
+ 'lua.removeSpace',
+ 'lua.solve',
+ 'lua.jsonToLua',
+ 'lua.setConfig',
+ 'lua.autoRequire',
+ },
+ },
+ },
---@async
function (params)
local command = params.command:gsub(':.+', '')
@@ -780,6 +836,9 @@ m.register 'workspace/executeCommand' {
}
m.register 'workspace/symbol' {
+ capability = {
+ workspaceSymbolProvider = true,
+ },
abortByFileUpdate = true,
---@async
function (params)
@@ -826,7 +885,29 @@ m.register 'textDocument/semanticTokens/full' {
end
}
+local function toArray(map)
+ local array = {}
+ for k in pairs(map) do
+ array[#array+1] = k
+ end
+ table.sort(array, function (a, b)
+ return map[a] < map[b]
+ end)
+ return array
+end
+
+
m.register 'textDocument/semanticTokens/range' {
+ capability = {
+ semanticTokensProvider = {
+ legend = {
+ tokenTypes = toArray(define.TokenTypes),
+ tokenModifiers = toArray(define.TokenModifiers),
+ },
+ range = true,
+ full = false,
+ },
+ },
---@async
function (params)
log.debug('textDocument/semanticTokens/range')
@@ -843,6 +924,9 @@ m.register 'textDocument/semanticTokens/range' {
}
m.register 'textDocument/foldingRange' {
+ capability = {
+ foldingRangeProvider = true,
+ },
abortByFileUpdate = true,
---@async
function (params)
@@ -915,6 +999,10 @@ m.register '$/status/click' {
}
m.register 'textDocument/formatting' {
+ capability = {
+ documentFormattingProvider = true,
+ },
+ preview = true,
---@async
function(params)
local uri = files.getRealUri(params.textDocument.uri)
@@ -949,6 +1037,10 @@ m.register 'textDocument/formatting' {
}
m.register 'textDocument/rangeFormatting' {
+ capability = {
+ documentRangeFormattingProvider = true,
+ },
+ preview = true,
---@async
function(params)
local uri = files.getRealUri(params.textDocument.uri)
@@ -983,6 +1075,12 @@ m.register 'textDocument/rangeFormatting' {
}
m.register 'textDocument/onTypeFormatting' {
+ capability = {
+ documentOnTypeFormattingProvider = {
+ firstTriggerCharacter = '\n',
+ moreTriggerCharacter = nil, -- string[]
+ },
+ },
abortByFileUpdate = true,
---@async
function (params)