Skip to content

Commit

Permalink
added the ability to bulk config files|buffers actions (closes #331)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibhagwan committed Feb 1, 2022
1 parent 3696489 commit 2aa5bd3
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 113 deletions.
68 changes: 33 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,29 @@ require'fzf-lua'.setup {
["shift-up"] = "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 = {
-- 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-t"] = actions.file_tabedit,
["alt-q"] = actions.file_sel_to_qf,
},
buffers = {
["default"] = actions.buf_edit,
["ctrl-s"] = actions.buf_split,
["ctrl-v"] = actions.buf_vsplit,
["ctrl-t"] = actions.buf_tabedit,
}
},
fzf_opts = {
-- options are sent as `<left>=<right>`
-- set to `false` to remove a flag
Expand Down Expand Up @@ -410,17 +433,9 @@ require'fzf-lua'.setup {
rg_opts = "--color=never --files --hidden --follow -g '!.git'",
fd_opts = "--color=never --type f --hidden --follow --exclude .git",
actions = {
-- set bind to 'false' to disable an action
-- 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-t"] = actions.file_tabedit,
["alt-q"] = actions.file_sel_to_qf,
-- inherits from 'actions.files', here we can override
-- or set bind to 'false' to disable a default action
["default"] = actions.file_edit,
-- custom actions are available too
["ctrl-y"] = function(selected) print(selected[1]) end,
}
Expand All @@ -445,13 +460,9 @@ require'fzf-lua'.setup {
git_icons = true,
color_icons = true,
actions = {
["default"] = actions.file_edit_or_qf,
["ctrl-s"] = actions.file_split,
["ctrl-v"] = actions.file_vsplit,
["ctrl-t"] = actions.file_tabedit,
["alt-q"] = actions.file_sel_to_qf,
["right"] = { actions.git_unstage, actions.resume },
["left"] = { actions.git_stage, actions.resume },
-- actions inherit from 'actions.files' and merge
["right"] = { actions.git_unstage, actions.resume },
["left"] = { actions.git_stage, actions.resume },
},
},
commits = {
Expand Down Expand Up @@ -514,7 +525,7 @@ require'fzf-lua'.setup {
args = {
prompt = 'Args❯ ',
files_only = true,
-- added on top of regular file actions
-- actions inherit from 'actions.files' and merge
actions = { ["ctrl-x"] = actions.arg_del }
},
oldfiles = {
Expand All @@ -527,10 +538,7 @@ require'fzf-lua'.setup {
color_icons = true, -- colorize file|git icons
sort_lastused = true, -- sort buffers() by last used
actions = {
["default"] = actions.buf_edit,
["ctrl-s"] = actions.buf_split,
["ctrl-v"] = actions.buf_vsplit,
["ctrl-t"] = actions.buf_tabedit,
-- actions inherit from 'actions.buffers' and merge
-- by supplying a table of functions we're telling
-- fzf-lua to not close the fzf window, this way we
-- can resume the buffers picker on the same window
Expand All @@ -550,12 +558,7 @@ require'fzf-lua'.setup {
["--nth"] = '2..',
["--tiebreak"] = 'index',
},
actions = {
["default"] = actions.buf_edit,
["ctrl-s"] = actions.buf_split,
["ctrl-v"] = actions.buf_vsplit,
["ctrl-t"] = actions.buf_tabedit,
}
-- actions inherit from 'actions.buffers'
},
blines = {
previewer = "builtin", -- set to 'false' to disable
Expand All @@ -568,12 +571,7 @@ require'fzf-lua'.setup {
["--with-nth"] = '2..',
["--tiebreak"] = 'index',
},
actions = {
["default"] = actions.buf_edit,
["ctrl-s"] = actions.buf_split,
["ctrl-v"] = actions.buf_vsplit,
["ctrl-t"] = actions.buf_tabedit,
}
-- actions inherit from 'actions.buffers'
},
colorschemes = {
prompt = 'Colorschemes❯ ',
Expand Down
68 changes: 33 additions & 35 deletions doc/fzf-lua.txt
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,29 @@ Consult the list below for available settings:
["shift-up"] = "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 = {
-- 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-t"] = actions.file_tabedit,
["alt-q"] = actions.file_sel_to_qf,
},
buffers = {
["default"] = actions.buf_edit,
["ctrl-s"] = actions.buf_split,
["ctrl-v"] = actions.buf_vsplit,
["ctrl-t"] = actions.buf_tabedit,
}
},
fzf_opts = {
-- options are sent as `<left>=<right>`
-- set to `false` to remove a flag
Expand Down Expand Up @@ -449,17 +472,9 @@ Consult the list below for available settings:
rg_opts = "--color=never --files --hidden --follow -g '!.git'",
fd_opts = "--color=never --type f --hidden --follow --exclude .git",
actions = {
-- set bind to 'false' to disable an action
-- 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-t"] = actions.file_tabedit,
["alt-q"] = actions.file_sel_to_qf,
-- inherits from 'actions.files', here we can override
-- or set bind to 'false' to disable a default action
["default"] = actions.file_edit,
-- custom actions are available too
["ctrl-y"] = function(selected) print(selected[1]) end,
}
Expand All @@ -484,13 +499,9 @@ Consult the list below for available settings:
git_icons = true,
color_icons = true,
actions = {
["default"] = actions.file_edit_or_qf,
["ctrl-s"] = actions.file_split,
["ctrl-v"] = actions.file_vsplit,
["ctrl-t"] = actions.file_tabedit,
["alt-q"] = actions.file_sel_to_qf,
["right"] = { actions.git_unstage, actions.resume },
["left"] = { actions.git_stage, actions.resume },
-- actions inherit from 'actions.files' and merge
["right"] = { actions.git_unstage, actions.resume },
["left"] = { actions.git_stage, actions.resume },
},
},
commits = {
Expand Down Expand Up @@ -553,7 +564,7 @@ Consult the list below for available settings:
args = {
prompt = 'Args❯ ',
files_only = true,
-- added on top of regular file actions
-- actions inherit from 'actions.files' and merge
actions = { ["ctrl-x"] = actions.arg_del }
},
oldfiles = {
Expand All @@ -566,10 +577,7 @@ Consult the list below for available settings:
color_icons = true, -- colorize file|git icons
sort_lastused = true, -- sort buffers() by last used
actions = {
["default"] = actions.buf_edit,
["ctrl-s"] = actions.buf_split,
["ctrl-v"] = actions.buf_vsplit,
["ctrl-t"] = actions.buf_tabedit,
-- actions inherit from 'actions.buffers' and merge
-- by supplying a table of functions we're telling
-- fzf-lua to not close the fzf window, this way we
-- can resume the buffers picker on the same window
Expand All @@ -589,12 +597,7 @@ Consult the list below for available settings:
["--nth"] = '2..',
["--tiebreak"] = 'index',
},
actions = {
["default"] = actions.buf_edit,
["ctrl-s"] = actions.buf_split,
["ctrl-v"] = actions.buf_vsplit,
["ctrl-t"] = actions.buf_tabedit,
}
-- actions inherit from 'actions.buffers'
},
blines = {
previewer = "builtin", -- set to 'false' to disable
Expand All @@ -607,12 +610,7 @@ Consult the list below for available settings:
["--with-nth"] = '2..',
["--tiebreak"] = 'index',
},
actions = {
["default"] = actions.buf_edit,
["ctrl-s"] = actions.buf_split,
["ctrl-v"] = actions.buf_vsplit,
["ctrl-t"] = actions.buf_tabedit,
}
-- actions inherit from 'actions.buffers'
},
colorschemes = {
prompt = 'Colorschemes❯ ',
Expand Down
Loading

0 comments on commit 2aa5bd3

Please sign in to comment.