diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-03-25 21:15:53 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-03-27 15:16:23 +0800 |
commit | f1f54501072f35997e4db848aa0b43a0e59a1d8f (patch) | |
tree | d14f30dcdd0e5a3d97354f8b717ca146ea39ccda /script/service | |
parent | 7d3cb7a0c80a52024c2545bd946f4d2a2f44c70f (diff) | |
download | lua-language-server-f1f54501072f35997e4db848aa0b43a0e59a1d8f.zip |
#462 show message of telemetry
Diffstat (limited to 'script/service')
-rw-r--r-- | script/service/telemetry.lua | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/script/service/telemetry.lua b/script/service/telemetry.lua index 9fbbfe9e..1070ba5d 100644 --- a/script/service/telemetry.lua +++ b/script/service/telemetry.lua @@ -5,6 +5,9 @@ local client = require 'provider.client' local nonil = require 'without-check-nil' local util = require 'utility' local platform = require 'bee.platform' +local proto = require 'proto.proto' +local lang = require 'language' +local define = require 'proto.define' local tokenPath = (ROOT / 'log' / 'token'):string() local token = util.loadFile(tokenPath) @@ -85,3 +88,63 @@ timer.wait(5, function () net.update() end) end) + +local m = {} + +function m.updateConfig() + if config.config.telemetry.enable ~= nil then + return + end + if m.hasShowedMessage then + return + end + m.hasShowedMessage = true + + if client.isVSCode() then + local enableTitle = lang.script.WINDOW_TELEMETRY_ENABLE + local disableTitle = lang.script.WINDOW_TELEMETRY_DISABLE + local item = proto.awaitRequest('window/showMessageRequest', { + message = lang.script.WINDOW_TELEMETRY_HINT, + type = define.MessageType.Info, + actions = { + { + title = enableTitle, + }, + { + title = disableTitle, + }, + } + }) + if not item then + return + end + if item.title == enableTitle then + proto.notify('$/command', { + command = 'lua.config', + data = { + key = 'Lua.telemetry.enable', + action = 'set', + value = true, + global = true, + } + }) + elseif item.title == disableTitle then + proto.notify('$/command', { + command = 'lua.config', + data = { + key = 'Lua.telemetry.enable', + action = 'set', + value = false, + global = true, + } + }) + end + else + proto.notify('window/showMessage', { + message = lang.script.WINDOW_TELEMETRY_HINT, + type = define.MessageType.Info, + }) + end +end + +return m |