diff options
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/lspconfig/util.lua | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/lua/lspconfig/util.lua b/lua/lspconfig/util.lua index 7de9e8b8..213e87f3 100644 --- a/lua/lspconfig/util.lua +++ b/lua/lspconfig/util.lua @@ -28,9 +28,9 @@ function M.bufname_valid(bufname) end function M.validate_bufnr(bufnr) - validate { - bufnr = { bufnr, 'n' }, - } + if nvim_eleven then + validate('bufnr', bufnr, 'number') + end return bufnr == 0 and api.nvim_get_current_buf() or bufnr end @@ -174,7 +174,9 @@ M.path = (function() end)() function M.search_ancestors(startpath, func) - validate { func = { func, 'f' } } + if nvim_eleven then + validate('func', func, 'function') + end if func(startpath) then return startpath end @@ -192,14 +194,6 @@ function M.search_ancestors(startpath, func) end end -function M.tbl_flatten(t) - return nvim_eleven and vim.iter(t):flatten(math.huge):totable() or vim.tbl_flatten(t) -end - -function M.get_lsp_clients(filter) - return nvim_eleven and lsp.get_clients(filter) or lsp.get_active_clients(filter) -end - local function escape_wildcards(path) return path:gsub('([%[%]%?%*])', '\\%1') end @@ -245,6 +239,7 @@ function M.get_active_clients_list_by_ft(filetype) local clients = M.get_lsp_clients() local clients_list = {} for _, client in pairs(clients) do + --- @diagnostic disable-next-line:undefined-field local filetypes = client.config.filetypes or {} for _, ft in pairs(filetypes) do if ft == filetype then @@ -326,6 +321,18 @@ function M.strip_archive_subpath(path) return path end +--- Functions that can be removed once minimum required neovim version is high enough + +function M.tbl_flatten(t) + --- @diagnostic disable-next-line:deprecated + return nvim_eleven and vim.iter(t):flatten(math.huge):totable() or vim.tbl_flatten(t) +end + +function M.get_lsp_clients(filter) + --- @diagnostic disable-next-line:deprecated + return nvim_eleven and lsp.get_clients(filter) or lsp.get_active_clients(filter) +end + --- Deprecated functions --- @deprecated use `vim.fn.isdirectory(path) == 1` instead |
