summaryrefslogtreecommitdiff
path: root/server/src/method/workspace
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-09-05 15:02:13 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-09-05 15:02:13 +0800
commit44a2f2d83de1b972522802534fbb376d7da2eb91 (patch)
tree74a5bb29664f62cd953a74a5ac8925bd1a421175 /server/src/method/workspace
parentf3768e21a732683c181ec17401d7ba63f68b3635 (diff)
downloadlua-language-server-44a2f2d83de1b972522802534fbb376d7da2eb91.zip
fixed #80 没有工作区时更新用户配置
Diffstat (limited to 'server/src/method/workspace')
-rw-r--r--server/src/method/workspace/executeCommand.lua36
1 files changed, 35 insertions, 1 deletions
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)