aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Fischer <florian.fl.fischer@fau.de>2021-03-20 11:43:04 +0100
committerFlorian Fischer <florian.fl.fischer@fau.de>2021-03-20 11:43:04 +0100
commite6afa5938e56dd15fa89c1ede5822a385d01b1c4 (patch)
treefb8f9a396fcb3bed5b13107cab633f08a1c9d1c1
parent505d1cdaea5fa6bdfd654ddd34bdfa85aa0ddb5d (diff)
downloadvis-lspc-e6afa5938e56dd15fa89c1ede5822a385d01b1c4.tar.gz
vis-lspc-e6afa5938e56dd15fa89c1ede5822a385d01b1c4.zip
responde to method calls with MethodNotFound Error
-rw-r--r--init.lua27
1 files changed, 26 insertions, 1 deletions
diff --git a/init.lua b/init.lua
index 944fc94..a685b3d 100644
--- a/init.lua
+++ b/init.lua
@@ -32,6 +32,23 @@ else
json = load_fallback_json()
end
+local jsonrpc = {}
+jsonrpc.error_codes = {
+ -- json rpc errors
+ ParseError = -32700,
+ InvalidRequest = -32600,
+ MethodNotFound = -32601,
+ InvalidParams = -32602,
+ InternalError = -32603,
+
+ ServerNotInitialized = -32002,
+ UnknownErrorCode = -32001,
+
+ -- lsp errors
+ ContentModified = -32801,
+ RequestCancelled = -32800,
+}
+
-- get vis's pid to pass it to the language servers
local vis_pid
do
@@ -528,7 +545,15 @@ local function ls_handle_method_response(ls, method_response, req)
ls.inflight[method_response.id] = nil
end
-local function ls_handle_method_call(ls, notification) -- luacheck: no unused args
+local function ls_handle_method_call(ls, method_call)
+ local method = method_call.method
+ lspc.log('Unknown method call ' .. method)
+ local response = {id = method_call.id}
+ response['error'] = {
+ code = jsonrpc.error_codes.MethodNotFound,
+ message = method .. ' not implemented',
+ }
+ ls_rpc(ls, response)
end
local function ls_handle_notification(ls, notification) -- luacheck: no unused args