diff --git a/vimrc b/vimrc index ca6bddd..15fe17e 100644 --- a/vimrc +++ b/vimrc @@ -135,15 +135,49 @@ nnoremap 1 :set relativenumber! nnoremap m :marks nnoremap v :vsplit nnoremap s :split -" a* currently conflicts with LspCodeAction + +" Git mappings +" +" Copy Git permalink to clipboard for either current line or range +function! CopyGitURLToLineOrRange() range + if a:firstline == a:lastline + execute ".GBrowse!" + else + execute a:firstline . "," . a:lastline . "GBrowse!" + endif +endfunction + +function! OpenGitURLToLineOrRange() range + if a:firstline == a:lastline + execute ".GBrowse" + else + execute a:firstline . "," . a:lastline . "GBrowse" + endif +endfunction + nnoremap ab :Gblame nnoremap as :Gstatus nnoremap ac :Commits nnoremap ah :GitGutterLineHighlightsToggle +nnoremap ay :call CopyGitURLToLineOrRange() +nnoremap ao :call OpenGitURLToLineOrRange() + " yank filename of current buffer: -nmap f :let @" = expand("%") +function! CopyToDefaultRegister() + let @" = expand("%:p") + echom expand("%:p") +endfunction +nmap fy :call CopyToDefaultRegister() " and into + register: -nmap F :let @+ = expand("%") +function! CopyToSystemClipboard() + let @* = expand("%:p") + let @+ = expand("%:p") + echom expand("%:p") +endfunction +nmap fY :call CopyToSystemClipboard() + +" ctrl-v to paste from system clipboard in insert mode: +inoremap "*Pa function! ToggleQuickFix() if empty(filter(getwininfo(), 'v:val.quickfix')) @@ -246,16 +280,6 @@ xmap ah (GitGutterTextObjectOuterVisual) " vim-fugitive packadd! vim-fugitive " https://github.com/tpope/vim-fugitive.git -" Copy Git permalink to clipboard for either current line or range -function! CopyGitURLToLineOrRange() range - if a:firstline == a:lastline - execute ".GBrowse!" - else - execute a:firstline . "," . a:lastline . "GBrowse!" - endif -endfunction -map u :call CopyGitURLToLineOrRange() - " vim-go " Doesn't work in after/ftplugin/go.vim: let g:go_def_mapping_enabled = 0