384 lines
9.8 KiB
VimL
384 lines
9.8 KiB
VimL
nnoremap <SPACE> <Nop>
|
|
let g:mapleader = ' '
|
|
|
|
"
|
|
nnoremap <Leader>tk <C-w><C-]><C-w>T
|
|
|
|
" Quickly insert an empty new line without entering insert mode
|
|
nnoremap <Leader>o o<Esc>
|
|
nnoremap <Leader>O O<Esc>
|
|
|
|
" workman
|
|
noremap <C-K> <C-O>
|
|
noremap <Tab> <C-I>
|
|
|
|
noremap e j
|
|
noremap o k
|
|
noremap n h
|
|
noremap i l
|
|
noremap k n
|
|
noremap h e
|
|
noremap l o
|
|
noremap f u
|
|
noremap u i
|
|
|
|
noremap E J
|
|
noremap O K
|
|
noremap N H
|
|
noremap I L
|
|
noremap K N
|
|
noremap H E
|
|
noremap L O
|
|
noremap F U
|
|
noremap U I
|
|
|
|
noremap ge gj
|
|
noremap go gk
|
|
noremap gn gh
|
|
noremap gl go
|
|
noremap gk gn
|
|
noremap gh ge
|
|
|
|
noremap gE gJ
|
|
noremap gN gH
|
|
noremap gK gN
|
|
noremap gH gE
|
|
noremap gL gO
|
|
|
|
nnoremap <silent> <c-w>e :wincmd j<cr>
|
|
nnoremap <silent> <c-w>o :wincmd k<cr>
|
|
nnoremap <silent> <c-w>n :wincmd h<cr>
|
|
nnoremap <silent> <c-w>i :wincmd l<cr>
|
|
nnoremap <silent> <c-w>k :wincmd n<cr>
|
|
nnoremap <silent> <c-w>l :wincmd o<cr>
|
|
|
|
vnoremap <c-n> B
|
|
vnoremap <c-i> W
|
|
nnoremap <c-n> B
|
|
nnoremap <c-i> W
|
|
|
|
vnoremap <A-n> b
|
|
vnoremap <A-i> w
|
|
nnoremap <A-n> b
|
|
nnoremap <A-i> w
|
|
" nnoremap <c-n>i e
|
|
|
|
" get control-j back, so switch it with ctrl-n at qwerty position of j
|
|
" imap <c-n> <cr>
|
|
" cmap <c-n> <cr>
|
|
inoremap <c-j> <c-n>
|
|
cnoremap <c-j> <c-n>
|
|
|
|
" half scroll up and down
|
|
noremap <C-A-p> <C-u>
|
|
noremap <C-A-u> <C-d>
|
|
map <C-d> <Nop>
|
|
|
|
|
|
" jump word in visual mode -- TODO
|
|
|
|
" In insert or command mode, move normally by using Ctrl
|
|
inoremap <C-n> <Left>
|
|
inoremap <C-e> <Down>
|
|
inoremap <C-o> <Up>
|
|
inoremap <C-i> <Right>
|
|
cnoremap <C-n> <Left>
|
|
cnoremap <C-e> <Down>
|
|
cnoremap <C-o> <Up>
|
|
cnoremap <C-i> <Right>
|
|
|
|
inoremap <C-A-n> <C-Left>
|
|
inoremap <C-A-i> <C-Right>
|
|
|
|
inoremap <C-A-e> <Esc>:+3<CR>i
|
|
inoremap <C-A-o> <Esc>:-3<CR>i
|
|
|
|
" easy config
|
|
nmap <S-F9> :e $HOME/.vimrc<CR>
|
|
nmap <S-F10> :so $HOME/.vimrc<CR>
|
|
|
|
" Force saving files that require root permission
|
|
command! SUDOwrite :execute 'w !sudo tee > /dev/null %' | edit!
|
|
|
|
" TODO: C-S-o etc does not work
|
|
" Bubble single lines
|
|
nmap <silent> <C-S-Up> :m-2<CR>==
|
|
nmap <silent> <C-S-o> :m-2<CR>==
|
|
nmap <silent> <C-S-Down> :m+<CR>==
|
|
nmap <silent> <C-S-e> :m+<CR>==
|
|
imap <silent> <C-S-Up> <Esc>:m-2<CR>==gi
|
|
imap <silent> <C-S-o> <Esc>:m-2<CR>==gi
|
|
imap <silent> <C-S-Down> <Esc>:m+<CR>==gi
|
|
imap <silent> <C-S-e> <Esc>:m+<CR>==gi
|
|
|
|
" Bubble multiple lines
|
|
vmap <silent> <C-S-Up> :m-2<CR>gv=gv
|
|
vmap <silent> <C-S-o> :m-2<CR>gv=gv
|
|
vmap <silent> <C-S-Down> :m'>+<CR>gv=gv
|
|
vmap <silent> <C-S-e> :m'>+<CR>gv=gv
|
|
|
|
" Indent lines using <Left> and <Right>
|
|
vmap <C-S-Right> >gv
|
|
nmap <C-S-Right> >>
|
|
imap <C-S-Right> <Esc>>>i
|
|
vmap <C-S-Left> <gv
|
|
nmap <C-S-Left> <<
|
|
imap <C-S-Left> <Esc><<i
|
|
|
|
" moving through location list items
|
|
" noremap <S-Up> :lprevious<CR>
|
|
" noremap <S-Down> :lnext<CR>
|
|
|
|
" moving through buffers
|
|
" noremap <S-Left> :bn<CR>
|
|
" noremap <S-Right> :bp<CR>
|
|
noremap <leader>bd <Esc>:bd<CR>
|
|
noremap <leader>wc <Esc>:bd<CR>
|
|
noremap <leader>bo <Esc>:Bufonly<CR>
|
|
|
|
" close preview
|
|
nmap <leader>pc <Esc>:pc<CR>
|
|
|
|
" Remap window commands
|
|
" map <leader>ws <Esc>:wincmd s<CR>
|
|
" map <leader>wv <Esc>:wincmd v<CR>
|
|
" map <leader>wc <Esc>:wincmd c<CR>
|
|
" map <leader>wn <Esc>:wincmd n<CR>
|
|
" map <leader>wo <Esc>:wincmd o<CR>
|
|
" map <leader>w+ <Esc>:wincmd _<CR>
|
|
" map <leader>w- <Esc>:wincmd <Bar><CR>
|
|
" map <leader>w= <Esc>:wincmd =<CR>
|
|
" nmap + :vertical resize +20<CR>
|
|
" nmap - :vertical resize -20<CR>
|
|
" map <C-S--> <Esc>:wincmd ><CR>
|
|
" map <C-Down> <Esc>:wincmd j<CR>
|
|
" map <C-j> <Esc>:wincmd j<CR>
|
|
" map <C-Up> <Esc>:wincmd k<CR>
|
|
" map <C-k> <Esc>:wincmd k<CR>
|
|
" map <C-Left> <Esc>:wincmd h<CR>
|
|
" map <C-h> <Esc>:wincmd h<CR>
|
|
" map <C-Right> <Esc>:wincmd l<CR>
|
|
" map <C-l> <Esc>:wincmd l<CR>
|
|
"
|
|
" nnoremap <silent> <A-o> :wincmd k<CR>
|
|
" nnoremap <silent> <A-e> :wincmd j<CR>
|
|
" nnoremap <silent> <A-n> :wincmd h<CR>
|
|
" nnoremap <silent> <A-i> :wincmd l<CR>
|
|
" inoremap <silent> <A-o> <Esc>:wincmd k<CR>
|
|
" inoremap <silent> <A-e> <Esc>:wincmd j<CR>
|
|
" inoremap <silent> <A-n> <Esc>:wincmd h<CR>
|
|
" inoremap <silent> <A-i> <Esc>:wincmd l<CR>
|
|
nnoremap <silent> <C-A-o> :wincmd k<CR>
|
|
nnoremap <silent> <C-A-e> :wincmd j<CR>
|
|
nnoremap <silent> <C-A-n> :wincmd h<CR>
|
|
nnoremap <silent> <C-A-i> :wincmd l<CR>
|
|
nnoremap <silent> <A-Up> :wincmd k<CR>
|
|
nnoremap <silent> <A-Down> :wincmd j<CR>
|
|
nnoremap <silent> <A-Left> :wincmd h<CR>
|
|
nnoremap <silent> <A-Right> :wincmd l<CR>
|
|
inoremap <silent> <A-Up> <Esc>:wincmd k<CR>
|
|
inoremap <silent> <A-Down> <Esc>:wincmd j<CR>
|
|
inoremap <silent> <A-Left> <Esc>:wincmd h<CR>
|
|
inoremap <silent> <A-Right> <Esc>:wincmd l<CR>
|
|
nnoremap <silent> <C-A-Up> :wincmd K<CR>
|
|
nnoremap <silent> <C-A-Down> :wincmd J<CR>
|
|
nnoremap <silent> <C-A-Left> :wincmd H<CR>
|
|
nnoremap <silent> <C-A-Right> :wincmd L<CR>
|
|
inoremap <silent> <C-A-Up> <Esc>:wincmd K<CR>
|
|
inoremap <silent> <C-A-Down> <Esc>:wincmd J<CR>
|
|
inoremap <silent> <C-A-Left> <Esc>:wincmd H<CR>
|
|
inoremap <silent> <C-A-Right> <Esc>:wincmd L<CR>
|
|
|
|
" tags
|
|
nmap <S-F3> :exec("tjump ".expand("<cword>"))<CR>
|
|
nmap <S-F4> :split<CR>:exec("tjump ".expand("<cword>"))<CR>
|
|
|
|
" trigger NERDTree, Tagbar $ Co.
|
|
" nmap <leader>n <Esc>:NERDTreeToggle<CR>
|
|
" nmap <leader>t <Esc>:TagbarToggle<CR>
|
|
" nmap <leader>f "zyaw :exe ":Ack ".@z.""<CR>
|
|
|
|
" grep word under cursor
|
|
nnoremap <silent><leader>f :lgr! "\b<C-R><C-W>\b"<CR>:cw<CR>
|
|
|
|
" paste from system clipboard
|
|
inoremap <silent> <S-Insert> <ESC>:set paste<CR>"+p :set nopaste<CR>
|
|
|
|
" toggle spellcheck
|
|
nmap <silent> <S-F7> :setlocal spell! spelllang=en_us<CR>
|
|
|
|
" cursor jump
|
|
" nnoremap <A-Up> 3k
|
|
" inoremap <A-Up> <Esc>:-3<CR>i
|
|
" vnoremap <A-Up> 3k
|
|
" nnoremap <A-Down> 3j
|
|
" inoremap <A-Down> <Esc>:+3<CR>i
|
|
" vnoremap <A-Down> 3j
|
|
" nnoremap <C-Up> 6k
|
|
" inoremap <C-Up> <Esc>:-6<CR>i
|
|
" vnoremap <C-Up> 6k
|
|
" nnoremap <C-Down> 6j
|
|
" inoremap <C-Down> <Esc>:+6<CR>i
|
|
" vnoremap <C-Down> 6j
|
|
|
|
nnoremap <A-o> 3k
|
|
vnoremap <A-o> 3k
|
|
nnoremap <A-e> 3j
|
|
vnoremap <A-e> 3j
|
|
nnoremap <C-o> 6k
|
|
vnoremap <C-o> 6k
|
|
nnoremap <C-e> 6j
|
|
vnoremap <C-e> 6j
|
|
|
|
" scrolling
|
|
nnoremap <S-PageUp> 10<C-Y>
|
|
inoremap <S-PageUp> <Esc>10<C-Y>i
|
|
vnoremap <S-PageUp> 10<C-Y>
|
|
nnoremap <S-PageDown> 10<C-E>
|
|
inoremap <S-PageDown> <Esc>10<C-E>i
|
|
vnoremap <S-PageDown> 10<C-E>
|
|
|
|
nnoremap <C-p> 10<C-Y>
|
|
inoremap <C-p> <Esc>10<C-Y>i
|
|
vnoremap <C-p> 10<C-Y>
|
|
nnoremap <C-u> 10<C-E>
|
|
inoremap <C-u> <Esc>10<C-E>i
|
|
vnoremap <C-u> 10<C-E>
|
|
|
|
|
|
" F keys
|
|
" nmap <F2> :noh<CR>
|
|
" imap <F2> <C-O>:noh<CR>
|
|
noremap <F5> :FufBuffer<CR>
|
|
nmap <F7> :call ManCurrentWord()<CR><CR>
|
|
" nmap <F8> :call DevHelpCurrentWord()<CR><CR>
|
|
" nmap <F4> <C-]>
|
|
|
|
" remap visual block
|
|
nnoremap <S-C> <c-v>
|
|
|
|
" write
|
|
noremap <C-s> :w<CR>
|
|
inoremap <C-s> <C-O>:w<CR>
|
|
|
|
" exit
|
|
noremap <C-q> :qa!<CR>
|
|
inoremap <C-q> <C-O>:qa!<CR>
|
|
|
|
" paste
|
|
nnoremap <C-V> "+gPl
|
|
vnoremap <C-V> :<C-U>call Paste("v")<CR>
|
|
inoremap <C-V> <C-O>:call Paste("i")<CR>
|
|
|
|
" select all
|
|
nnoremap <C-A> ggVG<CR>
|
|
inoremap <C-A> <C-O>:call Select()<CR>
|
|
|
|
nnoremap <leader>cd :cd %:p:h<CR>:pwd<CR>
|
|
|
|
nnoremap <Leader>cc :cclose<CR>
|
|
nnoremap <Leader>co :copen<CR>
|
|
|
|
function! ToggleQuickFix()
|
|
if empty(filter(getwininfo(), 'v:val.quickfix'))
|
|
copen
|
|
else
|
|
cclose
|
|
endif
|
|
endfunction
|
|
|
|
function! ToggleLocList()
|
|
if empty(filter(getwininfo(), 'v:val.loclist'))
|
|
lopen
|
|
else
|
|
lclose
|
|
endif
|
|
endfunction
|
|
|
|
nnoremap <silent> <F3> :call ToggleQuickFix()<CR>
|
|
nnoremap <silent> <F4> :call ToggleLocList()<CR>
|
|
|
|
|
|
|
|
|
|
" PLUGINS
|
|
|
|
|
|
" NERDTree
|
|
noremap <C-j> :NERDTreeToggle<CR>
|
|
" noremap <C-B> :TagbarToggle<CR>
|
|
inoremap <C-B> <C-O>:TagbarToggle<CR>
|
|
|
|
" vista
|
|
nmap <F8> :Vista!!<CR>
|
|
|
|
" NERDComment
|
|
nnoremap <silent> <F10> :call NERDComment("n", "Toggle")<cr>
|
|
vnoremap <silent> <F10> <ESC>:call NERDComment("v", "Toggle")<cr>
|
|
|
|
" YCM
|
|
nmap <C-F4> :YcmCompleter GoTo<CR>:wincmd o<CR>
|
|
|
|
" vim-clap
|
|
nnoremap <leader>ag :Clap grep ++query=<cword><CR>
|
|
" nnoremap <silent> <leader>tg :Clap proj_tags ++query=<cword><CR>
|
|
nmap <C-f> :Clap files<CR>
|
|
nmap <C-t> :Clap tags<CR>
|
|
nmap <C-b> :Clap buffers<CR>
|
|
|
|
nnoremap <silent> <leader>tg :tag <C-R>=expand("<cword>")<CR><CR>
|
|
nnoremap <silent> <leader>tp :ptag <C-R>=expand("<cword>")<CR><CR>
|
|
nnoremap <silent> <leader>ts :ts <C-R>=expand("<cword>")<CR><CR>
|
|
|
|
" gitgutter
|
|
nmap <leader>ggt <Esc>:GitGutterToggle<CR>
|
|
nmap <leader>nh <Plug>(GitGutterNextHunk)
|
|
nmap <leader>bh <Plug>(GitGutterPrevHunk)
|
|
|
|
" tig
|
|
" let g:tig_explorer_keymap_edit = '<C-x>'
|
|
" let g:tig_explorer_keymap_tabedit = '<C-t>'
|
|
" let g:tig_explorer_keymap_split = '<C-s>'
|
|
" let g:tig_explorer_keymap_vsplit = '<C-v>'
|
|
" nnoremap <Leader>T :TigOpenCurrentFile<CR>
|
|
" nnoremap <Leader>t :TigOpenProjectRootDir<CR>
|
|
" nnoremap <Leader>g :TigGrep<CR>
|
|
" nnoremap <Leader>r :TigGrepResume<CR>
|
|
" vnoremap <Leader>g y:TigGrep<Space><C-R>"<CR>
|
|
" nnoremap <Leader>cg :<C-u>:TigGrep<Space><C-R><C-W><CR>
|
|
" nnoremap <Leader>b :TigBlame<CR>
|
|
|
|
" ghcup
|
|
" nnoremap <Leader>ghc :GHCup<CR>
|
|
|
|
" git gutter
|
|
omap <leader>ic <Plug>(GitGutterTextObjectInnerPending)
|
|
omap <leader>ac <Plug>(GitGutterTextObjectOuterPending)
|
|
xmap <leader>ic <Plug>(GitGutterTextObjectInnerVisual)
|
|
xmap <leader>ac <Plug>(GitGutterTextObjectOuterVisual)
|
|
|
|
" fastfold
|
|
nmap zuz <Plug>(FastFoldUpdate)
|
|
|
|
"LanguageClient-neovim
|
|
" Required for operations modifying multiple buffers like rename.
|
|
set hidden
|
|
nnoremap <leader>lc :call LanguageClient_contextMenu()<CR>
|
|
" Or map each action separately
|
|
nnoremap <silent> T :call LanguageClient#textDocument_hover()<CR>
|
|
nnoremap <silent> gd :call LanguageClient#textDocument_definition()<CR>
|
|
" nnoremap <silent> <F2> :call LanguageClient#textDocument_rename()<CR>
|
|
" nnoremap <leader>ld :call LanguageClient#textDocument_definition()<CR>
|
|
" nnoremap <leader>lr :call LanguageClient#textDocument_rename()<CR>
|
|
" nnoremap <leader>lf :call LanguageClient#textDocument_formatting()<CR>
|
|
" nnoremap <leader>lt :call LanguageClient#textDocument_typeDefinition()<CR>
|
|
" nnoremap <leader>lx :call LanguageClient#textDocument_references()<CR>
|
|
" nnoremap <leader>la :call LanguageClient_workspace_applyEdit()<CR>
|
|
" nnoremap <leader>lc :call LanguageClient#textDocument_completion()<CR>
|
|
" nnoremap <leader>lh :call LanguageClient#textDocument_hover()<CR>
|
|
nnoremap <leader>la :call LanguageClient#textDocument_codeAction()<CR>
|
|
nnoremap <leader>rn :call LanguageClient#textDocument_rename()<CR>
|
|
|
|
|
|
|