diff options
Diffstat (limited to 'script')
-rw-r--r-- | script/config.lua | 3 | ||||
-rw-r--r-- | script/provider/provider.lua | 7 | ||||
-rw-r--r-- | script/provider/semantic-tokens.lua | 33 |
3 files changed, 41 insertions, 2 deletions
diff --git a/script/config.lua b/script/config.lua index cd9b5d33..1711052f 100644 --- a/script/config.lua +++ b/script/config.lua @@ -168,7 +168,8 @@ local ConfigTemplate = { local OtherTemplate = { associations = {{}, Hash(String, String)}, - exclude = {{}, Hash(String, Boolean)}, + exclude = {{}, Hash(String, Boolean)}, + semantic = {'', Or(Boolean, String)}, } local function init() diff --git a/script/provider/provider.lua b/script/provider/provider.lua index 40990906..9074b034 100644 --- a/script/provider/provider.lua +++ b/script/provider/provider.lua @@ -34,7 +34,11 @@ local function updateConfig() { scopeUri = workspace.uri, section = 'files.exclude', - } + }, + { + scopeUri = workspace.uri, + section = 'editor.semanticHighlighting.enabled', + }, }, }) if not configs or not configs[1] then @@ -46,6 +50,7 @@ local function updateConfig() local other = { associations = configs[2], exclude = configs[3], + semantic = configs[4], } local oldConfig = util.deepCopy(config.config) diff --git a/script/provider/semantic-tokens.lua b/script/provider/semantic-tokens.lua index e4b2fc6f..76fede85 100644 --- a/script/provider/semantic-tokens.lua +++ b/script/provider/semantic-tokens.lua @@ -2,6 +2,8 @@ local proto = require 'proto' local define = require 'proto.define' local client = require 'provider.client' local json = require "json" +local config = require 'config' +local lang = require 'language' local isEnable = false @@ -16,6 +18,7 @@ local function toArray(map) return array end +local dontShowAgain = false local function enable() if isEnable then return @@ -41,6 +44,36 @@ local function enable() }, } }) + if config.other.semantic ~= true and not dontShowAgain then + local item = proto.awaitRequest('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, + }, + } + }) + if item then + if item.title == lang.script.WINDOW_APPLY_SETTING then + proto.notify('$/command', { + command = 'lua.config', + data = { + key = 'editor.semanticHighlighting.enabled', + action = 'set', + value = true, + global = true, + } + }) + end + if item.title == lang.script.WINDOW_DONT_SHOW_AGAIN then + dontShowAgain = true + end + end + end end local function disable() |