Skip to content

Mappings

Λlisue edited this page Jan 7, 2025 · 5 revisions

Default mappings

Key Mapping Description
<C-t>
<Plug>(fall-list-first)
Move the cursor to the first item in the list component
<C-g>
<Plug>(fall-list-last)
Move the cursor to the last item in the list component
<C-p>
<Plug>(fall-list-prev)
Move the cursor to the previous item in the list component
<C-n>
<Plug>(fall-list-next)
Move the cursor to the next item in the list component
<C-u>
<Plug>(fall-list-prev:scroll)
Move the cursor up in the list component by the value of &scroll
<C-d>
<Plug>(fall-list-next:scroll)
Move the cursor down in the list component by the value of &scroll
<PageUp>
<Plug>(fall-list-left)
Scroll the content of the list component to the left
<PageDown>
<Plug>(fall-list-right)
Scroll the content of the list component to the right
<S-PageUp>
<Plug>(fall-list-left:scroll)
Scroll the content of the list component to the left by &scroll
<S-PageDown>
<Plug>(fall-list-right:scroll)
Scroll the content of the list component to the right by &scroll
<C-,>
<Plug>(fall-select)
Select the current item in the list component
<C-.>
<Plug>(fall-select-all)
Select all items in the list component
<C-j>
<Plug>(fall-select)<Plug>(fall-list-next)
Select and move the cursor to the next item in the list component
<C-k>
<Plug>(fall-list-prev)<Plug>(fall-select)
Move the cursor to the previous item and select it in the list component
<M-Home>
<Plug>(fall-preview-first)
Move the cursor to the first line in the preview component
<M-End>
<Plug>(fall-preview-last)
Move the cursor to the last line in the preview component
<M-Up>
<Plug>(fall-preview-prev)
Move the cursor to the previous line in the preview component
<M-Down>
<Plug>(fall-preview-next)
Move the cursor to the next line in the preview component
<S-Up>
<Plug>(fall-preview-prev:scroll)
Move the cursor up in the preview component by the value of &scroll
<S-Down>
<Plug>(fall-preview-next:scroll)
Move the cursor down in the preview component by the value of &scroll
<M-Left>
<Plug>(fall-preview-left)
Scroll the content of the preview component to the left
<M-Right>
<Plug>(fall-preview-right)
Scroll the content of the preview component to the right
<S-Left>
<Plug>(fall-preview-left:scroll)
Scroll the content of the preview component to the left by &scroll
<S-Right>
<Plug>(fall-preview-right:scroll)
Scroll the content of the preview component to the right by &scroll
<Tab>
<Plug>(fall-action-select)
Open an action selector to execute an action
<F1>
<Plug>(fall-help)
Open or close the help window
<S-Home>
<Plug>(fall-help-prev)
Go to the previous page in the help window
<S-End>
<Plug>(fall-help-next)
Go to the next page in the help window
<F2>
<Plug>(fall-switch-matcher-next)
Switch to the next matcher in the current picker
<F3>
<Plug>(fall-switch-sorter-next)
Switch to the next sorter in the current picker
<F4>
<Plug>(fall-switch-renderer-next)
Switch to the next renderer in the current picker
<F5>
<Plug>(fall-switch-previewer-next)
Switch to the next previewer in the current picker

The default mappings are optimized for full keyboard usage, following a design philosophy where list operations are centered around the home row, preview operations are handled near the arrow keys, and other actions are assigned to function keys. The default mappings are defined in ./plugin/fall/mapping.vim.

Plug mappings

Plug Mapping Description
<Plug>(fall-list-first) Moves the cursor to the first item in the list.
<Plug>(fall-list-last) Moves the cursor to the last item in the list.
<Plug>(fall-list-prev) Moves the cursor to the previous item in the list.
<Plug>(fall-list-next) Moves the cursor to the next item in the list.
<Plug>(fall-list-prev:scroll) Moves the cursor up by the value of &scroll in the list.
<Plug>(fall-list-next:scroll) Moves the cursor down by the value of &scroll in the list.
<Plug>(fall-list-left) Scrolls the list content to the left.
<Plug>(fall-list-right) Scrolls the list content to the right.
<Plug>(fall-list-left:scroll) Scrolls the list content to the left by the value of &scroll.
<Plug>(fall-list-right:scroll) Scrolls the list content to the right by the value of &scroll.
<Plug>(fall-select) Selects the currently highlighted item in the list.
<Plug>(fall-select-all) Selects all items in the list.
<Plug>(fall-switch-matcher-first) Switches to the first matcher.
<Plug>(fall-switch-matcher-last) Switches to the last matcher.
<Plug>(fall-switch-matcher-prev) Switches to the previous matcher.
<Plug>(fall-switch-matcher-next) Switches to the next matcher.
<Plug>(fall-switch-sorter-first) Switches to the first sorter.
<Plug>(fall-switch-sorter-last) Switches to the last sorter.
<Plug>(fall-switch-sorter-prev) Switches to the previous sorter.
<Plug>(fall-switch-sorter-next) Switches to the next sorter.
<Plug>(fall-switch-renderer-first) Switches to the first renderer.
<Plug>(fall-switch-renderer-last) Switches to the last renderer.
<Plug>(fall-switch-renderer-prev) Switches to the previous renderer.
<Plug>(fall-switch-renderer-next) Switches to the next renderer.
<Plug>(fall-switch-previewer-first) Switches to the first previewer.
<Plug>(fall-switch-previewer-last) Switches to the last previewer.
<Plug>(fall-switch-previewer-prev) Switches to the previous previewer.
<Plug>(fall-switch-previewer-next) Switches to the next previewer.
<Plug>(fall-preview-first) Moves the preview cursor to the first line.
<Plug>(fall-preview-last) Moves the preview cursor to the last line.
<Plug>(fall-preview-prev) Moves the preview cursor to the previous line.
<Plug>(fall-preview-next) Moves the preview cursor to the next line.
<Plug>(fall-preview-prev:scroll) Moves the preview cursor up by the value of &scroll.
<Plug>(fall-preview-next:scroll) Moves the preview cursor down by the value of &scroll.
<Plug>(fall-preview-left) Scrolls the preview content to the left.
<Plug>(fall-preview-right) Scrolls the preview content to the right.
<Plug>(fall-preview-left:scroll) Scrolls the preview content to the left by the value of &scroll.
<Plug>(fall-preview-right:scroll) Scrolls the preview content to the right by the value of &scroll.
<Plug>(fall-help) Toggles the help component visibility.
<Plug>(fall-help-prev) Moves to the previous page in the help component.
<Plug>(fall-help-next) Moves to the next page in the help component.
<Plug>(fall-action-select) Opens the action selector for the current item.

