summaryrefslogtreecommitdiff
path: root/script/core
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-01-11 15:44:48 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-01-11 15:44:48 +0800
commit85a9019faccdf44fafec36fa816bbc4a78b58286 (patch)
tree409140cf0ee00b06da763c2c69f9349872fe626d /script/core
parent72954de6b303866cbdbab25c0f4e8c00b9dfbe2b (diff)
downloadlua-language-server-85a9019faccdf44fafec36fa816bbc4a78b58286.zip
update semantic tokens
Diffstat (limited to 'script/core')
-rw-r--r--script/core/semantic-tokens.lua136
1 files changed, 122 insertions, 14 deletions
diff --git a/script/core/semantic-tokens.lua b/script/core/semantic-tokens.lua
index 96a1a56c..ca6471a7 100644
--- a/script/core/semantic-tokens.lua
+++ b/script/core/semantic-tokens.lua
@@ -373,32 +373,125 @@ local Care = util.switch()
type = define.TokenTypes.number,
}
end)
- : case 'doc.return.name'
+ : case 'doc.class.name'
: call(function (source, options, results)
results[#results+1] = {
- start = source.start,
- finish = source.finish,
- type = define.TokenTypes.parameter,
+ start = source.start,
+ finish = source.finish,
+ type = define.TokenTypes.class,
+ modifieres = define.TokenModifiers.declaration,
}
end)
- : case 'doc.tailcomment'
+ : case 'doc.extends.name'
: call(function (source, options, results)
results[#results+1] = {
- start = source.start,
- finish = source.finish,
- type = define.TokenTypes.comment,
+ start = source.start,
+ finish = source.finish,
+ type = define.TokenTypes.class,
}
end)
: case 'doc.type.name'
: call(function (source, options, results)
if source.typeGeneric then
results[#results+1] = {
+ start = source.start,
+ finish = source.finish,
+ type = define.TokenTypes.type,
+ modifieres = define.TokenModifiers.modification,
+ }
+ else
+ results[#results+1] = {
start = source.start,
finish = source.finish,
- type = define.TokenTypes.macro,
+ type = define.TokenTypes.type,
+ }
+ end
+ end)
+ : case 'doc.alias.name'
+ : call(function (source, options, results)
+ results[#results+1] = {
+ start = source.start,
+ finish = source.finish,
+ type = define.TokenTypes.macro,
+ }
+ end)
+ : case 'doc.param.name'
+ : call(function (source, options, results)
+ results[#results+1] = {
+ start = source.start,
+ finish = source.finish,
+ type = define.TokenTypes.parameter,
+ }
+ end)
+ : case 'doc.field'
+ : call(function (source, options, results)
+ if source.visible then
+ results[#results+1] = {
+ start = source.start,
+ finish = source.start + #source.visible,
+ type = define.TokenTypes.keyword,
}
end
end)
+ : case 'doc.field.name'
+ : call(function (source, options, results)
+ results[#results+1] = {
+ start = source.start,
+ finish = source.finish,
+ type = define.TokenTypes.property,
+ modifieres = define.TokenModifiers.declaration,
+ }
+ end)
+ : case 'doc.return.name'
+ : call(function (source, options, results)
+ results[#results+1] = {
+ start = source.start,
+ finish = source.finish,
+ type = define.TokenTypes.parameter,
+ }
+ end)
+ : case 'doc.generic.name'
+ : call(function (source, options, results)
+ results[#results+1] = {
+ start = source.start,
+ finish = source.finish,
+ type = define.TokenTypes.type,
+ modifieres = define.TokenModifiers.modification,
+ }
+ end)
+ : case 'doc.type.function'
+ : call(function (source, options, results)
+ results[#results+1] = {
+ start = source.start,
+ finish = source.start + #'fun',
+ type = define.TokenTypes.keyword,
+ }
+ if source.async then
+ results[#results+1] = {
+ start = source.asyncPos,
+ finish = source.asyncPos + #'async',
+ type = define.TokenTypes.keyword,
+ modifieres = define.TokenModifiers.async,
+ }
+ end
+ end)
+ : case 'doc.type.arg.name'
+ : call(function (source, options, results)
+ results[#results+1] = {
+ start = source.start,
+ finish = source.finish,
+ type = define.TokenTypes.parameter,
+ modifieres = define.TokenModifiers.declaration,
+ }
+ end)
+ : case 'doc.tailcomment'
+ : call(function (source, options, results)
+ results[#results+1] = {
+ start = source.start,
+ finish = source.finish,
+ type = define.TokenTypes.comment,
+ }
+ end)
: case 'nonstandardSymbol.comment'
: call(function (source, options, results)
results[#results+1] = {
@@ -559,11 +652,26 @@ return function (uri, start, finish)
end)
for _, comm in ipairs(state.comms) do
- results[#results+1] = {
- start = comm.start,
- finish = comm.finish,
- type = define.TokenTypes.comment,
- }
+ if comm.type == 'comment.short'
+ and comm.text:sub(1, 2) == '-@' then
+ results[#results+1] = {
+ start = comm.start,
+ finish = comm.start + 3,
+ type = define.TokenTypes.comment,
+ }
+ results[#results+1] = {
+ start = comm.start + 3,
+ finish = comm.start + 2 + #comm.text:match '%S+',
+ type = define.TokenTypes.comment,
+ modifieres = define.TokenModifiers.documentation,
+ }
+ else
+ results[#results+1] = {
+ start = comm.start,
+ finish = comm.finish,
+ type = define.TokenTypes.comment,
+ }
+ end
end
if #results == 0 then