mirror of
https://git.decapod.one/brethil/dotfiles
synced 2024-11-14 15:51:30 +01:00
127 lines
3.5 KiB
VimL
127 lines
3.5 KiB
VimL
"""" Leader shortcuts
|
||
|
||
|
||
let mapleader = ","
|
||
" also use space as leader
|
||
nmap <Space> <leader>
|
||
|
||
nmap <leader>w :w!<CR>
|
||
command! W execute 'w !sudo tee % > /dev/null' <bar> edit!
|
||
" nmap <leader>W :w!<CR>
|
||
|
||
"Reload vimrc on config change
|
||
map <leader>e :e! ~/.vimrc<CR>
|
||
" FIXME: This results in some weird conflict with lightline
|
||
autocmd! bufwritepost ~/.vimrc source ~/.vimrc
|
||
autocmd! bufwritepost $DOTFILES/vim/* source ~/.vimrc
|
||
|
||
" Quickly open a markdown buffer for scribble
|
||
map <leader>x :e ~/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`]
|
||
|
||
" open quickfix
|
||
nmap <leader>cc :botright cope<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>cn :cn<CR>
|
||
" previous cope error
|
||
map <leader>cp :cp<CR>
|
||
|
||
"disable highlighting for current word
|
||
map <silent> <leader><CR> :noh<CR>
|
||
map <leader>ss :setlocal spell!<CR>
|
||
|
||
nnoremap <leader>wz :call WinZoomToggle()<CR>
|
||
|
||
nmap \ :Explore<CR>
|
||
nnoremap <leader>C :close<CR>
|
||
nnoremap <leader>B :Bclose<CR>
|
||
nnoremap <leader>k :Ack<Space>
|
||
|
||
"" Fugitive
|
||
nnoremap <leader>/ :Git<CR>
|
||
nnoremap <leader>g :Git<CR>
|
||
nnoremap <leader>gd :Git diff<CR>
|
||
nnoremap <leader>gp :Git push<CR>
|
||
nnoremap <leader>M :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>hn :GitGutterNextHunk<CR>
|
||
nnoremap <leader>hp :GitGutterPrevHunk<CR>
|
||
|
||
"" Ale
|
||
nmap <silent> <C-k> <Plug>(ale_previous_wrap)
|
||
nmap <silent> <C-j> <Plug>(ale_next_wrap)
|
||
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<CR>
|
||
nmap <leader>h :ALEHover<CR>
|
||
nmap <leader>r :ALERename<CR>
|
||
map <leader>` :ALELint<CR>
|
||
|
||
map <leader>nn :NERDTreeToggle<CR>
|
||
|
||
"" CtrlP
|
||
" Quickly find and open a recently opened file
|
||
" let g:ctrlp_map = '<C-f>'
|
||
|
||
map <leader>o :CtrlPBuffer<CR>
|
||
map <leader>j :CtrlP<CR>
|
||
map <leader>b :CtrlPBuffer<CR>
|
||
map <leader>f :CtrlPMRUFiles<CR>
|
||
map <leader>t :CtrlPBufTag<CR>
|
||
map <leader>T :CtrlPTag<CR>
|
||
map <leader>c :CtrlPQuickfix<CR>
|
||
map <leader>c :CtrlPQuickfix<CR>
|
||
|
||
|
||
"" Indent Guides
|
||
map <leader>I :IndentGuidesToggle<CR>
|
||
|
||
" Goyo
|
||
nmap <leader>za :Goyo 80%x85%<CR>
|
||
nmap <leader>zz :Goyo<CR>
|
||
|
||
""Misc stuff
|
||
|
||
let s:uname=''
|
||
let s:uname = system('uname | tr -d "\n"') " Get platform name (stripping the trailing newline)
|
||
if s:uname == "Darwin"
|
||
"" Mac specific stuff
|
||
elseif s:uname == "linux"
|
||
"" Linux specific stuff
|
||
" Wayland clipboard fix https://github.com/vim/vim/issues/5157
|
||
xnoremap "+y :call system("wl-copy", @")<CR>
|
||
nnoremap "+p :let @"=substitute(system("wl-paste --no-newline"), '<C-v><C-m>', '', 'g')<cr>p
|
||
xnoremap "*y :call system("wl-copy --primary", @")<CR>
|
||
nnoremap "*p :let @"=substitute(system("wl-paste --no-newline --primary"), '<C-v><C-m>', '', 'g')<cr>p
|
||
else
|
||
"" Unkown platform
|
||
endif
|
||
|
||
" Add shortcuts to yank/paste to unnamed/unnamedplus clipboards
|
||
noremap <Leader>y "*y
|
||
noremap <Leader>p "*p
|
||
noremap <Leader>Y "+y
|
||
noremap <Leader>P "+p
|
||
|
||
" A friggin python breakpoint. Invoke with @b "FIXME: make this decent
|
||
let @b = 'A
|
||
breakpoint()ýajkj0'
|
||
|
||
|
||
" visual mode mappings
|
||
vnoremap <silent> <leader>k :call VisualSelection('ack', '')<CR>
|
||
vnoremap <silent> <leader>gs :call GitShowVisual()<CR>
|
||
vnoremap <silent> <leader>r :call VisualSelection('replace', '')<CR>
|