summaryrefslogtreecommitdiff
path: root/script/capability
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-05-15 19:16:42 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-05-15 19:16:42 +0800
commitb17a7ec335b2702dd3562ab2d3380effba08a51a (patch)
tree804485ea67d40e9b2270ba204ff0c3d54890b691 /script/capability
parentaeae9df8137820f1c64fe528b96dfbb9b1348eb5 (diff)
downloadlua-language-server-b17a7ec335b2702dd3562ab2d3380effba08a51a.zip
更新一波语义着色
Diffstat (limited to 'script/capability')
-rw-r--r--script/capability/semantic.lua28
1 files changed, 26 insertions, 2 deletions
diff --git a/script/capability/semantic.lua b/script/capability/semantic.lua
index a5c8746b..72c889e1 100644
--- a/script/capability/semantic.lua
+++ b/script/capability/semantic.lua
@@ -1,11 +1,27 @@
-local rpc = require 'rpc'
+local rpc = require 'rpc'
+local TokenTypes = require 'constant.TokenTypes'
+local TokenModifiers = require 'constant.TokenModifiers'
local isEnable = false
-local function enable()
+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 function enable(lsp)
if isEnable then
return
end
+ if not lsp.client.capabilities.textDocument.semanticTokens then
+ return
+ end
isEnable = true
log.debug('Enable semantic.')
rpc:request('client/registerCapability', {
@@ -13,6 +29,14 @@ local function enable()
{
id = 'semantic',
method = 'textDocument/semanticTokens',
+ registerOptions = {
+ legend = {
+ tokenTypes = toArray(TokenTypes),
+ tokenModifiers = toArray(TokenModifiers),
+ },
+ rangeProvider = false,
+ documentProvider = false,
+ },
},
}
})