diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-03-13 18:26:22 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-03-13 18:26:22 +0800 |
commit | 5cb11fec575ef35576ad467910d79d1cb035532d (patch) | |
tree | 21986b72ccd68f22f92d4d7b2f076bca720b3d3c /script/method | |
parent | 96e06d04fbd44326394178fdfdeca1c4f964406e (diff) | |
download | lua-language-server-5cb11fec575ef35576ad467910d79d1cb035532d.zip |
fix #138
Diffstat (limited to 'script/method')
-rw-r--r-- | script/method/initialize.lua | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/script/method/initialize.lua b/script/method/initialize.lua index 1fb0cb5f..ef025ddf 100644 --- a/script/method/initialize.lua +++ b/script/method/initialize.lua @@ -1,4 +1,5 @@ local workspace = require 'workspace' +local nonil = require 'without-check-nil' local function allWords() local str = [[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.:('"[,#*@| ]] @@ -11,17 +12,15 @@ end return function (lsp, params) lsp._inited = true + lsp.client = params if params.rootUri then lsp.workspace = workspace(lsp, 'root') lsp.workspace:init(params.rootUri) end - return { + local server = { capabilities = { - completionProvider = { - triggerCharacters = { '.' }, - }, hoverProvider = true, definitionProvider = true, referencesProvider = true, @@ -58,4 +57,14 @@ return function (lsp, params) }, } } + + nonil.enable() + if not params.capabilities.textDocument.completion.dynamicRegistration then + server.capabilities.completionProvider = { + triggerCharacters = allWords(), + } + end + nonil.disable() + + return server end |