diff options
author | Michal Liszcz <liszcz.michal@gmail.com> | 2023-12-22 15:03:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-22 15:03:13 +0100 |
commit | 031088fc0afffe4af6fa90d68d5b93ca09992ef1 (patch) | |
tree | b070d3d66acefc247fbd55b8280f9ded668b90cd /test | |
parent | 2151e781e47d647c17812bcc27395fc424398d94 (diff) | |
download | rneovim-031088fc0afffe4af6fa90d68d5b93ca09992ef1.tar.gz rneovim-031088fc0afffe4af6fa90d68d5b93ca09992ef1.tar.bz2 rneovim-031088fc0afffe4af6fa90d68d5b93ca09992ef1.zip |
fix(lsp): filetype matching to documentSelector in dynamic capabilities (#25425)
Use the get_language_id client option to resolve the filetype when
matching the document selector in a dynamic capability.
Co-authored-by: Mathias Fussenegger <f.mathias@zignar.net>
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/plugin/lsp_spec.lua | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua index 56d31a0e44..0026a7caa7 100644 --- a/test/functional/plugin/lsp_spec.lua +++ b/test/functional/plugin/lsp_spec.lua @@ -3936,12 +3936,15 @@ describe('LSP', function() describe('#dynamic vim.lsp._dynamic', function() it('supports dynamic registration', function() + ---@type string local root_dir = helpers.tmpname() os.remove(root_dir) mkdir(root_dir) local tmpfile = root_dir .. '/dynamic.foo' local file = io.open(tmpfile, 'w') - file:close() + if file then + file:close() + end exec_lua(create_server_definition) local result = exec_lua([[ @@ -3952,6 +3955,9 @@ describe('LSP', function() name = 'dynamic-test', cmd = server.cmd, root_dir = root_dir, + get_language_id = function() + return "dummy-lang" + end, capabilities = { textDocument = { formatting = { @@ -3985,6 +3991,13 @@ describe('LSP', function() { id = 'range-formatting', method = 'textDocument/rangeFormatting', + registerOptions = { + documentSelector = { + { + language = "dummy-lang" + }, + } + } }, }, }, { client_id = client_id }) @@ -4002,7 +4015,11 @@ describe('LSP', function() local function check(method, fname) local bufnr = fname and vim.fn.bufadd(fname) or nil local client = vim.lsp.get_client_by_id(client_id) - result[#result + 1] = {method = method, fname = fname, supported = client.supports_method(method, {bufnr = bufnr})} + result[#result + 1] = { + method = method, + fname = fname, + supported = client.supports_method(method, {bufnr = bufnr}) + } end |