ibhagwan / fzf-lua

Improved fzf.vim written in lua
GNU Affero General Public License v3.0
2.19k stars 142 forks source link

Bug: opts.keymap.fzf to toggle items to select not working for LSP symbols #1184

Closed rochakgupta closed 4 months ago

rochakgupta commented 4 months ago

RTFM Checklist

Operating system

Linux, Mac

Shell

zsh

Neovim version (nvim --version)

NVIM v0.9.5-Release

Fzf version (fzf --version)

0.50.0

Output of :lua print(os.getenv('FZF_DEFAULT_OPTS'))

-e -m --reverse --height 50% --border=sharp --bind "tab:toggle-out,shift-tab:toggle-in,ctrl-l:clear-query,ctrl-f:preview-down,ctrl-b:preview-up"

Is the problem reproducible with mini.sh?

Fzf-lua configuration

require('fzf-lua').setup({
  winopts = {
    width = 0.9,
    border = require('rochakgupta.settings').border,
    preview = {
      vertical = 'up:50%',
      layout = 'vertical',
      delay = 0, -- Increase delay to reduce lag on fast scrolling
    },
  },
  keymap = {
    -- These override the default tables completely
    -- no need to set to `false` to disable a bind
    -- delete or modify is sufficient
    builtin = {
      -- neovim `:tmap` mappings for the fzf win
      ['<F1>'] = 'toggle-help',
      ['<F2>'] = 'toggle-fullscreen',
      -- Only valid with the 'builtin' previewer
      ['<F3>'] = 'toggle-preview-wrap',
      ['<F4>'] = 'toggle-preview',
      -- Rotate preview clockwise/counter-clockwise
      ['<F5>'] = 'toggle-preview-ccw',
      ['<F6>'] = 'toggle-preview-cw',
      ['<C-f>'] = 'preview-page-down',
      ['<C-b>'] = 'preview-page-up',
      ['<C-r>'] = 'preview-page-reset',
    },
    fzf = {
      -- fzf '--bind=' options
      ['ctrl-l'] = 'clear-query',
      ['ctrl-c'] = 'abort',
      ['tab'] = 'toggle-out',
      ['shift-tab'] = 'toggle-in',
      ['ctrl-o'] = 'toggle-all',
      ['ctrl-f'] = 'preview-down',
      ['ctrl-b'] = 'preview-up',
      -- Only valid with fzf previewers (bat/cat/git/etc)
      ['f3'] = 'toggle-preview-wrap',
      ['f4'] = 'toggle-preview',
      ['ctrl-d'] = 'preview-page-down',
      ['ctrl-u'] = 'preview-page-up',
    },
  },
  actions = {
    -- These override the default tables completely
    -- no need to set to `false` to disable an action
    -- delete or modify is sufficient
    files = {
      -- providers that inherit these actions:
      --   files, git_files, git_status, grep, lsp
      --   oldfiles, quickfix, loclist, tags, btags
      --   args
      -- default action opens a single selection
      -- or sends multiple selection to quickfix
      -- replace the default action with the below
      -- to open all files whether single or multiple
      -- ["default"]     = actions.file_edit,
      ['default'] = actions.file_edit_or_qf,
      ['ctrl-s'] = actions.file_split,
      ['ctrl-v'] = actions.file_vsplit,
      ['ctrl-q'] = actions.file_edit_or_qf,
    },
    buffers = {
      -- providers that inherit these actions:
      --   buffers, tabs, lines, blines
      ['default'] = actions.buf_edit_or_qf,
      ['ctrl-s'] = actions.buf_split,
      ['ctrl-v'] = actions.buf_vsplit,
      ['ctrl-g'] = {
        fn = actions.buf_del,
        reload = true,
      },
      ['ctrl-q'] = actions.buf_edit_or_qf,
    },
  },
})

Describe the bug / steps to reproduce

Hi @ibhagwan,

First of all, thanks for creating this awesome plugin. I had been aching to give it a shot for a long time as telescope's algorithm just wasn't doing it for me. It works great so far, except for a few providers: lsp_live_workspace_symbols and lsp_document_symbols. To be specific, I am unable to tab, shift-tab and ctrl-o (as configured in the config) to select/unselect the symbols. Here is my dotfiles repository. Do note I am defining FZF_DEFAULT_OPTS in my .zshrc here.

Any idea what might be causing this? Is it possible I have to configure fzf options differently for these providers? Do note that they do show up in the help menu accessible through <F1>: fzf-lua-symbols-issue

Regards, @rochakgupta

ibhagwan commented 4 months ago

https://github.com/ibhagwan/fzf-lua/commit/0a36172c5a25070b4d38a9b3a42261f26b7a4074

@rochakgupta, removed --no-multi from the default fzf options for symbols, should work now.

rochakgupta commented 4 months ago

Thanks for the quick response! That fixed the issue. Also, any way I can get the symbol details to show up in the quickfix list when I send the selected items to it? This is what I am getting right now:

fzf-lua-symbols-qflist-issue
ibhagwan commented 4 months ago

I agree this info should be added, perhaps it gets lost due to the different formatting of the symbol lines, I will fix that when I get a chance.

rochakgupta commented 4 months ago

Thanks for the quick response. Yeah please take your time.

ibhagwan commented 4 months ago

@rochakgupta, https://github.com/ibhagwan/fzf-lua/commit/6ccbe4c0ffc593423d21d99b8395d846fe579c5a - should fix the qf context.

rochakgupta commented 4 months ago

Thanks @ibhagwan , that did it!