diff options
Diffstat (limited to 'script/provider')
-rw-r--r-- | script/provider/provider.lua | 20 | ||||
-rw-r--r-- | script/provider/semantic-tokens.lua | 12 |
2 files changed, 12 insertions, 20 deletions
diff --git a/script/provider/provider.lua b/script/provider/provider.lua index 070652ef..05202c01 100644 --- a/script/provider/provider.lua +++ b/script/provider/provider.lua @@ -688,15 +688,11 @@ proto.on('textDocument/semanticTokens/full', function (params) workspace.awaitReady() local _ <close> = progress.create(lang.script.WINDOW_PROCESSING_SEMANTIC_FULL, 0.5) local core = require 'core.semantic-tokens' - local text = files.getText(uri) - if not text then - return nil - end - local results = core(uri, 0, #text) + local results = core(uri, 0, math.huge) return { data = results } -end) +end, true) proto.on('textDocument/semanticTokens/range', function (params) local uri = params.textDocument.uri @@ -706,20 +702,12 @@ proto.on('textDocument/semanticTokens/range', function (params) workspace.awaitReady() local _ <close> = progress.create(lang.script.WINDOW_PROCESSING_SEMANTIC_RANGE, 0.5) local core = require 'core.semantic-tokens' - local cache = files.getOpenedCache(uri) - local start, finish - if cache and not cache['firstSemantic'] then - cache['firstSemantic'] = true - start = 0 - finish = #files.getText(uri) - else - start, finish = converter.unpackRange(uri, params.range) - end + local start, finish = converter.unpackRange(uri, params.range) local results = core(uri, start, finish) return { data = results } -end) +end, true) proto.on('textDocument/foldingRange', function (params) local core = require 'core.folding' diff --git a/script/provider/semantic-tokens.lua b/script/provider/semantic-tokens.lua index 448bbe2a..023c9e7e 100644 --- a/script/provider/semantic-tokens.lua +++ b/script/provider/semantic-tokens.lua @@ -42,7 +42,7 @@ local function enable() tokenModifiers = toArray(define.TokenModifiers), }, range = true, - full = false, + full = true, }, }, } @@ -106,10 +106,14 @@ local function refresh() proto.request('workspace/semanticTokens/refresh', json.null) end -config.watch(function (key, value) +config.watch(function (key, value, oldValue) if key == 'Lua.color.mode' then - if value == 'Semantic' then - enable() + if value == 'Semantic' or value == 'SemanticEnhanced' then + if isEnable and value ~= oldValue then + refresh() + else + enable() + end else disable() end |