summaryrefslogtreecommitdiff
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/locale/en-US/script.lni3
-rw-r--r--server/locale/zh-CN/script.lni3
-rw-r--r--server/src/method/workspace/executeCommand.lua36
3 files changed, 41 insertions, 1 deletions
diff --git a/server/locale/en-US/script.lni b/server/locale/en-US/script.lni
index 26d4b16f..e7f67a09 100644
--- a/server/locale/en-US/script.lni
+++ b/server/locale/en-US/script.lni
@@ -35,6 +35,9 @@ MWS_RESTART = 'Restart'
MWS_NOT_COMPLETE = 'Workspace is not complete yet. You may try again later...'
MWS_COMPLETE = 'Workspace is complete now. You may try again...'
MWS_MAX_PRELOAD = 'Preloaded files has reached the upper limit ({}), you need to manually open the files that need to be loaded.'
+MWS_UCONFIG_FAILED = 'Saving user setting failed.'
+MWS_UCONFIG_UPDATED = 'User setting updated.'
+MWS_WCONFIG_UPDATED = 'Workspace setting updated.'
PARSER_CRASH = 'Parser crashed! Last words:{}'
PARSER_UNKNOWN = 'Unknown syntax error...'
diff --git a/server/locale/zh-CN/script.lni b/server/locale/zh-CN/script.lni
index 20a45855..51fc6826 100644
--- a/server/locale/zh-CN/script.lni
+++ b/server/locale/zh-CN/script.lni
@@ -35,6 +35,9 @@ MWS_RESTART = '重启'
MWS_NOT_COMPLETE = '工作目录还没有准备好,你可以稍后再试一下...'
MWS_COMPLETE = '工作目录准备好了,你可以再试一下了...'
MWS_MAX_PRELOAD = '预加载文件数已达上限({}),你需要手动打开需要加载的文件。'
+MWS_UCONFIG_FAILED = '用户配置保存失败。'
+MWS_UCONFIG_UPDATED = '用户配置已更新。'
+MWS_WCONFIG_UPDATED = '工作区配置已更新。'
PARSER_CRASH = '语法解析崩溃了!遗言:{}'
PARSER_UNKNOWN = '未知语法错误...'
diff --git a/server/src/method/workspace/executeCommand.lua b/server/src/method/workspace/executeCommand.lua
index b622ec11..1204fe60 100644
--- a/server/src/method/workspace/executeCommand.lua
+++ b/server/src/method/workspace/executeCommand.lua
@@ -3,6 +3,7 @@ local json = require 'json'
local config = require 'config'
local rpc = require 'rpc'
local lang = require 'language'
+local platform = require 'bee.platform'
local command = {}
@@ -50,7 +51,28 @@ function command.config(lsp, data)
end
end
- local vscodePath = lsp.workspace.root / '.vscode'
+ local vscodePath
+ local mode
+ if lsp.workspace then
+ vscodePath = lsp.workspace.root / '.vscode'
+ mode = 'workspace'
+ else
+ if platform.OS == 'Windows' then
+ vscodePath = fs.path(os.getenv 'USERPROFILE') / 'AppData' / 'Roaming' / 'Code' / 'User'
+ else
+ vscodePath = fs.path(os.getenv 'HOME') / '.vscode-server' / 'data' / 'Machine'
+ end
+ mode = 'user'
+ end
+
+ if not fs.exists(vscodePath) then
+ rpc:notify('window/showMessage', {
+ type = 3,
+ message = lang.script.MWS_UCONFIG_FAILED,
+ })
+ return
+ end
+
local settingBuf = io.load(vscodePath / 'settings.json')
if not settingBuf then
fs.create_directories(vscodePath)
@@ -80,6 +102,18 @@ function command.config(lsp, data)
end
io.save(vscodePath / 'settings.json', json.encode(setting) .. '\r\n')
+
+ if mode == 'workspace' then
+ rpc:notify('window/showMessage', {
+ type = 3,
+ message = lang.script.MWS_WCONFIG_UPDATED,
+ })
+ elseif mode == 'user' then
+ rpc:notify('window/showMessage', {
+ type = 3,
+ message = lang.script.MWS_UCONFIG_UPDATED,
+ })
+ end
end
function command.removeSpace(lsp, data)