1
0
mirror of https://git.decapod.one/brethil/dotfiles synced 2024-11-09 13:31:31 +01:00
dotfiles/vim/shortcuts.vim

167 lines
4.7 KiB
VimL
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""" Leader shortcuts
let mapleader = ','
" also use space as leader
map <Space> <leader>
nmap <leader>w :w!<CR>
command! W execute 'w !sudo tee % > /dev/null' <bar> edit!
" nmap <leader>W :w!<CR>
" config editing
map <leader>e :vsplit ~/.vimrc<CR>
map <leader>ef :vsplit $DOTFILES/vim/functions.vim<CR>
map <leader>ec :vsplit $DOTFILES/vim/plugins_config.vim<CR>
map <leader>es :vsplit $DOTFILES/vim/shortcuts.vim<CR>
map <leader>ep :vsplit $DOTFILES/vim/plugs.vim<CR>
" Quickly open a markdown buffer for scribble
map <leader>x :e ~/buffer.md<CR>
map <leader>xx :e ~/projects/work/buffer.md<CR>
" Toggle paste mode on and off
nmap <leader>pp :setlocal paste!<CR>
" Re-select the text block just pasted
nnoremap <Leader>vv V`]
" Easy tab navigation with <leader>T
nmap <leader>Tn :tabnext<CR>
nmap <leader>TN :tabnew<CR>
nmap <leader>Tp :tabprev<CR>
nmap <leader>Tc :tabclose<CR>
nmap <C-W>n :tabnext<CR>
nmap <C-W>p :tabprev<CR>
nmap <C-W>N :tabnew<CR>
" move betweween functions/methods/classes definition,
" [m moves to the start of the previous method, ]m to the start of the next
" zz centers the result
map <Leader>] ]mzz
map <Leader>[ [mzz
" open quickfix
nmap <leader>cc :botright cope<CR>
" open loclist
nmap <leader>ll :botright lope<CR>
" close quickfix (also see <leader>C below)
nmap <leader>cx :hide<CR>
nmap <leader>co ggVGy:tabnew<CR>:set syntax=qf<CR>pgg
" next cope error
map <leader>N :cnext<CR>
" previous cope error
map <leader>P :cprevious<CR>
"disable highlighting current search word
map <silent> <leader><CR> :noh<CR>
map <leader>S :setlocal spell!<CR>
nnoremap <leader>M :bel copen<bar>silent make <bar>redraw!<CR>
nnoremap <leader>wz :call WinZoomToggle()<CR>
nnoremap <leader>q :close<CR>
nnoremap <leader>B :Bclose<CR>
nnoremap <leader>Q :close!<CR>
nnoremap <leader>k :Rg<CR>
"" Fugitive
nnoremap <leader>/ :vert Git<CR>
nnoremap <leader>\ :0Git<CR>
nnoremap <leader>d :Gvdiffsplit<CR>
nnoremap <leader>b :Git blame<CR>
nnoremap <leader>gp :Git push<CR>
nnoremap <leader>gl :Commits<CR>
nnoremap <leader>gL :BCommits<CR>
nnoremap <leader>gc :Git commit<CR>
nnoremap <leader>gpf :Git push --force-with-lease<CR>
"" Gitutter
nnoremap <leader>u :GitGutterBufferToggle<CR>
nnoremap <leader>L :GitGutterLineHighlightsToggle<CR>
nnoremap <leader>gp :GitGutterPrevHunk<CR>
nnoremap <leader>gn :GitGutterNextHunk<CR>
nnoremap <leader>gs :GitGutterStageHunk<CR>
nnoremap <leader>gu :GitGutterUndoHunk<CR>
"" Coverage Highlight
nnoremap <leader>H :HighlightCoverageForAll<CR>
" Ale
nmap <silent> <C-k> <Plug>(ale_previous_wrap)
nmap <silent> <C-j> <Plug>(ale_next_wrap)
nmap <leader>R :ALERepeatSelection<CR>
nmap <leader>sv :ALEGoToDefinition -vsplit<CR>
nmap <leader>sh :ALEGoToDefinition -split<CR>
nmap <leader>st :ALEGoToDefinition -tab<CR>
nmap <leader>A :ALEGoToDefinition<CR>
nmap <leader>n :ALEFindReferences -quickfix <bar> copen<CR>
nmap <leader>h :ALEHover<CR>
nmap <leader>r :ALERename<CR>
nmap <leader>` :ALELint<CR>
nmap <leader>F :ALEFix<CR>
nmap <leader>D :ALEToggle<CR>
map <leader>nn :NERDTreeToggle<CR>
"" fzf.vim
" Quickly find and open a recently opened file
map <leader>o :Buffers<CR>
map <leader>j :GFiles<CR>
map <leader>J :Files<CR>
map <leader>f :History<CR>
map <leader>T :BTags<CR>
map <leader>t :Tags<CR>
map <leader>l :Lines<CR>
" FIXME: Not using CtrlP anymore, replace this with fzf
""map <leader>c :CtrlPQuickfix<CR>
map <leader>s :Snippets<CR>
map <leader>; :Commands<CR>
map <leader>m :Maps<CR>
"" Indent Guides
map <leader>I :IndentGuidesToggle<CR>
map <leader>i :set cursorcolumn!<CR>
"" Goyo
nmap <leader>zz :Goyo<CR>
""" Tagbar
nmap <F8> :TagbarToggle<CR>
""Misc stuff
if g:uname ==? 'Darwin'
"" Mac specific stuff
elseif g:uname ==? 'Linux'
"" Linux specific stuff
xnoremap "+y y:call system("wl-copy", @")<cr>
map "+p :<C-U>let @"=substitute(system('wl-paste --no-newline'), '<C-v><C-m>', '', 'g') \| exec 'normal! ' . v:count1 . 'p'<cr>
else
"" Unknown platform
endif
" Add shortcuts to yank/paste to unnamed/unnamedplus clipboards
map <Leader>y "+y
map <Leader>p "+p
map <Leader>yp <Plug>yankstack_substitute_older_paste
map <leader>yn <Plug>yankstack_substitute_newer_paste
" Insert a python breakpoint
let @b = 'obreakpoint(<28>kr<1B><>a0j'
" visual mode mappings
vnoremap <silent> <leader>k :call VisualSelection('LAck', '')<CR>
vnoremap <silent> <leader>gs :call GitShowVisual()<CR>
vnoremap <silent> <leader>r :call VisualSelection('replace', '')<CR>
nnoremap K :exe "Rg " . expand("<cword>")<cr>
nnoremap GL :exe "Git log -L:" . expand("<cword>") . ":" . expand("%")<cr>
autocmd FileType python nnoremap T :Pytest function --pdb<CR>
" Ultisnips
map <Leader>ue :UltiSnipsEdit<cr>
nmap <F5> <ESC>:Gradle assembleDebug<CR>
nmap <F6> <ESC>:AndroidInstall debug<CR>
nmap <F7> <ESC>:AndroidLaunch debug<CR>