You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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()
localcode_action=require('idris2.code_action')
localfilters=code_action.filterslocalintrospect=code_action.introspect_filterlocalfunctionsave_hook(action)
ifintrospect(action) ==filters.MAKE_CASEorintrospect(action) ==filters.MAKE_WITHthenreturnendvim.cmd('silent write')
endrequire('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>
The text was updated successfully, but these errors were encountered:
I can reproduce this, though I surprisingly never have before just by chance.
The hook this plugin installs is not specific to the type of file being read. I am not sure (having not looked into it) if there would be a more appropriate way to install the hook that was more targeted, but I am sure this can be worked around in your implementation of that callback at least.
Due to my ignorance of pretty much everything involved (Lua, Neovim, this repo), I have no idea what that's supposed to do. But hey, at least it's definitely work for me. Both this LSP and haskell-language-server code actions work now as I would expect.
New config:
localcode_action=require('idris2.code_action')
localfilters=code_action.filterslocalintrospect=code_action.introspect_filterlocalfunctionsave_hook(action)
-- https://github.com/ShinKage/idris2-nvim/issues/33#issuecomment-2425178847ifnotactionornotaction.titlethenreturnendifintrospect(action) ==filters.MAKE_CASEorintrospect(action) ==filters.MAKE_WITHthenreturnendvim.cmd('silent write')
end
Edit: I presume I should keep this issue open until the README is fixed?
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: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:
Error message as reported to
:messages
:The text was updated successfully, but these errors were encountered: