diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-02-21 14:20:55 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-02-21 14:20:55 +0800 |
commit | 2dd4ea4b7d95561b228a97800f5f68a30a6cff97 (patch) | |
tree | ce53a95e4e0f7e6f5f1914df59005ae447b3c6ca /script/provider/capability.lua | |
parent | 1fc44f4d934960a0e0bcfe4da35a8429ced4f2e4 (diff) | |
download | lua-language-server-2dd4ea4b7d95561b228a97800f5f68a30a6cff97.zip |
cleanup
Diffstat (limited to 'script/provider/capability.lua')
-rw-r--r-- | script/provider/capability.lua | 91 |
1 files changed, 29 insertions, 62 deletions
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 |