aboutsummaryrefslogtreecommitdiff
path: root/test/functional/plugin/lsp_spec.lua
diff options
context:
space:
mode:
authorMathias Fußenegger <mfussenegger@users.noreply.github.com>2022-04-30 22:13:26 +0200
committerGitHub <noreply@github.com>2022-04-30 22:13:26 +0200
commit0344736aa698dc205f8f9f80609b7033308d39ca (patch)
tree099aa0fef01b37012de459129bffce46d32ecfed /test/functional/plugin/lsp_spec.lua
parentcc27540560672c1586e17a9e39512074e770b005 (diff)
downloadrneovim-0344736aa698dc205f8f9f80609b7033308d39ca.tar.gz
rneovim-0344736aa698dc205f8f9f80609b7033308d39ca.tar.bz2
rneovim-0344736aa698dc205f8f9f80609b7033308d39ca.zip
fix(lsp): handle textDocumentSync.save bool capability (#18332)
Follow up to https://github.com/neovim/neovim/pull/17814
Diffstat (limited to 'test/functional/plugin/lsp_spec.lua')
-rw-r--r--test/functional/plugin/lsp_spec.lua61
1 files changed, 61 insertions, 0 deletions
diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua
index be717cf724..3ee293db66 100644
--- a/test/functional/plugin/lsp_spec.lua
+++ b/test/functional/plugin/lsp_spec.lua
@@ -421,6 +421,67 @@ describe('LSP', function()
}
end)
+ it('_text_document_did_save_handler sends didSave with bool textDocumentSync.save', function()
+ local expected_handlers = {
+ {NIL, {}, {method="shutdown", client_id=1}};
+ {NIL, {}, {method="start", client_id=1}};
+ }
+ local client
+ test_rpc_server {
+ test_name = "text_document_sync_save_bool";
+ on_init = function(c)
+ client = c
+ end;
+ on_exit = function(code, signal)
+ eq(0, code, "exit code", fake_lsp_logfile)
+ eq(0, signal, "exit signal", fake_lsp_logfile)
+ end;
+ on_handler = function(err, result, ctx)
+ eq(table.remove(expected_handlers), {err, result, ctx}, "expected handler")
+ if ctx.method == "start" then
+ exec_lua([=[
+ BUFFER = vim.api.nvim_get_current_buf()
+ lsp.buf_attach_client(BUFFER, TEST_RPC_CLIENT_ID)
+ lsp._text_document_did_save_handler(BUFFER)
+ ]=])
+ else
+ client.stop()
+ end
+ end;
+ }
+ end)
+
+ it('_text_document_did_save_handler sends didSave including text if server capability is set', function()
+ local expected_handlers = {
+ {NIL, {}, {method="shutdown", client_id=1}};
+ {NIL, {}, {method="start", client_id=1}};
+ }
+ local client
+ test_rpc_server {
+ test_name = "text_document_sync_save_includeText";
+ on_init = function(c)
+ client = c
+ end;
+ on_exit = function(code, signal)
+ eq(0, code, "exit code", fake_lsp_logfile)
+ eq(0, signal, "exit signal", fake_lsp_logfile)
+ end;
+ on_handler = function(err, result, ctx)
+ eq(table.remove(expected_handlers), {err, result, ctx}, "expected handler")
+ if ctx.method == "start" then
+ exec_lua([=[
+ BUFFER = vim.api.nvim_get_current_buf()
+ vim.api.nvim_buf_set_lines(BUFFER, 0, -1, true, {"help me"})
+ lsp.buf_attach_client(BUFFER, TEST_RPC_CLIENT_ID)
+ lsp._text_document_did_save_handler(BUFFER)
+ ]=])
+ else
+ client.stop()
+ end
+ end;
+ }
+ end)
+
it('client.supports_methods() should validate capabilities', function()
local expected_handlers = {
{NIL, {}, {method="shutdown", client_id=1}};