home: vim: use 'which-key'

This commit is contained in:
Bruno BELANYI 2022-02-26 14:44:52 +01:00
parent fa836d7df9
commit 19889f4cbf
5 changed files with 54 additions and 21 deletions

View file

@ -1,10 +0,0 @@
" Visual bindings for merging diffs as in normal mode
xnoremap dp :diffput<cr>
xnoremap do :diffget<cr>
" Open status window
nnoremap <Leader>gs :Gstatus<CR>
" Open diff view of current buffer: the up/left window is the current index
nnoremap <Leader>gd :Gdiffsplit!<CR>
" Open current file log in new tab, populate its location list with history
nnoremap <Leader>gl :sp<CR><C-w>T:Gllog --follow -- %:p<CR>

View file

@ -1,5 +1,13 @@
" Only git-tracked files, Vim needs to be in a Git repository
nnoremap <Leader>ff :GFiles<CR>
lua << EOF
local wk = require("which-key")
" Currently open buffers
nnoremap <Leader>fb :Buffers<CR>
local keys = {
f = {
name = "Fuzzy finder",
b = { "<cmd>Buffers<CR>", "Open buffers" },
f = { "<cmd>GFiles<CR>", "Git tracked files" },
},
}
wk.register(keys, { prefix = "<leader>" })
EOF

View file

@ -0,0 +1,20 @@
lua << EOF
local wk = require("which-key")
local keys = {
d = {
name = "Merging diff hunks",
o = { "<cmd>diffget<CR>", "Use this buffer's change", mode="x" },
p = { "<cmd>diffput<CR>", "Accept other buffer change", mode="x" },
},
["<leader>g"] = {
name = "Git",
d = { "<cmd>Gdiffsplit<CR>", "Current buffer diff" },
l = { "<cmd>:sp<CR><C-w>T:Gllog --follow -- %:p<CR>", "Current buffer log" },
m = { "<Plug>(git-messenger)", "Current line blame" },
s = { "<cmd>Gstatus<CR>", "Status" },
},
}
wk.register(keys)
EOF

View file

@ -1,5 +1,10 @@
" Run make silently, then skip the 'Press ENTER to continue'
noremap <Leader>m :silent! :make! \| :redraw!<CR>
lua << EOF
local wk = require("which-key")
" Remove search-highlighting
noremap <Leader><Leader> :nohls<CR>
local keys = {
m = { "<cmd>silent! :make! | :redraw!<CR>", "Run make" },
["<leader>"] = { "<cmd>nohls<CR>", "Clear search highlight" },
}
wk.register(keys, { prefix = "<leader>" })
EOF

View file

@ -1,3 +1,13 @@
" Toggle quick-fix and location lists
nmap <Leader>tf <Plug>(qf_qf_toggle)
nmap <Leader>tl <Plug>(qf_loc_toggle)
lua << EOF
local wk = require("which-key")
local keys = {
["t"] = {
name = "Toggle",
f = { "<Plug>(qf_qf_toggle)", "Toggle quickfix list" },
l = { "<Plug>(qf_loc_toggle)", "Toggle location list" },
},
}
wk.register(keys, { prefix = "<leader>" })
EOF