diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-01-29 14:50:06 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-01-29 14:50:06 +0800 |
commit | 4556d55e6e944f122db9cbb8c4d126d43dc8710d (patch) | |
tree | a04e44c0d22e28ac91d7c742c4d33bc4db27e115 | |
parent | 84f00693304a934ffbd86aa48d35245d6277ea68 (diff) | |
download | lua-language-server-4556d55e6e944f122db9cbb8c4d126d43dc8710d.zip |
help makes semantic tokens effect
-rw-r--r-- | locale/en-us/script.lua | 2 | ||||
-rw-r--r-- | locale/zh-cn/script.lua | 4 | ||||
-rw-r--r-- | script/config.lua | 3 | ||||
-rw-r--r-- | script/provider/provider.lua | 7 | ||||
-rw-r--r-- | script/provider/semantic-tokens.lua | 33 |
5 files changed, 46 insertions, 3 deletions
diff --git a/locale/en-us/script.lua b/locale/en-us/script.lua index 9b129290..07cc15be 100644 --- a/locale/en-us/script.lua +++ b/locale/en-us/script.lua @@ -210,3 +210,5 @@ WINDOW_LUA_STATUS = [[ Cached files: {ast}/{max} Memory usage: {mem:.f}M ]] +WINDOW_APPLY_SETTING = 'Apply setting' +WINDOW_CHECK_SEMANTIC = 'If you are using the color theme in the market, you may need to modify `editor.semanticHighlighting.enabled` to `true` to make semantic tokens take effect.' diff --git a/locale/zh-cn/script.lua b/locale/zh-cn/script.lua index ebfead0c..57b84cde 100644 --- a/locale/zh-cn/script.lua +++ b/locale/zh-cn/script.lua @@ -202,10 +202,12 @@ WINDOW_PROCESSING_SEMANTIC_RANGE = '正在处理差量语义着色...' WINDOW_INCREASE_UPPER_LIMIT = '增加上限' WINDOW_CLOSE = '关闭' WINDOW_SETTING_WS_DIAGNOSTIC = '你可以在设置中延迟或禁用工作目录诊断' -WINDOW_DONT_SHOW_AGAIN = '不再提醒' +WINDOW_DONT_SHOW_AGAIN = '不再提示' WINDOW_DELAY_WS_DIAGNOSTIC = '空闲时诊断(延迟{}秒)' WINDOW_DISABLE_DIAGNOSTIC = '禁用工作区诊断' WINDOW_LUA_STATUS = [[ 已缓存文件:{ast}/{max} 内存占用:{mem:.f}M ]] +WINDOW_APPLY_SETTING = '应用设置' +WINDOW_CHECK_SEMANTIC = '如果你正在使用市场中的颜色主题,你可能需要同时修改 `editor.semanticHighlighting.enabled` 选项为 `true` 才会使语义着色生效。' 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() |