The plug mappings are defined in ./plugin/fall/mapping.vim.

Configuration

Use the FallPickerEnter:{name} autocmd to customize key mappings for the picker. All mappings defined during this autocmd will be automatically discarded, and the original mappings will be restored once the picker is closed.

For example:

Vim script
" These mappings will be available for all pickers.
function! s:fall_mappings() abort
  " Use <Up> and <Down> to navigate the list component instead of <C-p> and <C-n>.
  cnoremap <silent> <Up> <Plug>(fall-list-prev)
  cnoremap <silent> <Down> <Plug>(fall-list-next)
  " Disable <PageUp> and <PageDown> horizontal scrolling mappings in the list component.
  cnoremap <silent> <PageUp> <Nop>
  cnoremap <silent> <PageDown> <Nop>
endfunction

" These mappings will only be available for the "file" picker.
function! s:fall_mappings_file() abort
  " Directly invoke open-related actions for specific key mappings.
  cnoremap <silent> <C-e> <Cmd>call fall#action('open')<CR>
  cnoremap <silent> <C-x> <Cmd>call fall#action('open:split')<CR>
  cnoremap <silent> <C-v> <Cmd>call fall#action('open:vsplit')<CR>
  cnoremap <silent> <C-t> <Cmd>call fall#action('open:tabedit')<CR>
endfunction

augroup my_fall_mapping
  autocmd!
  " Apply custom mappings for all pickers.
  autocmd User FallPickerEnter:* call s:fall_mappings()
  " Apply custom mappings specifically for the "file" picker.
  autocmd User FallPickerEnter:file call s:fall_mappings_file()
augroup END
Lua (by ChatGPT)
-- Function to define mappings for all pickers
local function fall_mappings()
  local opts = { noremap = true, silent = true }

  -- Use <Up> and <Down> to navigate the list component instead of <C-p> and <C-n>
  vim.keymap.map("c", "<Up>", "<Plug>(fall-list-prev)", opts)
  vim.keymap.map("c", "<Down>", "<Plug>(fall-list-next)", opts)

  -- Disable <PageUp> and <PageDown> horizontal scrolling mappings in the list component.
  vim.keymap.map("c", "<PageUp>)", "<Nop>", opts)
  vim.keymap.map("c", "<PageDown>", "<Nop>", opts)
end

-- Function to define mappings specific to the "file" picker
local function fall_mappings_file()
  local opts = { noremap = true, silent = true }

  -- Directly invoke open-related actions
  vim.keymap.map("c", "<C-e>", "<Cmd>call fall#action('open')<CR>", opts)
  vim.keymap.map("c", "<C-x>", "<Cmd>call fall#action('open:split')<CR>", opts)
  vim.keymap.map("c", "<C-v>", "<Cmd>call fall#action('open:vsplit')<CR>", opts)
  vim.keymap.map("c", "<C-t>", "<Cmd>call fall#action('open:tabedit')<CR>", opts)
end

vim.api.nvim_create_augroup("MyFallMappings", { clear = true })
vim.api.nvim_create_autocmd("User", {
  group = "MyFallMappings",
  pattern = "FallPickerEnter:*",
  callback = fall_mappings,
})
vim.api.nvim_create_autocmd("User", {
  group = "MyFallMappings",
  pattern = "FallPickerEnter:file",
  callback = fall_mappings_file,
})

As shown in the example above, users can disable specific default mappings by mapping to <Nop>. If you want to completely disable the default mappings, you can use the g:fall_disable_default_mapping global variable as follows:

Vim
let g:fall_disable_default_mapping = v:true
Lua (by ChatGPT)
vim.g.fall_disable_default_mapping = true
Clone this wiki locally