diff --git a/.vim/vimrc b/.vim/vimrc index c5f1b33..44817a9 100644 --- a/.vim/vimrc +++ b/.vim/vimrc @@ -132,10 +132,19 @@ set ttyfast set lazyredraw set ruler set backspace=eol,indent,start +" statusline {{{ set statusline=%<%f%h%m%r%=%b\ 0x%B\ \ %l,%c%V\ %P set laststatus=2 +" Vista configuration +function! NearestMethodOrFunction() abort + return get(b:, 'vista_nearest_method_or_function', '') +endfunction + +set statusline+=\ +set statusline+=%{NearestMethodOrFunction()} +" }}} set number -set norelativenumber +set relativenumber " Make Vim to handle long lines nicely. set wrap set textwidth=79 @@ -158,6 +167,7 @@ nnoremap :nohlsearch set shell=/bin/bash set path+=** +packadd termdebug " Undofile {{{ @@ -179,19 +189,16 @@ let g:gutentags_cache_dir='~/.vim/tags' "let g:gutentags_ctags_extra_args=['--fields=+l'] " }}} - +" +" Mappings {{{ +" Editing {{{ "Changing Leader Key let mapleader = "\\" -" Make pasting done without any indentation break -set pastetoggle= -set clipboard=unnamed - nnoremap j J nnoremap k K nnoremap J 5j nnoremap K 5k - "nnoremap j gj "nnoremap k gk @@ -199,31 +206,91 @@ nnoremap K 5k inoremap nnoremap vnoremap +" jj For Quicker Escaping between normal and editing mode +inoremap jj +inoremap jk +inoremap :w :wi -" Map : to ; also in command mode. +" space one line, home,end globally increase/decrease +nnoremap za +nnoremap zm +nnoremap zr + +" Map : to ; also in command mode "nnoremap ; : " Reselect visual block after incrementing/decrementing vnoremap gv vnoremap gv -" Set vim to save the file on focus out -"au FocusLost * :wa +nnoremap 2 :set tabstop=2 softtabstop=2 shiftwidth=2 +nnoremap 4 :set tabstop=4 softtabstop=4 shiftwidth=4 +nnoremap 8 :set tabstop=8 softtabstop=8 shiftwidth=8 + +map :colorscheme random + +" Make pasting done without any indentation break +set pastetoggle= " leader Command to remove white space from a file ""nnoremap W :%s/\s\+$//:let @/='' -" Re-hardwrap Paragraph -nnoremap q gqip +tnoremap +" }}} +" Plugins {{{ +inoremap pumvisible() ? "\" : "\u\" -" jj For Quicker Escaping between normal and editing mode -inoremap jj -inoremap jk +nmap gd (coc-definition) +nmap gy (coc-type-definition) +nmap gi (coc-implementation) +nmap gr (coc-references) -" Resize Split When the window is resized -au VimResized * :wincmd = +nnoremap k :call show_documentation() -" Wildmenu completion +xmap f (coc-format-selected) +nmap f (coc-format-selected) + +" Show all diagnostics +nnoremap a :CocList diagnostics +" Manage extensions +nnoremap e :CocList extensions +" Show commands +nnoremap c :CocList commands +" Find symbol of current document +nnoremap o :CocList outline +" Search workspace symbols +nnoremap s :CocList -I symbols +" Do default action for next item. +nnoremap j :CocNext +" Do default action for previous item. +nnoremap k :CocPrev +" Resume latest coc list +nnoremap p :CocListResume + +let g:UltiSnipsExpandTrigger="" +let g:UltiSnipsJumpForwardTrigger="" +let g:UltiSnipsJumpBackwardTrigger="p" + +" yoink configuration +nmap p (YoinkPostPasteSwapBack) +nmap n (YoinkPostPasteSwapForward) +nmap p (YoinkPaste_p) +nmap P (YoinkPaste_P) + +nnoremap l :Lines +nnoremap b :Buffers +nnoremap s :Snippets +nnoremap a :Ag + +" Tagbar key bindings." +"nmap t :TlistToggle + +" }}} +" }}} + +set clipboard=unnamed + +" Wildmenu completion {{{ set wildmenu set wildmode=list:longest set wildignore+=.hg,.git,.svn " Version Controls" @@ -237,6 +304,7 @@ set wildignore+=*.luac "Lua byte code" set wildignore+=migrations "Django migrations" set wildignore+=*.pyc "Python Object codes" set wildignore+=*.orig "Merge resolution files" +" }}} match Error /\s\+$\|DU\cPA/ @@ -265,87 +333,47 @@ let g:miniBufExplMapCTabSwitchBufs = 1 let g:miniBufExplModSelTarget = 1 let g:miniBufExplStatusLineText = '' -" Tagbar key bindings." -"nmap t :TlistToggle - -nnoremap 2 :set tabstop=2 softtabstop=2 shiftwidth=2 -nnoremap 4 :set tabstop=4 softtabstop=4 shiftwidth=4 -nnoremap 8 :set tabstop=8 softtabstop=8 shiftwidth=8 - "Full line: "set colorcolumn=120 "call matchadd('ColorColumn', '\%80v', 100) if has("autocmd") - "restore cursor position - autocmd BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif - autocmd FileType helpfile set nonumber + "restore cursor position + autocmd BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif + autocmd FileType helpfile set nonumber - autocmd WinLeave * set nocursorline - autocmd WinEnter * set cursorline + autocmd WinLeave * set nocursorline + autocmd WinEnter * set cursorline - "autocmd FileType tex set textwidth=79 - "autocmd FileType c,cpp,hpp,h :RainbowLevelsOn + " Set vim to save the file on focus out + "au FocusLost * :wa + + " Resize Split When the window is resized + au VimResized * :wincmd = + + " If you want to show the nearest function in your statusline automatically + autocmd VimEnter * call vista#RunForNearestMethodOrFunction() endif -"hi! link RainbowLevel0 Constant -"hi! link RainbowLevel1 Type -"hi! link RainbowLevel2 Function -"hi! link RainbowLevel3 String -"hi! link RainbowLevel4 PreProc -"hi! link RainbowLevel5 Statement -"hi! link RainbowLevel6 Identifier -"hi! link RainbowLevel7 Normal -"hi! link RainbowLevel8 Comment - -"nnoremap yg :YcmCompleter GoTo -"nnoremap yf :YcmCompleter FixIt -"nnoremap yd :YcmCompleter GetDoc -"nnoremap yt :YcmCompleter GetType -"nnoremap yp :YcmCompleter GetParent -"let g:ycm_confirm_extra_conf = 0 -"let g:ycm_warning_symbol = '>' -"let g:ycm_complete_in_strings = 0 -"let g:ycm_collect_identifiers_from_tags_files = 1 -"let g:ycm_enable_diagnostic_highlighting = 0 -"let g:ycm_autoclose_preview_window_after_completion = 0 -"let g:ycm_autoclose_preview_window_after_insertion = 1 -"let g:ycm_min_num_of_chars_for_completion = 99 - -map :colorscheme random - " Folding {{{ function! FoldFormat() let foldsize = (v:foldend - v:foldstart) return getline(v:foldstart)."\t\t\t(".foldsize."\tmore lines)" endfunction -" space one line, home,end globally increase/decrease set foldenable set foldlevelstart=999 set foldnestmax=5 set foldtext=FoldFormat() set fillchars=fold:\ " comment just to remove trailing set foldmethod=syntax -nnoremap za -nnoremap zm -nnoremap zr +if has('folding') + setglobal foldopen+=jump +endif + " }}} set updatetime=100 -" From C.vim: -" ADDITIONAL MAPPING : complete a classical C comment: '/*' => '/* | */' -"vnoremap /* s/**/p -" additional mapping : complete a classical C multi-line comment: -"inoremap /* /*/kA -" additional mapping : { always opens a block -"inoremap { {}O -"vnoremap { S{}Pk=iB - -inoremap :w :wi - -"nnoremap :silent ! plantuml %:p && eog -g %:p:r.png &:redraw! - " ctrlp configuration "let g:ctrlp_map = '' "let g:ctrlp_cmd = 'CtrlPLastMode' @@ -353,49 +381,22 @@ inoremap :w :wi "let g:ctrlp_working_path_mode = 'rw' nnoremap :FZF -tnoremap - set nospell set runtimepath+=/usr/share/vim/vimfiles set spelllang=en " Dictionary path, from which the words are being looked up. set dictionary+=/usr/share/dict/words -" from vimconfig.com -"let g:rtagsRcCmd='rtags-rc' -"let g:matchparen_timeout = 2 -"let g:matchparen_insert_timeout = 2 - " Mapping to NERDTree -"nnoremap :e . nnoremap :NERDTreeToggle let NERDTreeIgnore=['\.vim$', '\~$', '\.pyc$'] +"nnoremap :e . "let g:netrw_banner=0 "let g:netrw_wisize=20 "let g:netrw_liststyle=3 "let g:netrw_lolcalrmdir='rm -r' "nnoremap n :Lexplore -" taken from Damian Conway - -"nnoremap n n:call HLNext(0.2) -"nnoremap N N:call HLNext(0.2) -" -"function! HLNext(blinktime) -" let [bufnum, lnum, col, off] = getpos('.') -" let matchlen = strlen(matchstr(strpart(getline('.'), col - 1), @/)) -" let target_pat = '\c\%#'.@/ -" let blinks = 1 -" for n in range(1, blinks) -" let red = matchadd('WarningMsg', target_pat, 101) -" redraw -" exec 'sleep ' . float2nr(a:blinktime / (2*blinks) * 1000) . 'm' -" call matchdelete(red) -" redraw -" exec 'sleep ' . float2nr(a:blinktime / (2*blinks) * 1000) . 'm' -" endfor -"endfunction - nnoremap S :%s//g xnoremap S :s//g xmap x @@ -408,7 +409,7 @@ function! FindAlternate() elseif (l:curr_ext == 'cpp') let l:ext = 'h' elseif (l:curr_ext == 'h') - let l:ext = 'cpp' + let l:ext = 'c' elseif (l:curr_ext == 'hpp') let l:ext = 'cpp' endif @@ -420,27 +421,20 @@ nnoremap :call FindAlternate() "let g:alternateSearchPath="sfr:../source,sfr:../src,sfr:../include,sfr:../inc,sfr:./Source,sfr:.." "map :call CurtineIncSw() -" taken from tpope +let g:startify_custom_header = '' setglobal complete-=i setglobal virtualedit=block setglobal shiftround -if has('folding') - setglobal foldopen+=jump -endif - -packadd termdebug - -let g:startify_custom_header = '' set shortmess+=c -inoremap coc#refresh() +"inoremap coc#refresh() set signcolumn=yes set cmdheight=2 -inoremap - \ pumvisible() ? "\" : - \ check_back_space() ? "\" : - \ coc#refresh() +"inoremap +" \ pumvisible() ? "\" : +" \ check_back_space() ? "\" : +" \ coc#refresh() inoremap pumvisible() ? "\" : "\" function! s:check_back_space() abort @@ -448,15 +442,6 @@ function! s:check_back_space() abort return !col || getline('.')[col - 1] =~# '\s' endfunction -inoremap pumvisible() ? "\" : "\u\" - -nmap gd (coc-definition) -nmap gy (coc-type-definition) -nmap gi (coc-implementation) -nmap gr (coc-references) - -nnoremap K :call show_documentation() - function! s:show_documentation() if (index(['vim','help'], &filetype) >= 0) execute 'h '.expand('') @@ -466,55 +451,8 @@ function! s:show_documentation() endfunction autocmd CursorHold * silent call CocActionAsync('highlight') -xmap f (coc-format-selected) -nmap f (coc-format-selected) - -" Show all diagnostics -nnoremap a :CocList diagnostics -" Manage extensions -nnoremap e :CocList extensions -" Show commands -nnoremap c :CocList commands -" Find symbol of current document -nnoremap o :CocList outline -" Search workspace symbols -nnoremap s :CocList -I symbols -" Do default action for next item. -nnoremap j :CocNext -" Do default action for previous item. -nnoremap k :CocPrev -" Resume latest coc list -nnoremap p :CocListResume - -" Vista configuration -function! NearestMethodOrFunction() abort - return get(b:, 'vista_nearest_method_or_function', '') -endfunction - -set statusline+=\ -set statusline+=%{NearestMethodOrFunction()} - -" By default vista.vim never run if you don't call it explicitly. -" -" If you want to show the nearest function in your statusline automatically -autocmd VimEnter * call vista#RunForNearestMethodOrFunction() - -let g:UltiSnipsExpandTrigger="" -let g:UltiSnipsJumpForwardTrigger="" -let g:UltiSnipsJumpBackwardTrigger="p" - -" yoink configuration -nmap p (YoinkPostPasteSwapBack) -nmap n (YoinkPostPasteSwapForward) -nmap p (YoinkPaste_p) -nmap P (YoinkPaste_P) hi None ctermbg=None ctermfg=None -nnoremap l :Lines -nnoremap b :Buffers -nnoremap s :Snippets -nnoremap a :Ag - let g:vim_search_pulse_mode = 'pattern' let g:vim_search_pulse_duration = 400