You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

86 lines
5.5 KiB

-- This file allows binding arbitrary keys in vim.
-- If a keymap is tied to a specific plugin, it should generally be specified
-- in the plugins file attached to that plugin.
--
-- When making a binding, group, etc, the key to bind to shoudl be specified
-- as an array. However, as long as _each character_ represents a single keypress
-- the key can be specified as a string. E.g., `key = 'jj'` and `key = { 'j', 'j' }`
-- are equivalent. However, `key = { '<A-h>' }` would be parsed as
-- `key = {'<', 'A', '-', 'h', '>'}
--
-- There are four main types of keymap bindings:
-- * Group: This only serves to provide a label for the keymap legend for
-- keys under a prefix. (e.g., label for `f` when we have bindings
-- for `fg` and `fh`).
-- `{ mode = 'n', key = { '<leader>', 'p' }, group = true, label = "Sample Group" }`
-- * Virtual: This registers a label in the keymap legend, but doesn't
-- actually change the binding of the key.
-- `{ mode = 'n', key = { 'g', 'q' }, virtual = true, description = 'reformat text, wrapping line length' }`
-- * Hidden: The key is bound through normal vim functionality, bypassing the
-- keymap legend so that the key will not show up in the legend.
-- `{ mode = 'n', key = { 'h' }, map = ':echo "Hello, world!'"', label = 'Hello world button', hidden = true
-- `{ mode = 'n', key = 'aaa', map = ':echo "Hello, world!'"', label = 'Hello world button', hidden = true}
-- * Normal: The key is bound, and the key is shown in the legend.
-- `{ mode = 'n', key = { 'j' }, map = ':echo "Hello, world!'"', label = 'Hello world button' }
-- `{ mode = 'n', key = 'aaa', map = ':echo "Hello, world!'"', label = 'Hello world button' }
return {
-- { mode = 'n', key = { '<F5>' }, map = ':call SynStack()<CR>', label = 'show syntax token' },
{ mode = 'n', key = { '<F49>' }, map = ':lua nukevim:help()<CR>', label = 'help' },
-- Provide labels for the main leader groups
{ mode = 'n', key = { '<leader>', 'c' }, group = true, label = 'code' },
{ mode = 'n', key = { '<leader>', 'd' }, group = true, label = 'dev tools' },
{ mode = 'v', key = { '<leader>', 'd' }, group = true, label = 'dev tools' },
{ mode = 'n', key = { '<leader>', 'g' }, group = true, label = 'git' },
{ mode = 'n', key = { '<leader>', 'l' }, group = true, label = 'language tools' },
{ mode = 'n', key = { '<leader>', 'w' }, group = true, label = 'workspace' },
-- A group label for the key legend
{ mode = 'n', key = 'z', group = true, label = 'text operations' },
-- A "virtual" key to add an existing vim bind to the legend
{ mode = 'n', key = 'z=', virtual = true, description = 'check spelling' },
-- Escape from insert with jj
{ mode = 'i', key = 'j', group = true, label = 'j' },
{ mode = 'i', key = 'jj', map = '<Esc>', label = 'escape' },
-- Dehighlight and recompute syntax highlighting
{ mode = 'n', key = { '<Space>', '<Space>' }, map = ':silent noh <Bar>echo<cr>:syn sync fromstart<CR>', label = 'refresh' },
-- Directory browsing
{ mode = 'n', key = { '-' }, virtual = true, label = "browse files" },
-- Move between buffers
{ mode = 'n', key = { '<A-h>' }, map = '<C-W>h', label = 'select buffer left' },
{ mode = 'n', key = { '<A-j>' }, map = '<C-W>j', label = 'select buffer down' },
{ mode = 'n', key = { '<A-k>' }, map = '<C-W>k', label = 'select buffer up' },
{ mode = 'n', key = { '<A-l>' }, map = '<C-W>l', label = 'select buffer right' },
{ mode = 'i', key = { '<A-h>' }, map = '<C-O><C-W>h', label = 'select buffer left', hidden = true },
-- { mode = 'i', key = { '<A-j>' }, map = '<C-O><C-W>j', label = 'select buffer down', hidden = true },
-- { mode = 'i', key = { '<A-k>' }, map = '<C-O><C-W>k', label = 'select buffer up', hidden = true },
{ mode = 'i', key = { '<A-j>' }, map = '<C-O><C-W>j', label = 'select buffer down', hidden = true, options = { silent = true }},
{ mode = 'i', key = { '<A-k>' }, map = '<C-O><C-W>k', label = 'select buffer up', hidden = true, options = { silent = true }},
{ mode = 'i', key = { '<A-l>' }, map = '<C-O><C-W>l', label = 'select buffer right', hidden = true },
-- Tab navigation
{ mode = 'n', key = { '<C-k>' }, map = ':tabnew<CR>', label = 'new tab' },
{ mode = 'n', key = { '<C-l>' }, map = ':tabnext<CR>', label = 'next tab' },
{ mode = 'i', key = { '<C-l>' }, map = '<ESC>:tabnext<CR>', label = 'next tab' },
{ mode = 'n', key = { '<C-h>' }, map = ':tabprev<CR>', label = 'previous tab' },
{ mode = 'i', key = { '<C-h>' }, map = '<ESC>:tabprev<CR>', label = 'previous tab' },
-- Scroll autocomplete
{ mode = 'i', key = { '<C-j>' }, map = '<C-n>', label = 'next autocomplete', hidden = true },
{ mode = 'i', key = { '<C-k>' }, map = '<C-p>', label = 'previous autocomplete', hidden = true },
-- Terminal bindings
{ mode = 't', key = { '<A-h>' }, map = '<C-\\><C-n><C-W>h', label = 'select buffer left', hidden = true },
{ mode = 't', key = { '<A-j>' }, map = '<C-\\><C-n><C-W>j', label = 'select buffer down', hidden = true },
{ mode = 't', key = { '<A-k>' }, map = '<C-\\><C-n><C-W>k', label = 'select buffer up', hidden = true },
{ mode = 't', key = { '<A-l>' }, map = '<C-\\><C-n><C-W>l', label = 'select buffer right', hidden = true },
{ mode = 't', key = { '<C-h>' }, map = '<C-\\><C-n>:tabprev<CR>', label = 'select buffer right', hidden = true },
{ mode = 't', key = { '<C-l>' }, map = '<C-\\><C-n>:tabnext<CR>', label = 'select buffer right', hidden = true },
{ mode = 't', key = { 'j', 'j' }, map = '<C-\\><C-n>', label = 'escape', hidden = true },
}