X-Git-Url: https://git.rmz.io/dotfiles.git/blobdiff_plain/8de18e145a7a0a64b3b86f9ae60e1bb798530f71..5f7a37092d2d250c176c4779106fc88c0e3e38a4:/vim/vimrc diff --git a/vim/vimrc b/vim/vimrc index f177116..10e5770 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -20,14 +20,16 @@ Plugin 'derekwyatt/vim-fswitch' Plugin 'elzr/vim-json' Plugin 'firef0x/pkgbuild.vim' Plugin 'junegunn/vim-easy-align' -Plugin 'kien/ctrlp.vim' -Plugin 'klen/python-mode' +" Plugin 'kien/ctrlp.vim' +" Plugin 'klen/python-mode' +Plugin 'wilywampa/python-mode' Plugin 'kshenoy/vim-signature' Plugin 'majutsushi/tagbar' Plugin 'raimondi/delimitmate' -Plugin 'rking/ag.vim' -Plugin 'scrooloose/nerdtree' +" Plugin 'rking/ag.vim' Plugin 'scrooloose/syntastic' +Plugin 'shougo/vimproc.vim' +Plugin 'shougo/unite.vim' Plugin 'sjl/gundo.vim' Plugin 'tomtom/tcomment_vim' Plugin 'tpope/vim-endwise' @@ -42,6 +44,11 @@ Plugin 'vim-scripts/yankring.vim' Plugin 'sirver/ultisnips' Plugin 'honza/vim-snippets' +" text objects +Plugin 'kana/vim-textobj-user' +Plugin 'julian/vim-textobj-variable-segment' +Plugin 'sgur/vim-textobj-parameter' + " ros Plugin 'ompugao/ros.vim' Plugin 'ompugao/ctrlp-ros' @@ -50,12 +57,19 @@ Plugin 'ompugao/ctrlp-ros' " Plugin 'jalcine/cmake.vim' " Plugin 'powerman/vim-plugin-viewdoc' -" find an alternative +" staging +" find an alternative (latex-box? Automatic Latex Plugin?) Plugin 'http://git.code.sf.net/p/vim-latex/vim-latex' " Plugin 'lokaltog/vim-easymotion' Plugin 'justinmk/vim-sneak' Plugin 'chrisbra/checkattach' Plugin 'nathanaelkane/vim-indent-guides' +Plugin 'alx741/vinfo' +Plugin 'octol/vim-cpp-enhanced-highlight' +Plugin 'vim-scripts/mediawiki.vim' +Plugin 'vim-scripts/replacewithregister' +Plugin 'tpope/vim-abolish' +Plugin 'derekwyatt/vim-protodef' " remove entries first set runtimepath -=$HOME/.vim @@ -73,6 +87,9 @@ syntax on colorscheme badwolf " options {{{1 +" put $ and the end of text to be replaced with 'cw' and the likes +set cpoptions+=$ + " moving around, searching and patterns {{{2 set incsearch " show match for partly typed search command set ignorecase " ignore case when using a search pattern @@ -83,23 +100,25 @@ set nostartofline " don't move the cursor to the first non-blank char of a set path=.,include/,../include/,/usr/include/c++/*,/opt/ros/hydro/include " displaying text {{{2 -set scrolloff=5 " number of screen lines to show around the cursor set nowrap " long lines wrap set linebreak " wrap long lines at a character in 'breakat' set showbreak=↪ " show these chars for wrapped lines +set breakindent " preserve indentation in wrapped text set lazyredraw " don't redraw while executing macros set list " show chars defined in 'listchars' -set listchars=tab:▸\ " list of strings used for list mode +set listchars=tab:❭\ " list of strings used for list mode set listchars+=extends:❯,precedes:❮ " Only shown when not in insert mode +au InsertLeave * :set listchars+=trail:· augroup trailing au! au InsertEnter * :set listchars-=trail:· au InsertLeave * :set listchars+=trail:· augroup END +set scrolloff=5 " number of screen lines to show around the cursor set sidescroll=1 " number of collumns to scroll set sidescrolloff=1 " don't scroll over the listchars @@ -166,11 +185,15 @@ set pastetoggle= " key sequence to toggle paste mode set foldmethod=marker " folding type set foldlevelstart=0 " value for 'foldlevel' when starting to edit a file +" open folds when jumping to line +set foldopen+=jump + " save and restore folds -set viewoptions=folds,cursor " don't save local options +set viewoptions=cursor " only save cursor position " diff mode {{{2 -set diffopt=filler,vertical +" vertical splits and ignore white space in diffs +set diffopt=filler,vertical,iwhite " reading and writing files {{{2 set modeline " read modelines @@ -216,7 +239,7 @@ set wildignore+=*.pyc " Python byte code set wildignore+=*.orig " Merge resolution files " various {{{2 -set virtualedit=block " let cursor move past last char in mode +set virtualedit=all " let cursor move past last char in mode set viminfo='100,<50,s10,h,n$XDG_CACHE_HOME/vim/viminfo " viminfo defaults but save file in .cache set viewdir=$XDG_CACHE_HOME/vim/view// @@ -268,9 +291,6 @@ nnoremap / :silent nohl nnoremap [ :tabprev nnoremap ] :tabnext -" Wrap -nnoremap W :set wrap! - " paste from selection nnoremap p* :silent! set paste"*p:set nopaste " paste from clipboard @@ -289,9 +309,6 @@ noremap ' ` " Select (charwise) the contents of the current line, excluding indentation. nnoremap vv ^vg_ -" Toggle [i]nvisible characters -nnoremap i :set list! - " Unfuck my screen nnoremap U :syntax sync fromstart:AirlineRefresh:redraw! @@ -315,6 +332,7 @@ nnoremap N Nzzzv nnoremap g; g;zzzv nnoremap g, g,zzzv nnoremap zzzv +nnoremap zzzv " Not using the default mappings of 'To line from top/bottom' noremap H ^ @@ -323,10 +341,10 @@ vnoremap H ^ vnoremap L g_ " Heresy, emacs insert bindings -inoremap I -inoremap A -cnoremap -cnoremap +inoremap I +inoremap A +cnoremap +cnoremap " proper movement when lines are wrapped noremap j (v:count == 0 ? 'gj' : 'j') @@ -353,9 +371,6 @@ cnoremap " close all folds open fold in cursor nnoremap zx zMzxzt -" edit vimrc in new tab -nmap ev :tabedit $MYVIMRC:lcd %:p:h - map :ls:b nnoremap w @@ -378,14 +393,16 @@ noremap O :set pastem`O``:set nopaste " Don't use Ex mode, use Q for formatting map Q gq -" allow undoing in insert-mode -inoremap u +" break undo sequence before removing word inoremap u -nmap b :set expandtab tabstop=4 shiftwidth=4 softtabstop=4 -nmap B :set expandtab tabstop=8 shiftwidth=8 softtabstop=4 -nmap M :set noexpandtab tabstop=8 softtabstop=4 shiftwidth=4 -nmap m :set expandtab tabstop=2 shiftwidth=2 softtabstop=2 +nnoremap coe :set =&expandtab ? 'noexpandtab' : 'expandtab' +nnoremap [oe :set expandtab +nnoremap ]oe :set noexpandtab + +for idt in range(1,8) + exe 'nnoremap co'.idt.' :set tabstop='.idt.' shiftwidth='.idt.' softtabstop='.idt.'' +endfor " space will toggle current fold in normal mode nnoremap za @@ -396,14 +413,19 @@ autocmd BufWinLeave *.* mkview autocmd BufWinEnter *.* silent loadview " save with sudo -cnoremap w!! w !sudo tee % > /dev/null +cabbrev w!! w !sudo tee % > /dev/null -" plugins options {{{1 -" ag {{{2 -let g:AgSmartCase = 1 -nnoremap ag yiw:Ag " -vnoremap ag y:Ag " +" uppercase previous word +inoremap gUiwgi + +" http://git.io/v3ZeU +nmap qq :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">" + +" commands {{{1 +command! Cd lcd %:h +command! Cr execute('lcd ' . FindGitDirOrHome()) +" plugins options {{{1 " airline {{{2 let g:airline#extensions#whitespace#enabled = 1 let g:airline#extensions#tabline#enabled = 1 @@ -411,6 +433,7 @@ let g:airline_powerline_fonts = 1 " checkattach {{{2 let g:checkattach_filebrowser = 'ranger' +let g:checkattach_once = 'y' " delimitmate {{{2 let delimitMate_expand_cr = 2 @@ -420,8 +443,12 @@ let g:delimitMate_expand_space = 1 nnoremap ff :FSHere nnoremap fl :FSRight nnoremap fh :FSLeft +nnoremap fj :FSBelow +nnoremap fk :FSAbove nnoremap fL :FSSplitRight nnoremap fH :FSSplitLeft +nnoremap fJ :FSSplitBelow +nnoremap fK :FSSplitAbove " fugitive {{{2 nmap dd :tab split \| Gdiff \| wincmd h @@ -430,7 +457,7 @@ autocmd BufReadPost fugitive://* set bufhidden=delete nnoremap gs :Gstatus nnoremap gd :Gdiff -nnoremap gc :tab Gcommit -v +nnoremap gc :Gcommit -v nnoremap ga :Gwrite nnoremap gb :Gblame @@ -444,15 +471,6 @@ nmap cog IndentGuidesToggle nmap [og IndentGuidesEnable nmap ]og IndentGuidesDisable -" NERDTree {{{2 -" open/close NERDTree with \e -nmap e :NERDTreeToggle -nmap :NERDTreeToggle -" to open files/dirs -let NERDTreeMapActivateNode='l' -" close vim if only NERDTree is open -autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif - " python-mode {{{2 let g:pymode_rope_completion = 0 @@ -482,7 +500,7 @@ let g:tagbar_autoshowtag = 1 let g:tagbar_width = 25 let g:tagbar_iconchars = ['+', '-'] -" UltiSnips {{{2 +" ultisnips {{{2 let g:UltiSnipsEditSplit = 'vertical' let g:UltiSnipsSnippetsDir = expand("$XDG_CONFIG_HOME/vim/ultisnips") let g:UltiSnipsSnippetDirectories = ["UltiSnips", "ultisnips"] @@ -512,6 +530,53 @@ endfunction au InsertEnter * exec "inoremap " . g:UltiSnipsExpandTrigger . " =g:UltiSnips_Complete()" let g:UltiSnipsListSnippets="" +" unite {{{2 +call unite#filters#matcher_default#use(['matcher_fuzzy']) +call unite#custom#profile('default', 'context', { + \ 'winheight': 20, + \ 'direction': 'botright' + \ }) + +nnoremap [unite] +nmap u [unite] + +" unite-grep {{{3 +" seems not respected +let g:unite_source_grep_max_candidates = 2000 +if executable('ag') + " Use ag in unite grep source. + let g:unite_source_grep_command = 'ag' + let g:unite_source_grep_default_opts = '--smart-case -w --vimgrep --hidden --ignore ''.hg'' --ignore ''.svn'' --ignore ''.git'' --ignore ''.bzr''' + let g:unite_source_grep_recursive_opt = '' +end +nnoremap [unite]a :Unite grep -input= +command! -nargs=1 Ag Unite grep -input= + +" unite-file_rec {{{3 +if executable('ag') + " Use ag in unite rec source + let g:unite_source_rec_async_command = 'ag --follow --nocolor --nogroup --hidden -g ""' +end +nnoremap [unite]f :Unite -start-insert file_rec/async + +" unite-buffer {{{3 +call unite#custom#default_action('buffer', 'goto') +nnoremap [unite]b :Unite buffer + +" unite-menu {{{3 +let g:unite_source_menu_menus = {} +let g:unite_source_menu_menus.fugitive = { 'description' : 'fugitive menu'} +let g:unite_source_menu_menus.fugitive.command_candidates = { + \ 'Gstatus gs' : 'Gstatus', + \ 'Gcommit -v gc' : 'Gcommit -v', + \ 'Glog' : 'Glog', + \} + +nnoremap gg :Unite menu:fugitive + +let g:unite_source_history_yank_enable = 1 +nnoremap [unite]p :Unite history/yank + " yankring {{{2 nnoremap p :YRShow let g:yankring_history_dir = expand('$XDG_CACHE_HOME/vim') @@ -528,13 +593,14 @@ let g:ycm_extra_conf_globlist = ['~/src/*','/mnt/data/src/*'] let g:ycm_global_ycm_extra_conf = expand('$XDG_CONFIG_HOME/vim/ycm_extra_conf.py') let g:ycm_extra_conf_vim_data = ['getcwd()'] let g:ycm_add_preview_to_completeopt = 1 -let g:ycm_autoclose_preview_window_after_insertion = 1 +let g:ycm_autoclose_preview_window_after_insertion = 0 "let g:ycm_extra_conf_vim_data = ['%:p'] nnoremap jd :YcmCompleter GoTo " vim-easy-align {{{2 " start interactive EasyAlign in visual mode vmap (EasyAlign) +nmap ga (EasyAlign) " vim-json {{{2 let g:vim_json_syntax_conceal = 0 @@ -573,6 +639,28 @@ if !exists(":DiffOrig") \ | wincmd p | diffthis endif +" edit configs {{{2 +function! EditConfig(what) + let l:dir = split(&runtimepath,',')[0] + if a:what == 'vimrc' + let l:file = expand($MYVIMRC) + elseif ! isdirectory(globpath(l:dir, a:what)) + echoe a:what." is not valid!" + elseif empty(&filetype) + echoe 'filetype is empty!' + else + let l:file = l:dir.'/'.a:what.'/'.&filetype.'.vim' + endif + + execute ':vsplit '.file + execute ':lcd %:p:h' +endf +nmap ev :call EditConfig('vimrc') +nmap ef :call EditConfig('ftplugin') +nmap es :call EditConfig('syntax') +nmap ei :call EditConfig('indent') +nmap eu :UltiSnipsEdit:lcd %:p:h + " spell check {{{2 " http://tex.stackexchange.com/a/52932 let g:myLangList=["en_gb","en_us","de","fr"] @@ -602,3 +690,23 @@ endfunction nnoremap coS :call SwitchSpell() " fix spelling with first choice nnoremap f 1z= + +" gitdir or home {{{2 +" from derek wyatt: +" http://git.io/v3GAV +function! FindGitDirOrHome() + let filedir = expand('%:p:h') + if isdirectory(filedir) + let cmd = 'bash -c "(cd ' . filedir . '; git rev-parse --show-toplevel 2>/dev/null)"' + let gitdir = system(cmd) + if strlen(gitdir) == 0 + return '~' + else + return gitdir[:-2] + endif + else + return '~' + endif +endfunction + +" vim:set et sw=2 ts=2 tw=78: