idris2-nvim
idris2-nvim copied to clipboard
Code actions slightly broken with other LSPs when using the save hook from README
Sorry beforehand if this is a dumb question and I'm just using the LSP wrong.
I'm using https://www.lazyvim.org/ as my package manager for Neovim and here's my ~/.config/nvim/lua/plugins/idris2.lua
file:
return {
"ShinKage/idris2-nvim",
dependencies = { 'neovim/nvim-lspconfig', 'MunifTanjim/nui.nvim' },
config = function()
local code_action = require('idris2.code_action')
local filters = code_action.filters
local introspect = code_action.introspect_filter
local function save_hook(action)
if introspect(action) == filters.MAKE_CASE
or introspect(action) == filters.MAKE_WITH then
return
end
vim.cmd('silent write')
end
require('idris2').setup({
code_action_post_hook = save_hook, -- Commenting this out solves the issue
})
end,
}
Now, when trying some other LSP code action with :lua vim.lsp.buf.code_action()
, I get an error.
Sample Haskell file with haskell-language-server:
-- Code action suggests: x = 1 : [1]
x = [1] ++ [1]
Error message as reported to :messages
:
"test.hs" [New] 2L, 52B written
Error executing vim.schedule lua callback: ...l/share/nvim/lazy/idris2-nvim/lua/idris2/code_action.lua:21: attempt to index
local 'action' (a nil value)
stack traceback:
...l/share/nvim/lazy/idris2-nvim/lua/idris2/code_action.lua:21: in function 'introspect'
/home/plumeus/.config/nvim/lua/plugins/idris2.lua:11: in function 'custom_handler'
...l/share/nvim/lazy/idris2-nvim/lua/idris2/code_action.lua:171: in function 'on_choice'
...eovim-unwrapped-0.10.2/share/nvim/runtime/lua/vim/ui.lua:54: in function 'ui_select'
...l/share/nvim/lazy/idris2-nvim/lua/idris2/code_action.lua:174: in function 'select'
...-unwrapped-0.10.2/share/nvim/runtime/lua/vim/lsp/buf.lua:821: in function 'on_code_action_results'
...-unwrapped-0.10.2/share/nvim/runtime/lua/vim/lsp/buf.lua:865: in function 'handler'
...wrapped-0.10.2/share/nvim/runtime/lua/vim/lsp/client.lua:687: in function ''
vim/_editor.lua: in function <vim/_editor.lua:0>