diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2020-05-16 11:40:11 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2020-05-16 11:40:11 +0800 |
commit | 915813465a67d07a354d08a39b45f7bb5ea47c44 (patch) | |
tree | 457d08eae9de4851dfca4c71324a1fd9e011591b /script | |
parent | b17a7ec335b2702dd3562ab2d3380effba08a51a (diff) | |
download | lua-language-server-915813465a67d07a354d08a39b45f7bb5ea47c44.zip |
更新颜色
Diffstat (limited to 'script')
-rw-r--r-- | script/config.lua | 2 | ||||
-rw-r--r-- | script/method/textDocument/semanticTokens.lua | 60 | ||||
-rw-r--r-- | script/vm/vm.lua | 1 |
3 files changed, 38 insertions, 25 deletions
diff --git a/script/config.lua b/script/config.lua index b7588fb5..baca3e63 100644 --- a/script/config.lua +++ b/script/config.lua @@ -125,7 +125,7 @@ local ConfigTemplate = { keywordSnippet = {'Both', String}, }, color = { - mode = {'Grammar', String}, + mode = {'Semantic', String}, }, plugin = { enable = {false, Boolean}, diff --git a/script/method/textDocument/semanticTokens.lua b/script/method/textDocument/semanticTokens.lua index 6595459e..de50b43b 100644 --- a/script/method/textDocument/semanticTokens.lua +++ b/script/method/textDocument/semanticTokens.lua @@ -23,36 +23,48 @@ local constLib = { ['package.searchers'] = true } -local function buildLibToken(source, lib) - local modifieres - if constLib[lib.doc] then - modifieres = TokenModifiers.readonly - else - modifieres = TokenModifiers.static - end - return { - start = source.start, - finish = source.finish, - type = TokenTypes.namespace, - modifieres = modifieres, - } -end - local Care = { - ['name'] = function (source) - local lib = findLib(source) - if lib then - return buildLibToken(source, lib) - end + ['name'] = function (source, sources) if source:get 'global' then - return { + if findLib(source) then + if source[1] == '_G' then + return + end + sources[#sources+1] = { + start = source.start, + finish = source.finish, + type = TokenTypes.namespace, + modifieres = TokenModifiers.static, + } + return + end + sources[#sources+1] = { start = source.start, finish = source.finish, type = TokenTypes.namespace, modifieres = TokenModifiers.deprecated, } - else - return { + elseif source:get 'table index' then + sources[#sources+1] = { + start = source.start, + finish = source.finish, + type = TokenTypes.property, + modifieres = TokenModifiers.declaration, + } + elseif source:bindLocal() then + if source:get 'arg' then + sources[#sources+1] = { + start = source.start, + finish = source.finish, + type = TokenTypes.parameter, + modifieres = TokenModifiers.declaration, + } + end + if source[1] == '_ENV' + or source[1] == 'self' then + return + end + sources[#sources+1] = { start = source.start, finish = source.finish, type = TokenTypes.variable, @@ -92,7 +104,7 @@ local function resolveTokens(vm, lines) local sources = {} for _, source in ipairs(vm.sources) do if Care[source.type] then - sources[#sources+1] = Care[source.type](source) + Care[source.type](source, sources) end end diff --git a/script/vm/vm.lua b/script/vm/vm.lua index 36ad78c9..bc4f13e3 100644 --- a/script/vm/vm.lua +++ b/script/vm/vm.lua @@ -108,6 +108,7 @@ function mt:runFunction(func) for _, arg in ipairs(func.args) do if arg:getSource() ~= func:getObject() then self:bindLocal(arg:getSource(), arg, 'local') + arg:getSource():set('arg', true) end end |