Skip to content

Commit c5d8c0e

Browse files
committed
refactor!: require Neovim v0.10+
1 parent 909fbe6 commit c5d8c0e

File tree

4 files changed

+11
-17
lines changed

4 files changed

+11
-17
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ AstroLSP provides a simple API for configuring and setting up language servers i
1212

1313
## ⚡️ Requirements
1414

15-
- Neovim >= 0.9
15+
- Neovim >= 0.10
1616

1717
## 📦 Installation
1818

lua/astrolsp/file_operations.lua

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ local M = {}
1414

1515
local config = vim.tbl_get(require "astrolsp", "config", "file_operations") or {}
1616

17-
-- TODO: remove check when dropping support for Neovim v0.9
18-
local get_clients = vim.lsp.get_clients or vim.lsp.get_active_clients
19-
2017
---@class AstroLSPFileOperationsRename
2118
---@field from string the original filename
2219
---@field to string the new filename
@@ -50,7 +47,7 @@ end
5047
---@param fnames string|string[] a file or list of files that were created
5148
function M.didCreateFiles(fnames)
5249
if not vim.tbl_get(config, "operations", "didCreate") then return end
53-
for _, client in pairs(get_clients()) do
50+
for _, client in pairs(vim.lsp.get_clients()) do
5451
local did_create = vim.tbl_get(client, "server_capabilities", "workspace", "fileOperations", "didCreate")
5552
if did_create then
5653
if type(fnames) == "string" then fnames = { fnames } end
@@ -70,7 +67,7 @@ end
7067
---@param fnames string|string[] a file or list of files that were deleted
7168
function M.didDeleteFiles(fnames)
7269
if not vim.tbl_get(config, "operations", "didDelete") then return end
73-
for _, client in pairs(get_clients()) do
70+
for _, client in pairs(vim.lsp.get_clients()) do
7471
local did_delete = vim.tbl_get(client, "server_capabilities", "workspace", "fileOperations", "didDelete")
7572
if did_delete ~= nil then
7673
if type(fnames) == "string" then fnames = { fnames } end
@@ -90,7 +87,7 @@ end
9087
---@param renames AstroLSPFileOperationsRename|AstroLSPFileOperationsRename[] a table or list of tables of files that were renamed
9188
function M.didRenameFiles(renames)
9289
if not vim.tbl_get(config, "operations", "didRename") then return end
93-
for _, client in pairs(get_clients()) do
90+
for _, client in pairs(vim.lsp.get_clients()) do
9491
local did_rename = vim.tbl_get(client, "server_capabilities", "workspace", "fileOperations", "didRename")
9592
if did_rename ~= nil then
9693
if renames.from then renames = { renames } end
@@ -120,7 +117,7 @@ end
120117
---@param fnames string|string[] a file or list of files that will be created
121118
function M.willCreateFiles(fnames)
122119
if not vim.tbl_get(config, "operations", "willCreate") then return end
123-
for _, client in pairs(get_clients()) do
120+
for _, client in pairs(vim.lsp.get_clients()) do
124121
local will_create = vim.tbl_get(client, "server_capabilities", "workspace", "fileOperations", "willCreate")
125122
if will_create then
126123
if type(fnames) == "string" then fnames = { fnames } end
@@ -142,7 +139,7 @@ end
142139
---@param fnames string|string[] a file or list of files that will be deleted
143140
function M.willDeleteFiles(fnames)
144141
if not vim.tbl_get(config, "operations", "willDelete") then return end
145-
for _, client in pairs(get_clients()) do
142+
for _, client in pairs(vim.lsp.get_clients()) do
146143
local will_delete = vim.tbl_get(client, "server_capabilities", "workspace", "fileOperations", "willDelete")
147144
if will_delete then
148145
if type(fnames) == "string" then fnames = { fnames } end
@@ -164,7 +161,7 @@ end
164161
---@param renames AstroLSPFileOperationsRename|AstroLSPFileOperationsRename[] a table or list of tables of files that will be renamed
165162
function M.willRenameFiles(renames)
166163
if not vim.tbl_get(config, "operations", "willRename") then return end
167-
for _, client in pairs(get_clients()) do
164+
for _, client in pairs(vim.lsp.get_clients()) do
168165
local will_rename = vim.tbl_get(client, "server_capabilities", "workspace", "fileOperations", "willRename")
169166
if will_rename then
170167
if renames.from then renames = { renames } end

lua/astrolsp/init.lua

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ function M.on_attach(client, bufnr)
132132
local callback_func = command and function(_, _, _) vim.cmd(command) end or callback
133133
autocmd.callback = function(args)
134134
local invalid = true
135-
for _, cb_client in ipairs((vim.lsp.get_clients or vim.lsp.get_active_clients) { buffer = bufnr }) do
135+
for _, cb_client in ipairs(vim.lsp.get_clients { buffer = bufnr }) do
136136
if check_cond(cond, cb_client, bufnr) then
137137
invalid = false
138138
break
@@ -247,8 +247,7 @@ function M.setup(opts)
247247
and not (vim.tbl_contains(disabled, client.name) or (type(filter) == "function" and not filter(client)))
248248
end
249249

250-
-- TODO: remove check when dropping support for Neovim v0.9
251-
if vim.lsp.inlay_hint then vim.lsp.inlay_hint.enable(M.config.features.inlay_hints ~= false) end
250+
vim.lsp.inlay_hint.enable(M.config.features.inlay_hints ~= false)
252251

253252
-- Set up tracking of signature help trigger characters
254253
local augroup = vim.api.nvim_create_augroup("track_signature_help_triggers", { clear = true })
@@ -275,7 +274,7 @@ function M.setup(opts)
275274
callback = function(args)
276275
if not vim.api.nvim_buf_is_valid(args.buf) then return end
277276
local triggers, retriggers = {}, {}
278-
for _, client in pairs((vim.lsp.get_clients or vim.lsp.get_active_clients) { bufnr = args.buf }) do
277+
for _, client in pairs(vim.lsp.get_clients { bufnr = args.buf }) do
279278
if client.id ~= args.data.client_id and client.supports_method "textDocument/signatureHelp" then
280279
for _, trigger in ipairs(client.server_capabilities.signatureHelpProvider.triggerCharacters or {}) do
281280
triggers[trigger] = true

lua/astrolsp/toggles.lua

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ function M.buffer_semantic_tokens(bufnr, silent)
6464
bufnr = bufnr or 0
6565
vim.b[bufnr].semantic_tokens = not vim.b[bufnr].semantic_tokens
6666
local toggled = false
67-
-- TODO: remove check after dropping support for Neovim v0.9
68-
---@diagnostic disable-next-line: deprecated
69-
for _, client in ipairs((vim.lsp.get_clients or vim.lsp.get_active_clients) { bufnr = bufnr }) do
67+
for _, client in ipairs(vim.lsp.get_clients { bufnr = bufnr }) do
7068
if client.supports_method "textDocument/semanticTokens/full" then
7169
-- HACK: `semantic_tokens.start/stop` don't support 0 for current buffer
7270
local real_bufnr = bufnr == 0 and vim.api.nvim_get_current_buf() or bufnr

0 commit comments

Comments
 (0)