diff options
author | Arcanox <arcanox@arcanox.me> | 2021-09-25 21:05:08 -0500 |
---|---|---|
committer | Arcanox <arcanox@arcanox.me> | 2021-09-25 21:05:08 -0500 |
commit | cb60b363f68a966e033a3dcaad95a142e62749b4 (patch) | |
tree | ce5f2ef1f0e207c8b6aff17e171aec2ca9eb6304 /script/core/semantic-tokens.lua | |
parent | 4fb25e5b8da07239e19036e72ef67c11b4509905 (diff) | |
download | lua-language-server-cb60b363f68a966e033a3dcaad95a142e62749b4.zip |
Fix global library functions being highlighted as a global type instead of a function
Diffstat (limited to 'script/core/semantic-tokens.lua')
-rw-r--r-- | script/core/semantic-tokens.lua | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/script/core/semantic-tokens.lua b/script/core/semantic-tokens.lua index 7a2c6194..9f51c500 100644 --- a/script/core/semantic-tokens.lua +++ b/script/core/semantic-tokens.lua @@ -14,8 +14,18 @@ local isEnhanced = config.get 'Lua.color.mode' == 'SemanticEnhanced' local Care = {} Care['getglobal'] = function (source, results) local isLib = vm.isGlobalLibraryName(source[1]) - local isFunc = (source.value and source.value.type == 'function') or - (source.next and source.next.type == 'call') + local isFunc = false + local value = source.value + local next = source.next + + if value and value.type == 'function' then + isFunc = true + elseif next and next.type == 'call' then + isFunc = true + elseif isEnhanced then + isFunc = infer.hasType(source, 'function') + end + local type = isFunc and define.TokenTypes['function'] or define.TokenTypes.variable local modifier = isLib and define.TokenModifiers.defaultLibrary or define.TokenModifiers.static @@ -44,7 +54,7 @@ Care['getfield'] = function (source, results) if not field then return end - if isEnhanced and infer.hasType(source.field, 'function') then + if isEnhanced and infer.hasType(field, 'function') then results[#results+1] = { start = field.start, finish = field.finish, @@ -52,7 +62,7 @@ Care['getfield'] = function (source, results) } return end - if source.dot and (not source.next or source.next.type ~= "call") then + if source.dot and not (source.next and source.next.type ~= "call") then results[#results+1] = { start = field.start, finish = field.finish, |