1
0
Fork 0

Improve vimrc

This commit is contained in:
Malte Brandy 2022-01-30 12:05:50 +01:00
parent d820c71f7c
commit cf03e2cea3

View file

@ -13,8 +13,8 @@ function! MyExplorer()
endif endif
endfunction endfunction
nnoremap <space>e :call MyExplorer()<CR> no <space>e :call MyExplorer()<CR>
nnoremap <space>v :Vista coc<CR> no <space>v :Vista coc<CR>
set nofoldenable set nofoldenable
set background=light set background=light
@ -48,13 +48,13 @@ augroup focus
au BufLeave * silent! wall au BufLeave * silent! wall
augroup END augroup END
nnoremap <silent><cr> :nohlsearch<CR> no <silent><cr> :nohlsearch<CR>
vnoremap < <gv vno < <gv
vnoremap > >gv vno > >gv
nnoremap <c-down> <c-w><c-j> no <c-down> <c-w><c-j>
nnoremap <c-up> <c-w><c-k> no <c-up> <c-w><c-k>
nnoremap <c-right> <c-w><c-l> no <c-right> <c-w><c-l>
nnoremap <c-left> <c-w><c-h> no <c-left> <c-w><c-h>
let mapleader="," let mapleader=","
@ -70,10 +70,10 @@ set ignorecase
set wildmenu set wildmenu
set hlsearch set hlsearch
noremap <buffer> <silent> <Up> gk no <buffer> <silent> <Up> gk
noremap <buffer> <silent> <Down> gj no <buffer> <silent> <Down> gj
noremap <buffer> <silent> <Home> g<Home> no <buffer> <silent> <Home> g<Home>
noremap <buffer> <silent> <End> g<End> no <buffer> <silent> <End> g<End>
let $NVIM_TUI_ENABLE_CURSOR_SHAPE=1 let $NVIM_TUI_ENABLE_CURSOR_SHAPE=1
let g:haskell_enable_quantification = 1 " to enable highlighting of `forall` let g:haskell_enable_quantification = 1 " to enable highlighting of `forall`
let g:haskell_enable_recursivedo = 1 " to enable highlighting of `mdo` and `rec` let g:haskell_enable_recursivedo = 1 " to enable highlighting of `mdo` and `rec`
@ -118,11 +118,11 @@ set signcolumn=yes
" Use tab for trigger completion with characters ahead and navigate. " Use tab for trigger completion with characters ahead and navigate.
" Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin. " Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
inoremap <silent><expr> <TAB> ino <silent><expr> <TAB>
\ pumvisible() ? "\<C-n>" : \ pumvisible() ? "\<C-n>" :
\ <SID>check_back_space() ? "\<TAB>" : \ <SID>check_back_space() ? "\<TAB>" :
\ coc#refresh() \ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>" ino <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
function! s:check_back_space() abort function! s:check_back_space() abort
let col = col('.') - 1 let col = col('.') - 1
@ -130,26 +130,26 @@ function! s:check_back_space() abort
endfunction endfunction
" Use <c-space> to trigger completion. " Use <c-space> to trigger completion.
inoremap <silent><expr> <c-space> coc#refresh() ino <silent><expr> <c-space> coc#refresh()
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position. " Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position.
" Coc only does snippet and additional edit on confirm. " Coc only does snippet and additional edit on confirm.
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>" ino <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
nnoremap <silent> gp :call CocAction('diagnosticPrevious')<cr> no <silent> gp :call CocAction('diagnosticPrevious')<cr>
nnoremap <silent> gn :call CocAction('diagnosticNext')<cr> no <silent> gn :call CocAction('diagnosticNext')<cr>
" Remap keys for gotos " Remap keys for gotos
nnoremap <silent> gd :call CocAction('jumpDefinition')<cr> no <silent> gd :call CocAction('jumpDefinition')<cr>
nnoremap <silent> gt :call CocAction('jumpTypeDefinition')<cr> no <silent> gt :call CocAction('jumpTypeDefinition')<cr>
nnoremap <silent> gr :call CocAction('jumpReferences')<cr> no <silent> gr :call CocAction('jumpReferences')<cr>
nnoremap <silent> gs :Git status<CR> no <silent> gs :Git status<CR>
nnoremap <silent> gu :CocCommand git.chunkUndo<CR> no <silent> gu :CocCommand git.chunkUndo<CR>
nnoremap <silent> gi :CocCommand git.chunkInfo<CR> no <silent> gi :CocCommand git.chunkInfo<CR>
nnoremap <silent> ga :CocCommand git.chunkStage<CR> no <silent> ga :CocCommand git.chunkStage<CR>
nnoremap <silent> gb :CocCommand git.showCommit<CR> no <silent> gb :CocCommand git.showCommit<CR>
nnoremap <silent> gc :Git commit<CR> no <silent> gc :Git commit<CR>
function! s:show_documentation() function! s:show_documentation()
if (index(['vim','help'], &filetype) >= 0) if (index(['vim','help'], &filetype) >= 0)
@ -160,7 +160,7 @@ function! s:show_documentation()
endif endif
endfunction endfunction
nnoremap <silent> <space>i :call <SID>show_documentation()<CR> no <silent> <space>i :call <SID>show_documentation()<CR>
augroup mygroup augroup mygroup
@ -171,14 +171,14 @@ augroup mygroup
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
augroup end augroup end
nnoremap <silent> <space>f :call CocAction('format')<cr> no <silent> <space>f :call CocAction('format')<cr>
nnoremap <silent> <space>l :call CocAction('codeLensAction')<cr> no <silent> <space>l :call CocAction('codeLensAction')<cr>
" FZF ctrl-p style search " FZF ctrl-p style search
nnoremap <space>p :Files<CR> no <space>p :Files<CR>
nnoremap <space>g :Rg<CR> no <space>g :Rg<CR>
nnoremap <space>h :History<CR> no <space>h :History<CR>
nnoremap <space>b :Buffers<CR> no <space>b :Buffers<CR>
function MyClose() function MyClose()
if &readonly if &readonly
@ -197,19 +197,19 @@ function MyCloseAll()
quitall quitall
endif endif
endfunction endfunction
nnoremap <space>q :call MyClose()<CR> no <space>q :call MyClose()<CR>
nnoremap <space>k :call MyCloseAll()<CR> no <space>k :call MyCloseAll()<CR>
nnoremap <space>s :w<CR> no <space>s :w<CR>
nnoremap <a-left> :bp<CR> no <a-left> :bp<CR>
nnoremap <a-right> :bn<CR> no <a-right> :bn<CR>
inoremap <a-left> <ESC>:bp<CR> ino <a-left> <ESC>:bp<CR>
inoremap <a-right> <ESC>:bn<CR> ino <a-right> <ESC>:bn<CR>
" Use <tab> for select selections ranges, needs server support, like: coc-tsserver, coc-python " Use <tab> for select selections ranges, needs server support, like: coc-tsserver, coc-python
nnoremap <silent> <TAB> <Plug>(coc-range-select) no <silent> <TAB> <Plug>(coc-range-select)
xmap <silent> <TAB> <Plug>(coc-range-select) xno <silent> <TAB> <Plug>(coc-range-select)
xmap <silent> <S-TAB> <Plug>(coc-range-select-backword) xno <silent> <S-TAB> <Plug>(coc-range-select-backword)
" Use `:Fold` to fold current buffer " Use `:Fold` to fold current buffer
@ -218,19 +218,19 @@ command! -nargs=? Fold :call CocAction('fold', <f-args>)
" use `:OR` for organize import of current buffer " use `:OR` for organize import of current buffer
command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport') command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
imap <ESC>[1~ <HOME> ino <ESC>[1~ <HOME>
imap <ESC>[4~ <End> ino <ESC>[4~ <End>
" Using CocList " Using CocList
" Show all diagnostics " Show all diagnostics
nnoremap <silent> <space>d :<C-u>CocFzfList diagnostics<cr> no <silent> <space>d :<C-u>CocFzfList diagnostics<cr>
" Show commands " Show commands
nnoremap <silent> <space>c :<C-u>CocFzfList commands<cr> no <silent> <space>c :<C-u>CocFzfList commands<cr>
" Find symbol of current document " Find symbol of current document
nnoremap <silent> <space>o :Vista finder coc<cr> no <silent> <space>o :Vista finder coc<cr>
" Find symbol of current document " Find symbol of current document
nnoremap <silent> <space>a :<C-u>CocAction<cr> no <silent> <space>a :<C-u>CocAction<cr>
imap <Enter> <CR> ino <Enter> <CR>
" Load this after theme " Load this after theme
hi Normal ctermbg=NONE hi Normal ctermbg=NONE