diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/src/method/initialize.lua | 8 | ||||
-rw-r--r-- | server/src/method/initialized.lua | 26 | ||||
-rw-r--r-- | server/src/rpc.lua | 6 | ||||
-rw-r--r-- | server/src/service.lua | 5 | ||||
-rw-r--r-- | server/src/workspace.lua | 6 |
5 files changed, 43 insertions, 8 deletions
diff --git a/server/src/method/initialize.lua b/server/src/method/initialize.lua index 113acfb8..8b71e8fd 100644 --- a/server/src/method/initialize.lua +++ b/server/src/method/initialize.lua @@ -18,7 +18,13 @@ return function (lsp) openClose = true, -- 文本改变时完全通知 TODO 支持差量更新(2) change = 1, - } + }, + workspace = { + workspaceFolders = { + supported = true, + changeNotifications = true, + } + }, } } end diff --git a/server/src/method/initialized.lua b/server/src/method/initialized.lua index 716a86e7..a7e70d66 100644 --- a/server/src/method/initialized.lua +++ b/server/src/method/initialized.lua @@ -1,3 +1,27 @@ -return function () +local rpc = require 'rpc' +local workspace = require 'workspace' + +return function (lsp) + lsp.workspace = workspace() + -- 必须动态注册的事件: + rpc:request('client/registerCapability', { + registrations = { + -- 监事文件变化 + { + id = '0', + method = 'workspace/didChangeWatchedFiles', + registerOptions = { + watchers = { + { + globPattern = '**/*.lua', + kind = 1 | 2 | 4, -- Create | Delete + }, + }, + }, + }, + } + }, function () + log.debug('client/registerCapability Success!') + end) return true end diff --git a/server/src/rpc.lua b/server/src/rpc.lua index 728cf74f..99136a0a 100644 --- a/server/src/rpc.lua +++ b/server/src/rpc.lua @@ -53,11 +53,11 @@ local function recieve(self, proto) log.warn('Recieve timeout: ', table.dump(proto.error)) return end - if proto.result then - data.callback(proto.result) - else + if proto.error then log.warn('Recieve: ', table.dump(proto.error)) + return end + data.callback(proto.result) end return { diff --git a/server/src/service.lua b/server/src/service.lua index 9a53804d..03069adb 100644 --- a/server/src/service.lua +++ b/server/src/service.lua @@ -50,6 +50,7 @@ function mt:_callMethod(name, params) } end end + log.debug(name) if optional then return nil else @@ -210,10 +211,8 @@ function mt:on_tick() if proto then if proto.method then self:_doProto(proto) - elseif proto.result or proto.error then - rpc:recieve(proto) else - log.warn('Unknow proto type.') + rpc:recieve(proto) end end self:_buildTextCache() diff --git a/server/src/workspace.lua b/server/src/workspace.lua new file mode 100644 index 00000000..f167719c --- /dev/null +++ b/server/src/workspace.lua @@ -0,0 +1,6 @@ +local mt = {} +mt.__index = {} + +return function () + +end |