99--- @class astrolsp
1010local M = {}
1111
12- local utils = require " astrolsp.utils"
13-
1412local tbl_contains = vim .tbl_contains
1513local tbl_isempty = vim .tbl_isempty
1614
@@ -29,7 +27,7 @@ local function lsp_event(name) vim.api.nvim_exec_autocmds("User", { pattern = "A
2927local function check_cond (cond , client , bufnr )
3028 local cond_type = type (cond )
3129 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
3331 if cond_type == " boolean" then return cond end
3432 return true
3533end
6058--- @param client vim.lsp.Client The LSP client details when attaching
6159--- @param bufnr integer The buffer that the LSP client is attaching to
6260function 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
6462 vim .lsp .codelens .refresh { bufnr = bufnr }
6563 end
6664
6765 local formatting_disabled = vim .tbl_get (M .config , " formatting" , " disabled" )
6866 if
69- utils . supports_method (client , " textDocument/formatting" , bufnr )
67+ client : supports_method (" textDocument/formatting" , bufnr )
7068 and (formatting_disabled ~= true and not tbl_contains (formatting_disabled , client .name ))
7169 then
7270 local autoformat = assert (M .config .formatting .format_on_save )
@@ -78,7 +76,7 @@ function M.on_attach(client, bufnr)
7876 end
7977 end
8078
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
8280 if M .config .features .semantic_tokens then
8381 if vim .b [bufnr ].semantic_tokens == nil then vim .b [bufnr ].semantic_tokens = true end
8482 else
@@ -257,7 +255,7 @@ function M.setup(opts)
257255 desc = " Add signature help triggers as language servers attach" ,
258256 callback = function (args )
259257 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
261259 for _ , set in ipairs { " triggerCharacters" , " retriggerCharacters" } do
262260 local set_var = " signature_help_" .. set
263261 local triggers = vim .b [args .buf ][set_var ] or {}
@@ -276,9 +274,7 @@ function M.setup(opts)
276274 if not vim .api .nvim_buf_is_valid (args .buf ) then return end
277275 local triggers , retriggers = {}, {}
278276 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
282278 for _ , trigger in ipairs (client .server_capabilities .signatureHelpProvider .triggerCharacters or {}) do
283279 triggers [trigger ] = true
284280 end
0 commit comments