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 /runtime/lua/vim/lsp/_dynamic.lua | |
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 'runtime/lua/vim/lsp/_dynamic.lua')
-rw-r--r-- | runtime/lua/vim/lsp/_dynamic.lua | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/runtime/lua/vim/lsp/_dynamic.lua b/runtime/lua/vim/lsp/_dynamic.lua index 4bee58559f..5edb27b498 100644 --- a/runtime/lua/vim/lsp/_dynamic.lua +++ b/runtime/lua/vim/lsp/_dynamic.lua @@ -55,7 +55,7 @@ function M:unregister(unregisterations) end --- @param method string ---- @param opts? {bufnr?: number} +--- @param opts? {bufnr: integer?} --- @return lsp.Registration? (table|nil) the registration if found --- @private function M:get(method, opts) @@ -69,14 +69,14 @@ function M:get(method, opts) if not documentSelector then return reg end - if M.match(opts.bufnr, documentSelector) then + if self:match(opts.bufnr, documentSelector) then return reg end end end --- @param method string ---- @param opts? {bufnr?: number} +--- @param opts? {bufnr: integer?} --- @private function M:supports(method, opts) return self:get(method, opts) ~= nil @@ -85,13 +85,17 @@ end --- @param bufnr number --- @param documentSelector lsp.DocumentSelector --- @private -function M.match(bufnr, documentSelector) - local ft = vim.bo[bufnr].filetype +function M:match(bufnr, documentSelector) + local client = vim.lsp.get_client_by_id(self.client_id) + if not client then + return false + end + local language = client.config.get_language_id(bufnr, vim.bo[bufnr].filetype) local uri = vim.uri_from_bufnr(bufnr) local fname = vim.uri_to_fname(uri) for _, filter in ipairs(documentSelector) do local matches = true - if filter.language and ft ~= filter.language then + if filter.language and language ~= filter.language then matches = false end if matches and filter.scheme and not vim.startswith(uri, filter.scheme .. ':') then |