diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2019-11-08 14:05:55 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2019-11-08 14:05:55 +0800 |
commit | 0a2df61286035af2bd506605547f6a5d5024c691 (patch) | |
tree | 0d77de700d936403aec32c0eea37237448f04b3a /server-beta/src/provider/completion.lua | |
parent | f53b68d739ab7aad9c6aae2b902f34fbb8fc97ea (diff) | |
download | lua-language-server-0a2df61286035af2bd506605547f6a5d5024c691.zip |
修正诊断策略
Diffstat (limited to 'server-beta/src/provider/completion.lua')
-rw-r--r-- | server-beta/src/provider/completion.lua | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/server-beta/src/provider/completion.lua b/server-beta/src/provider/completion.lua new file mode 100644 index 00000000..d2df44d2 --- /dev/null +++ b/server-beta/src/provider/completion.lua @@ -0,0 +1,53 @@ +local proto = require 'proto' + +local isEnable = false + +local function allWords() + local str = [[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.:('"[,#*@| ]] + local list = {} + for c in str:gmatch '.' do + list[#list+1] = c + end + return list +end + +local function enable() + if isEnable then + return + end + isEnable = true + log.debug('Enable completion.') + proto.awaitRequest('client/registerCapability', { + registrations = { + { + id = 'completion', + method = 'textDocument/completion', + registerOptions = { + resolveProvider = false, + triggerCharacters = allWords(), + }, + }, + } + }) +end + +local function disable() + if not isEnable then + return + end + isEnable = false + log.debug('Disable completion.') + proto.awaitRequest('client/unregisterCapability', { + unregisterations = { + { + id = 'completion', + method = 'textDocument/completion', + }, + } + }) +end + +return { + enable = enable, + disable = disable, +} |