Add descriptions to Harpoon and Cheat Sheet key mappings and include Dressing plugin in custom plugins

This commit is contained in:
PeteChu 2023-04-05 15:16:52 +07:00
parent b366efced2
commit e7b27047e2
4 changed files with 44 additions and 4 deletions

View File

@ -1,8 +1,8 @@
local mark = require("harpoon.mark")
local ui = require("harpoon.ui")
vim.keymap.set("n", "<leader>ha", mark.add_file)
vim.keymap.set("n", "<leader>ha", mark.add_file, { desc = "[H]arpoon [A]dd" })
vim.keymap.set("n", "<C-e>", ui.toggle_quick_menu)
vim.keymap.set("n", "<leader>hn", function() ui.nav_next() end)
vim.keymap.set("n", "<leader>hp", function() ui.nav_prev() end)
vim.keymap.set("n", "<leader>hn", function() ui.nav_next() end, { desc = "[H]arpoon [N]ext" })
vim.keymap.set("n", "<leader>hp", function() ui.nav_prev() end, { desc = "[H]arpoon [P]revious" })

View File

@ -50,6 +50,9 @@ keymap('n', '<leader>Y', "\"+Y", { desc = "[Y]ank to clipboard" })
-- Open folder in workspace in tmux session
keymap("n", "<leader>op", "<cmd>silent !tmux neww tmux-sessionizer<CR>", { desc = "[O]pen [P]roject" })
-- Search cheat sheet
keymap("n", "<leader>ch", "<cmd>silent !tmux neww tmux-cht.sh<CR>", { desc = "[C]heat [S]heet" })
-- replace selected word in the file
keymap("n", "<leader>R", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]], { desc = "[R]eplace words in the file" })

36
after/plugin/redir.vim Normal file
View File

@ -0,0 +1,36 @@
function! Redir(cmd, rng, start, end)
for win in range(1, winnr('$'))
if getwinvar(win, 'scratch')
execute win . 'windo close'
endif
endfor
if a:cmd =~ '^!'
let cmd = a:cmd =~' %'
\ ? matchstr(substitute(a:cmd, ' %', ' ' . shellescape(escape(expand('%:p'), '\')), ''), '^!\zs.*')
\ : matchstr(a:cmd, '^!\zs.*')
if a:rng == 0
let output = systemlist(cmd)
else
let joined_lines = join(getline(a:start, a:end), '\n')
let cleaned_lines = substitute(shellescape(joined_lines), "'\\\\''", "\\\\'", 'g')
let output = systemlist(cmd . " <<< $" . cleaned_lines)
endif
else
redir => output
execute a:cmd
redir END
let output = split(output, "\n")
endif
vnew
let w:scratch = 1
setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile
call setline(1, output)
endfunction
" This command definition includes -bar, so that it is possible to "chain" Vim commands.
" Side effect: double quotes can't be used in external commands
command! -nargs=1 -complete=command -bar -range Redir silent call Redir(<q-args>, <range>, <line1>, <line2>)
" This command definition doesn't include -bar, so that it is possible to use double quotes in external commands.
" Side effect: Vim commands can't be "chained".
command! -nargs=1 -complete=command -range Redir silent call Redir(<q-args>, <range>, <line1>, <line2>)

View File

@ -7,5 +7,6 @@ return {
'mbbill/undotree',
'famiu/bufdelete.nvim',
'ThePrimeagen/harpoon',
'ThePrimeagen/vim-be-good'
'ThePrimeagen/vim-be-good',
'stevearc/dressing.nvim'
}