Skip to content

Commit

Permalink
Support neovim < 0.10 for lsp.get_clients
Browse files Browse the repository at this point in the history
  • Loading branch information
hedyhli committed Jun 5, 2024
1 parent e6afff2 commit 193e03a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions lua/outline/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ function M.setup(opts)
_G._outline_nvim_has = {
[8] = minor >= 8,
[9] = minor >= 9,
[10] = minor >= 10,
}

cfg.setup(opts)
Expand Down
6 changes: 5 additions & 1 deletion lua/outline/providers/nvim-lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ local function get_appropriate_client(bufnr, capability)
local clients, use_client

if _G._outline_nvim_has[8] then
clients = l.get_clients({ bufnr = bufnr })
if _G._outline_nvim_has[10] then
clients = l.get_clients({ bufnr = bufnr })
else
clients = l.get_active_clients({ bufnr = bufnr })
end
for _, client in ipairs(clients) do
if _check_client(client, capability) then
use_client = client
Expand Down
7 changes: 6 additions & 1 deletion lua/outline/utils/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ local config = require('outline.config')
local M = {}

function M.is_buf_attached_to_lsp(bufnr)
local clients = vim.lsp.get_clients({ bufnr = bufnr or 0 })
local clients
if _G._outline_nvim_has[10] then
clients = vim.lsp.get_clients({ bufnr = bufnr or 0 })
else
clients = vim.lsp.get_active_clients({ bufnr = bufnr or 0 })
end
return clients ~= nil and #clients > 0
end

Expand Down

0 comments on commit 193e03a

Please sign in to comment.