Skip to content

Commit

Permalink
buf_get_clients -> get_clients
Browse files Browse the repository at this point in the history
buf_get_clients is deprecated.
  • Loading branch information
dstein64 committed Jul 5, 2024
1 parent 18c6e69 commit c7b5fa4
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/vim/.vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -1306,6 +1306,14 @@ function! LspFormatExpr()
endfunction

lua << EOF
local buf_get_clients = function(bufnr)
if vim.lsp.get_clients ~= nil then
return vim.lsp.get_clients({buffer = bufnr})
else
return vim.lsp.buf_get_clients(bufnr)
end
end

-- Define a custom synchronous omnifunc, instead of using the asynchronous
-- built-in, v:lua.lsp.omnifunc. This version supports completeopt=longest,
-- unlike the built-in (Neovim Issue #15314).
Expand All @@ -1317,7 +1325,7 @@ function _G.lsp_omnifunc_sync(findstart, base)
-- modified prior to the second call.
local bufnr = vim.fn.bufnr()
result = {}
local has_clients = not vim.tbl_isempty(vim.lsp.buf_get_clients(bufnr))
local has_clients = not vim.tbl_isempty(buf_get_clients(bufnr))
if not has_clients then return -3 end
local pos = vim.api.nvim_win_get_cursor(0)
local line = vim.api.nvim_get_current_line()
Expand Down Expand Up @@ -1352,7 +1360,7 @@ end
-- Returns a list of LSP clients attached to the current buffer.
function _G.lsp_buf_clients()
local clients = {}
for _, client in pairs(vim.lsp.buf_get_clients()) do
for _, client in pairs(buf_get_clients()) do
table.insert(clients, client.name)
end
return clients
Expand Down

0 comments on commit c7b5fa4

Please sign in to comment.