diff options
Diffstat (limited to 'server/src/capability')
-rw-r--r-- | server/src/capability/completion.lua | 53 | ||||
-rw-r--r-- | server/src/capability/init.lua | 3 |
2 files changed, 56 insertions, 0 deletions
diff --git a/server/src/capability/completion.lua b/server/src/capability/completion.lua new file mode 100644 index 00000000..28a6036c --- /dev/null +++ b/server/src/capability/completion.lua @@ -0,0 +1,53 @@ +local rpc = require 'rpc' + +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.') + rpc:request('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.') + rpc:request('client/unregisterCapability', { + unregisterations = { + { + id = 'completion', + method = 'textDocument/completion', + }, + } + }) +end + +return { + enable = enable, + disable = disable, +} diff --git a/server/src/capability/init.lua b/server/src/capability/init.lua new file mode 100644 index 00000000..09eb6a09 --- /dev/null +++ b/server/src/capability/init.lua @@ -0,0 +1,3 @@ +return { + completion = require 'capability.completion', +} |