ibhagwan / fzf-lua

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

Unable to open preview for custom map #989

Closed asknet closed 7 months ago

asknet commented 7 months ago

Info

Description

In my init.lua i disable previewer by default, by setting like below

fzf.setup({
    preview_opts = 'hidden',
    fzf_opts = { ["--layout"] = "default" },
})

Now for some custom maps, I want to enable preview and I tried below both options, but it's not working. Appreciate your time and help on this.

lua require('fzf-lua').grep_cword({ preview_opts = true, winopts = { preview = { vertical = 'right', hidden = 'nohidden' }}} )
lua require('fzf-lua').grep_cword({ previewer = true, winopts = { preview = { vertical = 'right', hidden = 'nohidden' }}} )
ibhagwan commented 7 months ago

I haven’t tested, but it’s probably because you’re using a very old backward compatible option preview_opts that takes precedence over your overrides, change your setup to:

fzf.setup({
    winopts = { preview = { hidden = 'hidden' }},
    fzf_opts = { ["--layout"] = "default" },
})

Do this and your overrides will work as expected.

ibhagwan commented 7 months ago

Btw I also created a shortened version for vimscript where you can set the key with one string, for example to enable preview (with the setup I provided above):

:FzfLua grep_cword winopts.preview.hidden=nohidden
asknet commented 7 months ago

Thank you for quick response @ibhagwan After fixing preview_opts it's working. You are awesome!

ibhagwan commented 7 months ago

Thank you for quick response @ibhagwan After fixing preview_opts it's working. You are awesome!

Ty for the kind words @asknet!