9
9
--- @class astrolsp
10
10
local M = {}
11
11
12
- local utils = require " astrolsp.utils"
13
-
14
12
local tbl_contains = vim .tbl_contains
15
13
local tbl_isempty = vim .tbl_isempty
16
14
@@ -29,7 +27,7 @@ local function lsp_event(name) vim.api.nvim_exec_autocmds("User", { pattern = "A
29
27
local function check_cond (cond , client , bufnr )
30
28
local cond_type = type (cond )
31
29
if cond_type == " function" then return cond (client , bufnr ) end
32
- if cond_type == " string" then return utils . supports_method (client , cond , bufnr ) end
30
+ if cond_type == " string" then return client : supports_method (cond , bufnr ) end
33
31
if cond_type == " boolean" then return cond end
34
32
return true
35
33
end
60
58
--- @param client vim.lsp.Client The LSP client details when attaching
61
59
--- @param bufnr integer The buffer that the LSP client is attaching to
62
60
function M .on_attach (client , bufnr )
63
- if utils . supports_method (client , " textDocument/codeLens" , bufnr ) and M .config .features .codelens then
61
+ if client : supports_method (" textDocument/codeLens" , bufnr ) and M .config .features .codelens then
64
62
vim .lsp .codelens .refresh { bufnr = bufnr }
65
63
end
66
64
67
65
local formatting_disabled = vim .tbl_get (M .config , " formatting" , " disabled" )
68
66
if
69
- utils . supports_method (client , " textDocument/formatting" , bufnr )
67
+ client : supports_method (" textDocument/formatting" , bufnr )
70
68
and (formatting_disabled ~= true and not tbl_contains (formatting_disabled , client .name ))
71
69
then
72
70
local autoformat = assert (M .config .formatting .format_on_save )
@@ -78,7 +76,7 @@ function M.on_attach(client, bufnr)
78
76
end
79
77
end
80
78
81
- if utils . supports_method (client , " textDocument/semanticTokens/full" , bufnr ) and vim .lsp .semantic_tokens then
79
+ if client : supports_method (" textDocument/semanticTokens/full" , bufnr ) and vim .lsp .semantic_tokens then
82
80
if M .config .features .semantic_tokens then
83
81
if vim .b [bufnr ].semantic_tokens == nil then vim .b [bufnr ].semantic_tokens = true end
84
82
else
@@ -257,7 +255,7 @@ function M.setup(opts)
257
255
desc = " Add signature help triggers as language servers attach" ,
258
256
callback = function (args )
259
257
local client = vim .lsp .get_client_by_id (args .data .client_id )
260
- if client and utils . supports_method (client , " textDocument/signatureHelp" , args .buf ) then
258
+ if client and client : supports_method (" textDocument/signatureHelp" , args .buf ) then
261
259
for _ , set in ipairs { " triggerCharacters" , " retriggerCharacters" } do
262
260
local set_var = " signature_help_" .. set
263
261
local triggers = vim .b [args .buf ][set_var ] or {}
@@ -276,9 +274,7 @@ function M.setup(opts)
276
274
if not vim .api .nvim_buf_is_valid (args .buf ) then return end
277
275
local triggers , retriggers = {}, {}
278
276
for _ , client in pairs (vim .lsp .get_clients { bufnr = args .buf }) do
279
- if
280
- client .id ~= args .data .client_id and utils .supports_method (client , " textDocument/signatureHelp" , args .buf )
281
- then
277
+ if client .id ~= args .data .client_id and client :supports_method (" textDocument/signatureHelp" , args .buf ) then
282
278
for _ , trigger in ipairs (client .server_capabilities .signatureHelpProvider .triggerCharacters or {}) do
283
279
triggers [trigger ] = true
284
280
end
0 commit comments