diff options
author | Michael Lingelbach <m.j.lbach@gmail.com> | 2021-09-26 13:53:04 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-26 22:53:04 +0200 |
commit | c217766f7c32f17598563b16ef260322ce80bfc9 (patch) | |
tree | 57145567fc326ade5aabb29f3a48f9ee2712a6c1 /runtime/lua/vim/lsp/rpc.lua | |
parent | 68c65b7732efdb637c4a0d1e2f2799932f654c59 (diff) | |
download | rneovim-c217766f7c32f17598563b16ef260322ce80bfc9.tar.gz rneovim-c217766f7c32f17598563b16ef260322ce80bfc9.tar.bz2 rneovim-c217766f7c32f17598563b16ef260322ce80bfc9.zip |
feat(lsp): use cjson for lsp rpc (#15759)
Diffstat (limited to 'runtime/lua/vim/lsp/rpc.lua')
-rw-r--r-- | runtime/lua/vim/lsp/rpc.lua | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/runtime/lua/vim/lsp/rpc.lua b/runtime/lua/vim/lsp/rpc.lua index 7f31bbdf75..716f42faf9 100644 --- a/runtime/lua/vim/lsp/rpc.lua +++ b/runtime/lua/vim/lsp/rpc.lua @@ -11,7 +11,7 @@ local validate, schedule, schedule_wrap = vim.validate, vim.schedule, vim.schedu ---@param data (table) Data to encode ---@returns (string) Encoded object local function json_encode(data) - local status, result = pcall(vim.fn.json_encode, data) + local status, result = pcall(vim.json.encode, data) if status then return result else @@ -24,7 +24,7 @@ end ---@param data (string) Data to decode ---@returns (table) Decoded JSON object local function json_decode(data) - local status, result = pcall(vim.fn.json_decode, data) + local status, result = pcall(vim.json.decode, data) if status then return result else @@ -394,11 +394,8 @@ local function start(cmd, cmd_args, dispatchers, extra_spawn_params) local function encode_and_send(payload) local _ = log.debug() and log.debug("rpc.send", payload) if handle == nil or handle:is_closing() then return false end - -- TODO(ashkan) remove this once we have a Lua json_encode - schedule(function() - local encoded = assert(json_encode(payload)) - stdin:write(format_message_with_content_length(encoded)) - end) + local encoded = assert(json_encode(payload)) + stdin:write(format_message_with_content_length(encoded)) return true end @@ -582,8 +579,6 @@ local function start(cmd, cmd_args, dispatchers, extra_spawn_params) on_error(client_errors.INVALID_SERVER_MESSAGE, decoded) end end - -- TODO(ashkan) remove this once we have a Lua json_decode - handle_body = schedule_wrap(handle_body) local request_parser = coroutine.wrap(request_parser_loop) request_parser() |