ojroques / nvim-lspfuzzy

A Neovim plugin to make the LSP client use FZF
BSD 2-Clause "Simplified" License
316 stars 11 forks source link

code action not works #15

Closed zjsyhjh closed 3 years ago

zjsyhjh commented 3 years ago

codeAction doesn't seem to work for me. Here is the config.

 vim.api.nvim_buf_set_keymap('n', 'gca', [[<cmd>lua vim.lsp.buf.code_action()<CR>]], { silent = true, noremap = true })
ojroques commented 3 years ago

If you want to use nvim_buf_set_keymap for your mapping, the first argument must be the buffer handle, see :h nvim_buf_set_keymap() (0 for the current buffer)

Otherwise you can set the mapping like so:

 vim.api.nvim_set_keymap('n', 'gca', [[<cmd>lua vim.lsp.buf.code_action()<CR>]], { silent = true, noremap = true })
zjsyhjh commented 3 years ago

https://user-images.githubusercontent.com/5110713/122389003-0aa2ea80-cfa3-11eb-8d27-a69d0571370f.mov

@ojroques Sorry for my mistake. The video shows the whole process. I can get the code action when using the plugin, but when I confirm the action, it does nothing.

ojroques commented 3 years ago

demo

Code actions work fine on my side. Your issue most likely comes from the language server you're using and not from the plugin.

To check if that's the case, disable the plugin and retry applying the code action. If it still doesn't work, it definitely comes from your language server.

zjsyhjh commented 3 years ago

https://user-images.githubusercontent.com/5110713/122434191-75671c80-cfc9-11eb-8e13-d364c7a9be0a.mov

@ojroques it works when I disable the plugin.

ojroques commented 3 years ago

I think I have found the issue, the logic was wrong when applying code actions. Hopefully everything works as intended now. Please update the plugin and re-open the issue if it still doesn't work.

zjsyhjh commented 3 years ago

It works for me now. Thanks!