Skip to content

Commit

Permalink
fix: handling codeaction items on latest neovim nightly (#27)
Browse files Browse the repository at this point in the history
In the neovim/neovim@9281edb
'codeaction' items type has changed to
`{action: lsp.Command|lsp.CodeAction, ctx: lsp.HandlerContext}[]`
instead of just table of 2 elements `{ client_id, action }`.
So, because of that, plugin crashes with 'attempt to index a nil value'.

To be compatible with < 0.9 version, `if vim.version` was added.
  • Loading branch information
spoof authored Nov 8, 2023
1 parent b0015e6 commit 0fc69eb
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions lua/telescope/_extensions/ui-select.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,21 @@ return require("telescope").register_extension {
client_name = 0,
}
for idx, item in ipairs(items) do
local client = vim.lsp.get_client_by_id(item[1])
local client_id, title
if vim.version and vim.version.cmp(vim.version(), vim.version.parse "0.10-dev") >= 0 then
client_id = item.ctx.client_id
title = item.action.title
else
client_id = item[1]
title = item[2].title
end

local client = vim.lsp.get_client_by_id(client_id)

local entry = {
idx = idx,
["add"] = {
command_title = item[2].title:gsub("\r\n", "\\r\\n"):gsub("\n", "\\n"),
command_title = title:gsub("\r\n", "\\r\\n"):gsub("\n", "\\n"),
client_name = client and client.name or "",
},
text = item,
Expand Down

0 comments on commit 0fc69eb

Please sign in to comment.