aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGregory Anders <8965202+gpanders@users.noreply.github.com>2022-05-18 11:59:03 -0600
committerGitHub <noreply@github.com>2022-05-18 11:59:03 -0600
commit03a8269e3a904e7660eb95b9c17ccfc0938f1e30 (patch)
tree331a1a4c3d5f9a63e746c15fe328a8f869e9be5e /test
parentb840b5b6a94411a456123306adca715683e16bba (diff)
parented93186ee22b852580ed8a255ed2104e020cf11c (diff)
downloadrneovim-03a8269e3a904e7660eb95b9c17ccfc0938f1e30.tar.gz
rneovim-03a8269e3a904e7660eb95b9c17ccfc0938f1e30.tar.bz2
rneovim-03a8269e3a904e7660eb95b9c17ccfc0938f1e30.zip
Merge pull request #18507 from gpanders/au-lsp-attached
Diffstat (limited to 'test')
-rw-r--r--test/functional/plugin/lsp_spec.lua38
1 files changed, 38 insertions, 0 deletions
diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua
index 4cb7636825..6c961eff7d 100644
--- a/test/functional/plugin/lsp_spec.lua
+++ b/test/functional/plugin/lsp_spec.lua
@@ -18,6 +18,7 @@ local NIL = helpers.NIL
local read_file = require('test.helpers').read_file
local write_file = require('test.helpers').write_file
local isCI = helpers.isCI
+local meths = helpers.meths
-- Use these to get access to a coroutine so that I can run async tests and use
-- yield.
@@ -341,6 +342,43 @@ describe('LSP', function()
}
end)
+ it('should fire autocommands on attach and detach', function()
+ local client
+ test_rpc_server {
+ test_name = "basic_init";
+ on_setup = function()
+ exec_lua [[
+ BUFFER = vim.api.nvim_create_buf(false, true)
+ vim.api.nvim_create_autocmd('LspAttach', {
+ callback = function(args)
+ local client = vim.lsp.get_client_by_id(args.data.client_id)
+ vim.g.lsp_attached = client.name
+ end,
+ })
+ vim.api.nvim_create_autocmd('LspDetach', {
+ callback = function(args)
+ local client = vim.lsp.get_client_by_id(args.data.client_id)
+ vim.g.lsp_detached = client.name
+ end,
+ })
+ ]]
+ end;
+ on_init = function(_client)
+ client = _client
+ eq(true, exec_lua("return lsp.buf_attach_client(BUFFER, TEST_RPC_CLIENT_ID)"))
+ client.notify('finish')
+ end;
+ on_handler = function(_, _, ctx)
+ if ctx.method == 'finish' then
+ eq('basic_init', meths.get_var('lsp_attached'))
+ exec_lua("return lsp.buf_detach_client(BUFFER, TEST_RPC_CLIENT_ID)")
+ eq('basic_init', meths.get_var('lsp_detached'))
+ client.stop()
+ end
+ end;
+ }
+ end)
+
it('client should return settings via workspace/configuration handler', function()
local expected_handlers = {
{NIL, {}, {method="shutdown", client_id=1}};