diff options
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/rpc.lua | 24 | ||||
-rw-r--r-- | server/src/service.lua | 11 |
2 files changed, 20 insertions, 15 deletions
diff --git a/server/src/rpc.lua b/server/src/rpc.lua index 559853e0..728cf74f 100644 --- a/server/src/rpc.lua +++ b/server/src/rpc.lua @@ -5,18 +5,26 @@ local TIMEOUT = 1.0 local ID = 0 local BUF = {} -local function notify(self, data) - data.jsonrpc = '2.0' - local content = json.encode(data) +local function notify(self, method, params) + local pack = { + jsonrpc = '2.0', + method = method, + params = params, + } + local content = json.encode(pack) local buf = ('Content-Length: %d\r\n\r\n%s'):format(#content, content) io.write(buf) end -local function request(self, data, callback) +local function request(self, method, params, callback) ID = ID + 1 - data.jsonrpc = '2.0' - data.id = ID - local content = json.encode(data) + local pack = { + jsonrpc = '2.0', + id = ID, + method = method, + params = params, + } + local content = json.encode(pack) local buf = ('Content-Length: %d\r\n\r\n%s'):format(#content, content) BUF[ID] = { callback = callback, @@ -36,8 +44,8 @@ end local function recieve(self, proto) local id = proto.id local data = BUF[id] - log.warn('Recieve id not found: ', table.dump(proto)) if not data then + log.warn('Recieve id not found: ', table.dump(proto)) return end BUF[id] = nil diff --git a/server/src/service.lua b/server/src/service.lua index fd748a96..9a53804d 100644 --- a/server/src/service.lua +++ b/server/src/service.lua @@ -93,13 +93,10 @@ function mt:_doDiagnostic() local name = 'textDocument/publishDiagnostics' local res = self:_callMethod(name, data) if res then - rpc:notify { - method = name, - params = { - uri = uri, - diagnostics = res, - }, - } + rpc:notify(name, { + uri = uri, + diagnostics = res, + }) end end local passed = os.clock() - clock |