84 lines
2.1 KiB
Lua
84 lines
2.1 KiB
Lua
local function map(mode, lhs, rhs, opts)
|
|
local options = { noremap = true }
|
|
if opts then options = vim.tbl_extend('force', options, opts) end
|
|
vim.api.nvim_set_keymap(mode, lhs, rhs, options)
|
|
end
|
|
|
|
local function nmap(lhs, rhs, opts)
|
|
map('n', lhs, rhs, opts)
|
|
end
|
|
|
|
--- Mappings
|
|
-- Essentials
|
|
vim.g.mapleader = ' '
|
|
|
|
nmap(';', ':')
|
|
nmap(',,', '<C-^>')
|
|
nmap('<leader>w', ':w<CR>') -- TODO: stop this madness, :h autowrite
|
|
nmap('Q', ':q!<CR>')
|
|
nmap('<leader><space>', ':nohlsearch<CR>', { silent = true })
|
|
|
|
-- Convenience
|
|
nmap('yy', 'Y')
|
|
nmap('Y', 'y$')
|
|
nmap('N', 'Nzz')
|
|
nmap('n', 'nzz')
|
|
nmap('j', 'gj')
|
|
nmap('k', 'gk')
|
|
nmap('H', '^')
|
|
nmap('L', '$')
|
|
nmap('J', 'mzJ`z')
|
|
nmap('K', '<Nop>')
|
|
nmap('gQ', '<Nop>')
|
|
|
|
-- Tabs
|
|
nmap('<leader>t', ':tabnew<CR>')
|
|
nmap('<Tab>', ':tabnext<CR>')
|
|
nmap('<S-Tab>', ':tabprevious<CR>')
|
|
nmap('<leader>1', '1gt')
|
|
nmap('<leader>2', '2gt')
|
|
nmap('<leader>3', '3gt')
|
|
nmap('<leader>4', '4gt')
|
|
nmap('<leader>5', '5gt')
|
|
|
|
-- Visual mode
|
|
map('v', '.', ':normal .<CR>')
|
|
map('v', 'J', ':m \'>+1<CR>gv=gv')
|
|
map('v', 'K', ':m \'<-2<CR>gv=gv')
|
|
map('v', '<', '<gv')
|
|
map('v', '>', '>gv')
|
|
|
|
-- Telescope
|
|
nmap('<leader>ff', ':lua require("telescope.builtin").find_files({ hidden = true })<CR>')
|
|
-- TODO: change to Telescope
|
|
-- nmap('<leader>ft', ':Files ~/Tmp<CR>')
|
|
-- nmap('<leader>fo', ":call fzf#run(fzf#wrap(fzf#vim#with_preview({ 'source': 'fd . --type f --extension=md --follow --exclude .git ~/Syncthing/Obsidian/Personal' })))<CR>", { silent = true })
|
|
|
|
-- vim-easy-align
|
|
map('x', 'ga', ':EasyAlign<CR>') -- TODO: this should allow for gaip, but does not
|
|
map('v', 'ga', ':EasyAlign<CR>')
|
|
|
|
-- nvim-tree.lua
|
|
-- nmap('<leader>n', ':NERDTreeToggle<CR>')
|
|
-- nmap('<leader>N', ':NERDTreeFind<CR>')
|
|
nmap('<leader>n', ':NvimTreeToggle<CR>')
|
|
nmap('<leader>N', ':NvimTreeFindFile<CR>')
|
|
|
|
-- glow.vim
|
|
nmap('<leader>p', ':Glow<CR>')
|
|
|
|
-- fugitive.vim
|
|
nmap('<leader>ga',':Gwrite<CR>')
|
|
nmap('<leader>gs',':Git<CR>')
|
|
nmap('<leader>gb',':Git blame<CR>')
|
|
|
|
-- rails-vim
|
|
nmap('<leader>a', ':A<CR>')
|
|
|
|
-- test
|
|
nmap('<leader>r', ':TestFile<CR>')
|
|
nmap('<leader>R', ':TestSuite<CR>')
|
|
|
|
-- CtrlSF
|
|
nmap('<C-f>', '<Plug>CtrlSFPrompt')
|