Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to show name of the LSP in code actions #825

Merged
merged 6 commits into from
Feb 3, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ Default options:
```lua
code_action = {
num_shortcut = true,
show_server_name = false,
keys = {
-- string | table type
quit = "q",
Expand Down
1 change: 1 addition & 0 deletions doc/lspsaga.nvim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ Default options:
>
code_action = {
num_shortcut = true,
show_server_name = false,
MaximilianLloyd marked this conversation as resolved.
Show resolved Hide resolved
keys = {
-- string | table type
quit = "q",
Expand Down
8 changes: 6 additions & 2 deletions lua/lspsaga/codeaction.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,16 @@ function act:action_callback()
for index, client_with_actions in pairs(self.action_tuples) do
local action_title = ''
local indent = index > 9 and '' or ' '
if #client_with_actions ~= 2 then
if #client_with_actions ~= 3 then
vim.notify('There has something wrong in aciton_tuples')
return
end
if client_with_actions[2].title then
action_title = indent .. index .. ' ' .. client_with_actions[2].title
end
if (config.code_action.show_server_name == true) then
action_title = action_title .. ' ' .. client_with_actions[3]
end
table.insert(contents, action_title)
end

Expand Down Expand Up @@ -148,8 +151,9 @@ function act:send_code_action_request(main_buf, options, cb)
self.action_tuples = {}

for client_id, result in pairs(results) do
local name = vim.lsp.get_client_by_id(client_id).name
MaximilianLloyd marked this conversation as resolved.
Show resolved Hide resolved
for _, action in pairs(result.result or {}) do
table.insert(self.action_tuples, { client_id, action })
table.insert(self.action_tuples, { client_id, action, name })
end
end

Expand Down
1 change: 1 addition & 0 deletions lua/lspsaga/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ local default_config = {
},
code_action = {
num_shortcut = true,
show_server_name = false,
keys = {
quit = 'q',
exec = '<CR>',
Expand Down