summaryrefslogtreecommitdiff
path: root/script/capability
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-03-13 18:26:22 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-03-13 18:26:22 +0800
commit5cb11fec575ef35576ad467910d79d1cb035532d (patch)
tree21986b72ccd68f22f92d4d7b2f076bca720b3d3c /script/capability
parent96e06d04fbd44326394178fdfdeca1c4f964406e (diff)
downloadlua-language-server-5cb11fec575ef35576ad467910d79d1cb035532d.zip
fix #138
Diffstat (limited to 'script/capability')
-rw-r--r--script/capability/completion.lua19
1 files changed, 17 insertions, 2 deletions
diff --git a/script/capability/completion.lua b/script/capability/completion.lua
index 28a6036c..e3fb2e98 100644
--- a/script/capability/completion.lua
+++ b/script/capability/completion.lua
@@ -1,4 +1,5 @@
local rpc = require 'rpc'
+local nonil = require 'without-check-nil'
local isEnable = false
@@ -11,10 +12,17 @@ local function allWords()
return list
end
-local function enable()
+local function enable(lsp)
if isEnable then
return
end
+
+ nonil.enable()
+ if not lsp.client.capabilities.textDocument.completion.dynamicRegistration then
+ return
+ end
+ nonil.disable()
+
isEnable = true
log.debug('Enable completion.')
rpc:request('client/registerCapability', {
@@ -31,10 +39,17 @@ local function enable()
})
end
-local function disable()
+local function disable(lsp)
if not isEnable then
return
end
+
+ nonil.enable()
+ if not lsp.client.capabilities.textDocument.completion.dynamicRegistration then
+ return
+ end
+ nonil.disable()
+
isEnable = false
log.debug('Disable completion.')
rpc:request('client/unregisterCapability', {