codeAction (still) broken in neovim 6+
geekingfrog opened this issue · 5 comments
It seems this commit didn't quite fix #22.
I tried to debug it for a while but couldn't figure out the reason. Here's what I have so far:
nvim --version
NVIM v0.6.0
Build type: Release
LuaJIT 2.0.5
Compiled by builduser
Features: +acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/usr/share/nvim"
Run :checkhealth for more info
(not I have the same issue with 6.1)
vimrc used:
call plug#begin('~/.config/nvim/plugged')
Plug 'neovim/nvim-lspconfig'
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'
Plug 'gfanto/fzf-lsp.nvim'
call plug#end()
lua << EOF
vim.lsp.set_log_level("debug")
local nvim_lsp = require('lspconfig')
-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
-- Enable completion triggered by <c-x><c-o>
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings.
local opts = { noremap=true, silent=true }
-- See `:help vim.lsp.*` for documentation on any of the below functions
-- buf_set_keymap('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
buf_set_keymap('n', '<space>ca', '<cmd>CodeActions<CR>', opts)
end
-- Use a loop to conveniently call 'setup' on multiple servers and
-- map buffer local keybindings when the language server attaches
local servers = { 'jedi_language_server', 'rust_analyzer', 'clojure_lsp', 'dhall_lsp_server' }
for _, lsp in ipairs(servers) do
nvim_lsp[lsp].setup(setup_opts)
end
EOF
When choosing the action to execute, nothing happens and I get the following in :messages:
/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:346: Cannot serialise function: type not supported
stack traceback:
^I[C]: in function 'encode'
^I/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:346: in function 'encode_and_send'
^I/usr/share/nvim/runtime/lua/vim/lsp/rpc.lua:394: in function 'request'
^I/usr/share/nvim/runtime/lua/vim/lsp.lua:956: in function 'request'
^I...e/HOME/.config/nvim/plugged/fzf-lsp.nvim/lua/fzf_lsp.lua:395: in function <...e/HOME/.config/nvim/plu
gged/fzf-lsp.nvim/lua/fzf_lsp.lua:384>
It seems the action
table passed to the client holds some un-serializable attribute, but when I tried to inspect it further I got nothing, and no metatable. I'm not sure what's going on.
Thank you for been so accurate on the desciption. Can i also ask you:
- what language server are you using?
- is this happening when you use the
:CodeAction
comand or even using the async handlers? (from the vimrc config snippet seams theCodeAction
command because i don't se the setup call for the fzf_lsp, but i wanna make sure to chase the right problem)
- I'm using rust-analyzer, with the following setup:
cargo new testproject
cd testproject
cat > src/main.rs <<EOF
fn main() {
let m = BTreeMap::new();
println!("Hello, world!");
}
EOF
Then open src/main.rs
, put the cursor on the BTreeMap
and attempt to automatically add the import (use std::collections::BTreeMap
)
- This is happening when calling
CodeAction
command, which ultimately is going to use an async handler insidefzf_code_actions
Ok no problem i've found it, the last commit should have fix that (hopefully forever 😅) let me know if it works
To try just call :PlugUpdate
It woooooorks 🥳 thanks for the quick update.