Skip to content
This repository has been archived by the owner on Aug 11, 2024. It is now read-only.

fix(capabilities): replace variable #105

Merged
merged 5 commits into from
May 4, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions lua/lspsaga/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,23 @@ end

M.code_action_execute = function(client_id, action, ctx)
local client = vim.lsp.get_client_by_id(client_id)
local is_nightly = vim.fn.has("nvim-0.8.0")
if
not action.edit
and client
and type(client.resolved_capabilities.code_action) == "table"
and client.resolved_capabilities.code_action.resolveProvider
and
(
( is_nightly
and type(client.server_capabilities.codeActionProvider) == "table"
and client.server_capabilities.codeActionProvider.resolveProvider
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for sake of readability, client.server_capabilities should be abbreviated to capabilities

)
or
(
not is_nightly
and type(client.resolved_capabilities.code_action) == "table"
and client.resolved_capabilities.code_action.resolveProvider
)
)
then
client.request("codeAction/resolve", action, function(err, resolved_action)
if err then
Expand Down
8 changes: 7 additions & 1 deletion lua/lspsaga/codeaction/indicator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,14 @@ M.check = function()
if M.servers[current_file] == nil then
vim.lsp.for_each_buffer_client(vim.api.nvim_get_current_buf(), function(client)
if M.servers[current_file] then return end
local is_nightly = vim.fn.has("nvim-0.8.0")
-- Test code action table with version binding
if
client.resolved_capabilities.code_action
(
(is_nightly and client.server_capabilities.codeActionProvider)
or
(not is_nightly and client.resolved_capabilities.code_action)
)
and client.supports_method "code_action"
then
M.servers[current_file] = true
Expand Down
7 changes: 6 additions & 1 deletion lua/lspsaga/signaturehelp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@ local function check_server_support_signaturehelp()
return
end
local clients = vim.lsp.buf_get_clients()
local is_nightly = vim.fn.has("nvim-0.8.0")
for _, client in pairs(clients) do
if client.resolved_capabilities.signature_help == true then
if
(is_nightly and client.server_capabilities.signatureHelpProvider)
or
(not is_nightly and client.resolved_capabilities.signature_help == true)
then
return true
end
end
Expand Down