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 all 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
12 changes: 10 additions & 2 deletions lua/lspsaga/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,19 @@ end

M.code_action_execute = function(client_id, action, ctx)
local client = vim.lsp.get_client_by_id(client_id)

local code_action_provide = nil
if vim.fn.has("nvim-0.8.0") then
code_action_provide = client.server_capabilities.codeActionProvider
else
code_action_provide = client.resolved_capabilities.code_action
end

if
not action.edit
and client
and type(client.resolved_capabilities.code_action) == "table"
and client.resolved_capabilities.code_action.resolveProvider
and type(code_action_provide) == "table"
and code_action_provide.resolveProvider
then
client.request("codeAction/resolve", action, function(err, resolved_action)
if err then
Expand Down
11 changes: 8 additions & 3 deletions lua/lspsaga/codeaction/indicator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +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
if
client.resolved_capabilities.code_action
and client.supports_method "code_action"
local is_nightly = vim.fn.has("nvim-0.8.0")
local code_action_provider = nil
if is_nightly then
code_action_provider = client.server_capabilities.codeActionProvider
else
code_action_provider = client.resolved_capabilities.code_action
end
if code_action_provider and client.supports_method "code_action"
then
M.servers[current_file] = true
end
Expand Down
10 changes: 9 additions & 1 deletion lua/lspsaga/signaturehelp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,16 @@ 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
local provider = nil
if is_nightly then
provider = client.server_capabilities.signatureHelpProvider -- table
else
provider = client.resolved_capabilities.signature_help -- boolean
end

if provider then
return true
end
end
Expand Down