ibhagwan / fzf-lua

Improved fzf.vim written in lua
MIT License
2.31k stars 150 forks source link

Could we have a list of string passing into the `setup.keymap`? #571

Closed nyngwang closed 1 year ago

nyngwang commented 1 year ago

Description

As title. Is it possible to achieve something like this? Or there is some existing way to achieve the same result (entering fullscreen and open the preview). Thanks in advance!

keymap = {
  builtin = {
    ['<F1>']        = { 'toggle-fullscreen', 'toggle-preview' },
    -- ['<F2>']        = 'toggle-preview',
    -- ['<F3>']        = 'toggle-preview-cw',
    -- ['<F4>']        = 'toggle-preview-ccw',
    -- ["<S-down>"]    = "preview-page-down",
    -- ["<S-up>"]      = "preview-page-up",
    -- ["<S-left>"]    = "preview-page-reset",
  }
},
ibhagwan commented 1 year ago

Not possible, what’s the point of this if I may ask?

nyngwang commented 1 year ago

To @ibhagwan:

[...], what’s the point of this if I may ask?

I recently like the idea of minimal UI before manually calling any functions. So I move fzf-lua to the center of my screen and disable the preview window. When I need to preview a hovered item, I will always call the two actions in sequence: toggle-preview, toggle-fullscreen. But this will cost two keypress. It will be good if I can just use one keymap to complete the task.

Or, is it possible achieve this in another format: by passing a function () as the value for the table, then calling each internal function in order?

before & after(pressing <F1><F2>, so I have to remember that I need to press two keys):

ibhagwan commented 1 year ago

I have a similar workflow in my neovim config to review git changes, I open git status, make it full screen and then make the tmux pane also fullscreen using <tmux prefix>-Z, IMHO, this is better achieved using your own customization, I don’t plan on adding this functionality into fzf-lua as it adds unnecessary complexity into the bind logic.

My code if you wish to take a look:

https://github.com/ibhagwan/nvim-lua/blob/6fc689c5f14fe9f0850f47622613ddb07ec51061/lua/plugins/fzf-lua/init.lua#L161-L186

nyngwang commented 1 year ago

@ibhagwan You're right, apologies that I complicated the problem. With your config, I came up with the following solution: (You might know how to improve it)

vim.keymap.set('t', '<F1>', function ()
  if vim.bo.filetype == 'fzf' then
    require('fzf-lua.win').toggle_preview()
    require('fzf-lua.win').toggle_fullscreen()
  end
end, { noremap = true, silent = true, nowait = true })

Thanks again for this beautiful plugin -- fzf-lua :) This issue can be safely closed now!

ibhagwan commented 1 year ago

Great! will close :-)