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

Default horizontal split hotkey #331

Closed
yads opened this issue Jan 31, 2022 · 7 comments
Closed

Default horizontal split hotkey #331

yads opened this issue Jan 31, 2022 · 7 comments
Labels
enhancement New feature or request

Comments

@yads
Copy link

yads commented Jan 31, 2022

It seems like most plugins use Ctrl-x as the hotkey for opening up in a horizontal split. Whereas, this plugin uses Ctrl-s, is there an appetite for me submitting a PR making Ctrl-x as the default horizontal split command? Currently I'm using the following setup to have this functionality in my setup:

...
  git = {
    status = {
      actions = {
        ["ctrl-s"] = false,
        ["ctrl-x"] = fzf_actions.file_split
      }
    },
    bcommits = {
      actions = {
        ["ctrl-s"] = false,
        ["ctrl-x"] = fzf_actions.git_buf_split
      }
    }
  },
  grep = {
    actions = {
      ["ctrl-s"] = false,
      ["ctrl-x"] = fzf_actions.file_split
    }
  },
  args = {
    actions = {
      ["ctrl-r"] = fzf_actions.arg_del
    }
  },
  buffers = {
    actions = {
      ["ctrl-s"] = false,
      ["ctrl-x"] = fzf_actions.buf_split,
      ["ctrl-r"] = { fzf_actions.buf_del, fzf_actions.resume }
    }
  },
  lines = {
    actions = {
      ["ctrl-s"] = false,
      ["ctrl-x"] = fzf_actions.buf_split,
    }
  },
  blines = {
    actions = {
      ["ctrl-s"] = false,
      ["ctrl-x"] = fzf_actions.buf_split,
    }
  }
@ibhagwan
Copy link
Owner

Personally I feel ctrl-v makes more sense for vertical, as long as this is customizable I don’t see a need changing the default, especially since ctrl-v is also used in many other plugins.

@yads
Copy link
Author

yads commented Jan 31, 2022

Yes Ctrl-v is already split vertical, which matches other plugins. It's the horizontal key mapping that's at issue here. While yes it's customizable, it's not totally clear how to actually customize since there are a lot of places this needs to happen (i.e. you can't just say globally horizontal split is now Ctrl-X) and there are 3 different actions and it's again not clear which one needs to be used and where (buf_split, file_split, git_buf_split).

@ibhagwan
Copy link
Owner

Yes Ctrl-v is already split vertical, which matches other plugins. It's the horizontal key mapping that's at issue here. While yes it's customizable, it's not totally clear how to actually customize since there are a lot of places this needs to happen (i.e. you can't just say globally horizontal split is now Ctrl-X) and there are 3 different actions and it's again not clear which one needs to be used and where (buf_split, file_split, git_buf_split).

Oops I meant ctrl-s, the same still applies, I feel ctrl-x is more applicable for deleting stuff.

Perhaps this is better addressed in the wiki?

@ibhagwan
Copy link
Owner

I thought of something by better, I’ll just separate the default actions from the provider actions so you can at least make the change in one place instead.

@yads
Copy link
Author

yads commented Jan 31, 2022

I was thinking that as well, but when I was looking at the code I wasn't sure how easy that was to do.

@ibhagwan
Copy link
Owner

ibhagwan commented Feb 1, 2022

Latest commit adds this functinality, without losing the ability to override a single provider's actions you can now also modify the defaults for files and buffer actions (which individual providers inherit from).

These tables override the defaults completly so you have to define each action you're interested in (can also avoid the <bind> = false to disable a bind). For what you requested in the OP, you just need to define the below:

Note that individual provider actions table can override these so delete file.actions, buffers.actions, etc

require 'fzf-lua'.setup({
  actions = {
    files = {
      ["default"]       = fzf_lua.actions.file_edit_or_qf,
      ["ctrl-x"]        = fzf_lua.actions.file_split,
      ["ctrl-v"]        = fzf_lua.actions.file_vsplit,
      ["ctrl-t"]        = fzf_lua.actions.file_tabedit,
      ["alt-q"]         = fzf_lua.actions.file_sel_to_qf,
    },
    buffers = {
      ["default"]       = fzf_lua.actions.buf_edit,
      ["ctrl-x"]        = fzf_lua.actions.buf_split,
      ["ctrl-v"]        = fzf_lua.actions.buf_vsplit,
      ["ctrl-t"]        = fzf_lua.actions.buf_tabedit,
    }
  },
  buffers = {
    actions = {
      ["ctrl-r"] = { fzf_actions.buf_del, fzf_actions.resume }
    }
  },
})

@yads
Copy link
Author

yads commented Feb 1, 2022

That's awesome thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants