gfanto / fzf-lsp.nvim

Enable the power of fzf fuzzy search for the neovim built in lsp
MIT License
222 stars 11 forks source link

Broken with neovim 0.6? #22

Closed geekingfrog closed 2 years ago

geekingfrog commented 2 years ago

Hello. In neovim 0.5.1, I can bring up the fzf window for code action, and execute these actions. For example, add a missing import. However, in 0.6, the same action brings up the window, but upon pressing <enter> nothing happens. I couldn't find anything in the lsp logs and don't know how to debug that.

gfanto commented 2 years ago

Hi, that's weird, i tried with the 0.6 and it works fine for me, can you give me more information about your setup please? For example: 1) is this happening for all language servers? (right now i use mostly gopls for example, maybe try with that) 2) your lsp configuration for that specific language server 3) the fzf-lsp.nvim specific configuration

gfanto commented 2 years ago

Can you also share your neovim version? (nvim --version)

geekingfrog commented 2 years ago

I reproduced it with a minimal configuration \o/

Here's the vim config I 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

  local setup_opts = {
    on_attach = on_attach,
    flags = {
      debounce_text_changes = 150,
    },
  }

  if lsp == 'rust_analyzer' then
    setup_opts.init_options = {
      procMacro = { enable = true }
    }
  end

  nvim_lsp[lsp].setup(setup_opts)

end

EOF

With 0.5, nvim --version gives me:

NVIM v0.5.1
Build type: Release
LuaJIT 2.0.5
Compilation: /usr/bin/cc -D_FORTIFY_SOURCE=2 -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -DNDEBUG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/build/neovim/src/neovim-0.5.1/build/config -I/build/neovim/src/neovim-0.5.1/src -I/usr/include -I/build/neovim/src/neovim-0.5.1/build/src/nvim/auto -I/build/neovim/src/neovim-0.5.1/build/include
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

And with 0.6 I have:

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

I also created a small asciinema to display the problem. If I change the codeAction to use the native lsp function instead of fzf-lsp then it works fine.

This problem also seems to happen for all my lsp (python, clojure and rust).

gfanto commented 2 years ago

Thank you i'll look into that today :+1:

gfanto commented 2 years ago

I found the problem, the have probably introduced some incompatibility with the sync call, so i will fix that. If you want a fast solution until i make the fix, you can just replace: buf_set_keymap('n', '<space>ca', '<cmd>CodeActions<CR>', opts) with buf_set_keymap('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts) that you already have in your config, but commented. I will tell you when the fix will be ready