summaryrefslogtreecommitdiff
path: root/script/method
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2020-07-22 17:22:10 +0800
committer最萌小汐 <sumneko@hotmail.com>2020-07-22 17:22:10 +0800
commit5bf4d5f892e9af225f2cdd77c2e3ea4be582705b (patch)
tree6c6a6c4972e85a2cafbe689cb5ab42b306e51789 /script/method
parent050b7262a4019a1ecafac0acdc5bd9a1b0ca0bf4 (diff)
downloadlua-language-server-5bf4d5f892e9af225f2cdd77c2e3ea4be582705b.zip
修改配置由前端完成;为了防止冲突,命令加个前缀
Diffstat (limited to 'script/method')
-rw-r--r--script/method/workspace/executeCommand.lua92
1 files changed, 2 insertions, 90 deletions
diff --git a/script/method/workspace/executeCommand.lua b/script/method/workspace/executeCommand.lua
index d5abb453..357c21c0 100644
--- a/script/method/workspace/executeCommand.lua
+++ b/script/method/workspace/executeCommand.lua
@@ -1,9 +1,5 @@
-local fs = require 'bee.filesystem'
-local json = require 'json'
-local config = require 'config'
local rpc = require 'rpc'
local lang = require 'language'
-local platform = require 'bee.platform'
local command = {}
@@ -39,91 +35,7 @@ end
--- @param lsp LSP
--- @param data table
-function command.config(lsp, data)
- local def = config.config
- for _, k in ipairs(data.key) do
- def = def[k]
- if not def then
- return
- end
- end
- if data.action == 'add' then
- if type(def) ~= 'table' then
- return
- end
- end
-
- local vscodePath
- local mode
- local ws
- if data.uri then
- ws = lsp:findWorkspaceFor(data.uri)
- end
- if ws then
- vscodePath = ws.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'
- if not fs.exists(vscodePath) then
- rpc:notify('window/showMessage', {
- type = 3,
- message = lang.script.MWS_UCONFIG_FAILED,
- })
- return
- end
- end
-
- local settingBuf = io.load(vscodePath / 'settings.json')
- if not settingBuf then
- fs.create_directories(vscodePath)
- end
-
- local setting = json.decode(settingBuf or '', true) or {}
- local key = 'Lua.' .. table.concat(data.key, '.')
- local attr = setting[key]
-
- if data.action == 'add' then
- if attr == nil then
- attr = {}
- elseif type(attr) == 'string' then
- attr = {}
- for str in attr:gmatch '[^;]+' do
- attr[#attr+1] = str
- end
- elseif type(attr) == 'table' then
- else
- return
- end
-
- attr[#attr+1] = data.value
- setting[key] = attr
- elseif data.action == 'set' then
- setting[key] = data.value
- 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
-
---- @param lsp LSP
---- @param data table
-function command.removeSpace(lsp, data)
+command['lua.removeSpace'] = function (lsp, data)
local uri = data.uri
local vm, lines = lsp:getVM(uri)
if not vm then
@@ -188,7 +100,7 @@ local literalMap = {
--- @param lsp LSP
--- @param data table
-function command.solve(lsp, data)
+command['lua.resolve'] = function (lsp, data)
local uri = data.uri
local vm, lines = lsp:getVM(uri)
if not vm then