Skip to content

Commit 1e36aa9

Browse files
committed
refactor!: drop support for Neovim v0.10
1 parent 4943abb commit 1e36aa9

File tree

2 files changed

+22
-39
lines changed

2 files changed

+22
-39
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ AstroUI provides a simple API for configuring and setting up the user interface
1010

1111
## ⚡️ Requirements
1212

13-
- Neovim >= 0.10
13+
- Neovim >= 0.11
1414
- [astrocore][astrocore]
1515

1616
## 📦 Installation

lua/astroui/folding.lua

Lines changed: 21 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -91,47 +91,30 @@ function M.info(bufnr)
9191
require("astrocore").notify(table.concat(lines, "\n"), vim.log.levels.INFO, { title = "AstroNvim Folding" })
9292
end
9393

94-
-- TODO: remove helper function when dropping support for Neovim v0.10
95-
96-
---@param client vim.lsp.Client
97-
---@param method string
98-
---@param bufnr? integer
99-
local function supports_method(client, method, bufnr)
100-
if vim.fn.has "nvim-0.11" == 1 then
101-
return client:supports_method(method, bufnr)
102-
else
103-
---@diagnostic disable-next-line: param-type-mismatch
104-
return client.supports_method(method, { bufnr = bufnr })
105-
end
106-
end
107-
10894
function M.setup()
10995
vim.api.nvim_create_user_command("AstroFoldInfo", function() M.info() end, { desc = "Display folding information" })
110-
-- TODO: remove check when dropping support for Neovim v0.10
111-
if vim.lsp.foldexpr then
112-
local augroup = vim.api.nvim_create_augroup("astroui_foldexpr", { clear = true })
113-
vim.api.nvim_create_autocmd("LspAttach", {
114-
desc = "Monitor attached LSP clients with fold providers",
115-
group = augroup,
116-
callback = function(args)
117-
local client = assert(vim.lsp.get_client_by_id(args.data.client_id))
118-
if supports_method(client, "textDocument/foldingRange", args.buf) then lsp_bufs[args.buf] = true end
119-
end,
120-
})
121-
vim.api.nvim_create_autocmd("LspDetach", {
122-
group = augroup,
123-
desc = "Safely remove LSP folding providers when language servers detach",
124-
callback = function(args)
125-
if not vim.api.nvim_buf_is_valid(args.buf) then return end
126-
for _, client in pairs(vim.lsp.get_clients { bufnr = args.buf }) do
127-
if client.id ~= args.data.client_id and supports_method(client, "textDocument/foldingRange", args.buf) then
128-
return
129-
end
96+
local augroup = vim.api.nvim_create_augroup("astroui_foldexpr", { clear = true })
97+
vim.api.nvim_create_autocmd("LspAttach", {
98+
desc = "Monitor attached LSP clients with fold providers",
99+
group = augroup,
100+
callback = function(args)
101+
local client = assert(vim.lsp.get_client_by_id(args.data.client_id))
102+
if client:supports_method("textDocument/foldingRange", args.buf) then lsp_bufs[args.buf] = true end
103+
end,
104+
})
105+
vim.api.nvim_create_autocmd("LspDetach", {
106+
group = augroup,
107+
desc = "Safely remove LSP folding providers when language servers detach",
108+
callback = function(args)
109+
if not vim.api.nvim_buf_is_valid(args.buf) then return end
110+
for _, client in pairs(vim.lsp.get_clients { bufnr = args.buf }) do
111+
if client.id ~= args.data.client_id and client:supports_method("textDocument/foldingRange", args.buf) then
112+
return
130113
end
131-
lsp_bufs[args.buf] = nil
132-
end,
133-
})
134-
end
114+
end
115+
lsp_bufs[args.buf] = nil
116+
end,
117+
})
135118
is_setup = true
136119
end
137120

0 commit comments

Comments
 (0)