Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there an easy way to configure actions of all providers that deal with files? #279

Closed
tamirzb opened this issue Dec 25, 2021 · 4 comments
Labels
question Further information is requested

Comments

@tamirzb
Copy link
Contributor

tamirzb commented Dec 25, 2021

I want to configure the default action to always open multiple selections in multiple buffers, and never in a quickfix list. Is there an easy way to configure this for all providers?

From what I understand, the way I would have to go to do this is to configure this explicitly for each of the providers, or am I wrong? Is there a way to change the "default" actions?

@ibhagwan
Copy link
Owner

Unfortinately there's no easy way to configure all the default actions in one go, tehcnically they all "inherit" from globals.files.actions but the inerheritance only gets defined the first time you're sourcing fzf-lua.config.

That said, this is lua and everything is easy, you can "hack" your way to do what you want in a couple of lines:

local actions = require'fzf-lua.actions'
-- incase you want to use it somwhere
local old_file_edit_or_qf = actions.file_edit_or_qf 
actions.file_edit_or_qf = actions.file_edit

@ibhagwan ibhagwan added the question Further information is requested label Dec 25, 2021
@tamirzb
Copy link
Contributor Author

tamirzb commented Dec 25, 2021

Did you try this? Because it doesn't work for me.

Anyway, if we're talking hacks, the best thing I could come up with is:

local fzf_lua_config = require('fzf-lua.config')
local actions = require('fzf-lua.actions')
fzf_lua_config.globals.files.actions.default = actions.file_edit

But I'm afraid that as it relies a bit on fzf-lua's internals it might get broken one day by an update. Anyway I guess I'll use this for now, but if you ever get to it it would be nice to have a proper way to configure this.

And in any case thanks for replying quickly :)

@ibhagwan
Copy link
Owner

Did you try this? Because it doesn't work for me.

I did not try :-)

Anyway, if we're talking hacks, the best thing I could come up with is:

I have no plan on changing this anytime soon, this is a good enough "hack" IMO.

If I get inspired I might add a "global" action table, but that would require some other changes as there's already loads of configuration options as is.

@ibhagwan
Copy link
Owner

ibhagwan commented Feb 1, 2022

See #331, all you need to do one is delete all the individual provider action tables and use this instead:

require 'fzf-lua'.setup({
  actions = {
    files = {
      ["default"]       = actions.file_edit,
      ["ctrl-s"]        = actions.file_split,
      ["ctrl-v"]        = actions.file_vsplit,
      ["ctrl-t"]        = actions.file_tabedit,
      ["alt-q"]         = actions.file_sel_to_qf,
    },
  },
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants