1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
local proto = require 'proto'
local define = require 'proto.define'
local client = require 'client'
local json = require "json"
local config = require 'config'
local lang = require 'language'
local nonil = require 'without-check-nil'
local dontShowAgain = false
local function check(uri)
if dontShowAgain then
return
end
dontShowAgain = true
nonil.disable()
if config.get(uri, 'editor.semanticHighlighting.enabled') == 'configuredByTheme' then
proto.request('window/showMessageRequest', {
type = define.MessageType.Info,
message = lang.script.WINDOW_CHECK_SEMANTIC,
actions = {
{
title = lang.script.WINDOW_APPLY_SETTING,
},
{
title = lang.script.WINDOW_DONT_SHOW_AGAIN,
},
}
}, function (item)
if not item then
return
end
if item.title == lang.script.WINDOW_APPLY_SETTING then
client.setConfig {
{
key = 'editor.semanticHighlighting.enabled',
action = 'set',
value = true,
global = true,
}
}
end
end)
end
end
local function refresh()
if not client.isReady() then
return
end
log.debug('Refresh semantic tokens.')
proto.request('workspace/semanticTokens/refresh', json.null)
check()
end
config.watch(function (uri, key, value, oldValue)
if key == '' then
refresh()
end
if key == 'Lua.color.mode' then
refresh()
end
if key:find '^Lua.runtime'
or key:find '^Lua.workspace'
or key:find '^files' then
refresh()
end
end)
return {}
|