3 " Author: Samir Benmendil <samir.benmendil[at]gmail[dot]com>
8 set runtimepath& " reset rtp
9 " remove all autocommands
12 set runtimepath+=$XDG_DATA_HOME/vim/vundle
13 call vundle#begin('$XDG_DATA_HOME/vim')
15 Plugin 'gmarik/vundle'
17 Plugin 'AndrewRadev/switch.vim'
18 Plugin 'airblade/vim-gitgutter'
19 Plugin 'bling/vim-airline'
20 Plugin 'chrisbra/checkattach'
21 Plugin 'derekwyatt/vim-fswitch'
22 Plugin 'elzr/vim-json'
23 Plugin 'firef0x/pkgbuild.vim'
24 Plugin 'junegunn/vim-easy-align'
25 Plugin 'justinmk/vim-sneak'
26 Plugin 'klen/python-mode'
27 Plugin 'kshenoy/vim-signature'
28 Plugin 'majutsushi/tagbar'
29 Plugin 'octol/vim-cpp-enhanced-highlight'
30 Plugin 'raimondi/delimitmate'
31 Plugin 'rdnetto/ycm-generator'
32 Plugin 'scrooloose/syntastic'
33 Plugin 'shougo/unite.vim'
34 Plugin 'shougo/vimproc.vim'
35 Plugin 'sjl/gundo.vim'
36 Plugin 'tomtom/tcomment_vim'
37 Plugin 'tpope/vim-abolish'
38 Plugin 'tpope/vim-endwise'
39 Plugin 'tpope/vim-eunuch'
40 Plugin 'tpope/vim-fugitive'
41 Plugin 'tpope/vim-repeat'
42 Plugin 'tpope/vim-surround' "investigate vim-sandwich
43 Plugin 'tpope/vim-unimpaired'
44 Plugin 'tweekmonster/spellrotate.vim'
45 Plugin 'valloric/youcompleteme'
46 Plugin 'vim-scripts/mediawiki.vim'
47 Plugin 'vim-scripts/replacewithregister'
48 Plugin 'vim-scripts/yankring.vim'
51 Plugin 'flazz/vim-colorschemes'
54 Plugin 'sirver/ultisnips'
55 Plugin 'honza/vim-snippets'
58 Plugin 'kana/vim-textobj-user'
59 Plugin 'julian/vim-textobj-variable-segment'
60 Plugin 'sgur/vim-textobj-parameter'
61 Plugin 'kana/vim-operator-user'
64 Plugin 'ompugao/ros.vim'
65 Plugin 'ompugao/ctrlp-ros'
68 " find an alternative (latex-box? Automatic Latex Plugin?)
69 Plugin 'vim-latex/vim-latex'
71 Plugin 'derekwyatt/vim-protodef'
72 Plugin 'ram-z/vim-clang-format'
73 Plugin 'sgeb/vim-diff-fold'
74 " needs editing colorscheme
75 " Plugin 'jeaye/color_coded'
76 " Check LucHermites plugins: https://github.com/LucHermitte/lh-cpp
77 Plugin 'wincent/loupe'
78 Plugin 'ram-z/vimwiki'
79 Plugin 'alepez/vim-gtest'
83 " remove entries first
84 set runtimepath -=$HOME/.vim
85 set runtimepath -=$HOME/.vim/after
86 set runtimepath -=$XDG_CONFIG_HOME/vim
87 set runtimepath -=$XDG_CONFIG_HOME/vim/after
88 " then prepend and append them
89 set runtimepath ^=$XDG_CONFIG_HOME/vim
90 set runtimepath +=$XDG_CONFIG_HOME/vim/after
92 filetype plugin indent on
99 " moving around, searching and patterns {{{2
100 set incsearch " show match for partly typed search command
101 set ignorecase " ignore case when using a search pattern
102 set smartcase " override 'ignorecase' when pattern has upper case characters
103 set hlsearch " highlight all matches for the last used search pattern
105 set nostartofline " don't move the cursor to the first non-blank char of a line
108 set path+=../include/
109 set path+=/usr/include/c++/*
111 " displaying text {{{2
112 set nowrap " long lines wrap
113 set linebreak " wrap long lines at a character in 'breakat'
114 set showbreak=↪ " show these chars for wrapped lines
115 set breakindent " preserve indentation in wrapped text
117 set lazyredraw " don't redraw while executing macros
119 set list " show chars defined in 'listchars'
120 set listchars=tab:❭\ " list of strings used for list mode
121 set listchars+=extends:❯,precedes:❮
122 " Only shown when not in insert mode
123 au InsertLeave * :set listchars+=trail:·
126 au InsertEnter * :set listchars-=trail:·
127 au InsertLeave * :set listchars+=trail:·
130 set scrolloff=5 " number of screen lines to show around the cursor
131 set sidescroll=1 " number of collumns to scroll
132 set sidescrolloff=1 " don't scroll over the listchars
134 set fillchars=diff:⣿,vert:│
136 set nonumber " show the line number for each line
137 set norelativenumber " show the relative line number for each line
139 " syntax, highlighting and spelling {{{2
140 set synmaxcol=800 " don't highlight long lines
142 set dictionary=spell " list of dictionary files for keyword completion
146 " multiple windows {{{2
147 set laststatus=2 " 0, 1 or 2; when to use a status line for the last window
149 set previewheight=20 " default height for the preview window
153 " set splitbelow " a new window is put below of the current one
154 set splitright " a new window is put right of the current one
159 " using the mouse {{{2
160 set mouse=rnv " list of flags for using the mouse
161 set ttymouse=xterm " type of mouse
163 " messages and info {{{2
164 set showcmd " Show (partial) command in status line.
165 set ruler " show the cursor position all the time
166 set confirm " Ask what to do when closing unsaved documents
167 set shortmess= " reset option
168 set shortmess+=a " all abbreviations
169 set shortmess+=o " overwrite file-written message
170 set shortmess+=O " file-read message overrides previous
171 set shortmess+=t " truncate file message at start
172 set shortmess+=T " truncate other messages in the middle
173 set shortmess+=W " don't give 'written' or '[w]' when writing a file
174 set shortmess+=A " ignore swapfile warning
175 set shortmess+=I " no splash screen
178 set backspace=indent,eol,start " allow backspacing over everything in insert mode
180 set showmatch " Show matching brackets.
182 set nojoinspaces " don't use two spaces after '.' when joining a line
183 set formatoptions+=j " Delete comment leader when joining lines
184 set formatoptions+=c " Autowrap comments using textwidth
185 set formatoptions+=r " Insert comment leader after hitting <Enter>
186 set formatoptions+=n " Recognize numbered lists
187 set formatoptions+=q " Allow formatting of comments with "gq".
188 set formatoptions+=l " do not wrap lines that have been longer when starting insert mode already
189 set formatoptions+=t " Auto-wrap text using textwidth
190 set formatoptions-=o " Do not insert comment leader after hitting o or O in normal mode
192 set nrformats=hex " number formats recognized for CTRL-A and CTRL-X commands
194 set complete=. " scan the current buffer ( 'wrapscan' is ignored)
195 set complete+=w " scan buffers from other windows
196 set complete+=b " scan other loaded buffers that are in the buffer list
197 set complete+=u " scan the unloaded buffers that are in the buffer list
198 set complete+=t " scan tags
199 set complete+=i " scan current and included files
200 set complete+=kspell " use the currently active spell checking |spell|
202 " whether to use a popup menu for Insert mode completion
203 set completeopt=longest,menuone,preview
205 " tabs and indent {{{2
206 set shiftwidth=4 " number of spaces used for each step of (auto)indent
207 set smarttab " a <Tab> in an indent inserts 'shiftwidth' spaces
208 set softtabstop=4 " if non-zero, number of spaces to insert for a <Tab>
209 set shiftround " round to 'shiftwidth' for "<<" and ">>"
210 set expandtab " expand <Tab> to spaces in Insert mode
213 set pastetoggle=<F11> " key sequence to toggle paste mode
216 set foldmethod=marker " folding type
217 set foldlevelstart=0 " value for 'foldlevel' when starting to edit a file
219 " open folds when jumping to line
222 set viewoptions=cursor " save cursor position
223 set viewoptions+=folds " save folds
226 set diffopt+=filler " show filler lines
227 set diffopt+=vertical " always vertical split
228 set diffopt+=context:10 " 10 lines context between changes
230 " reading and writing files {{{2
231 set modeline " read modelines
232 set modelines=2 " only check first/last 2 lines
234 set writebackup " write a backup file before overwriting a file
235 set backup " keep a backup after owerwriting a file
236 set backupdir=$XDG_CACHE_HOME/vim/backup//
238 set backupskip+=.netrc " skip netrc
239 set backupskip+=/dev/shm/pass* " skip passwordstore files
241 set undofile " persistent undo history
242 set undodir=$XDG_CACHE_HOME/vim/undo//
246 au BufWritePre .netrc setlocal noundofile
247 au BufWritePre /dev/shm/pass* setlocal noundofile
248 au BufWritePre /tmp/* setlocal noundofile
251 set autowrite " automatically write a file when leaving a modified buffer
252 set autoread " automatically read a file that has been modified
256 set directory=$XDG_CACHE_HOME/vim/swap//
258 " command line editing {{{2
259 set history=5000 " how many command lines are remembered
260 set wildmenu " command-line completion shows a list of matches
261 set wildmode=longest:full,full " specifies how command line completion works
262 set wildignorecase " ignore case when completing file names
264 set wildignore+=.hg,.git,.svn " Version control
265 set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
266 set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
267 set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
268 set wildignore+=*.spl " compiled spelling word lists
269 set wildignore+=*.sw? " Vim swap files
270 set wildignore+=*.luac " Lua byte code
271 set wildignore+=*.pyc " Python byte code
272 set wildignore+=*.orig " Merge resolution files
274 " running make and jumping to errors {{{2
275 set makeprg=make\ -w " print changing directories
277 set grepprg=ag\ --vimgrep\ $*
279 " language specific {{{2
280 set isfname-== " don't treat `=` as being part of filenames
283 set virtualedit+=block " let cursor move past last char in <C-V> mode
284 set virtualedit+=onemore " allow the cursor to move just past the end of the line
285 set viminfo='100,<50,s10,h,n$XDG_CACHE_HOME/vim/viminfo " viminfo defaults but save file in .cache
287 set viewdir=$XDG_CACHE_HOME/vim/view//
289 set sessionoptions+=unix,slash " damn windows and it's silly ways
292 " Resize splits when the window is resized {{{2
295 autocmd VimResized * :wincmd =
298 " Only show cursorline in the current window and in normal mode {{{2
301 au WinLeave,InsertEnter * set nocursorline
302 au WinEnter,InsertLeave * set cursorline
305 " Treat buffers from stdin (e.g.: echo foo | vim -) as scratch {{{2
308 au StdinReadPost * :set buftype=nofile
311 " Jump to last known cursor position {{{2
314 " blacklist certain filetype
315 let blacklist = ['gitcommit']
316 autocmd BufReadPost *
317 \ if index(blacklist, &ft) < 0 && line("'\"") > 1 && line("'\"") <= line("$") |
318 \ exe "normal! g`\"" |
322 " Check for file modifications automatically {{{2
323 " (current buffer only)
324 " Use :NoAutoChecktime to disable it (uses b:autochecktime)
325 fun! MyAutoCheckTime()
326 " only check timestamp for normal files
327 if &buftype != '' | return | endif
328 if ! exists('b:autochecktime') || b:autochecktime
330 let b:autochecktime = 1
333 augroup MyAutoChecktime
335 au FocusGained,BufEnter,CursorHold,InsertEnter * call MyAutoCheckTime()
337 command! NoAutoChecktime let b:autochecktime=0
338 command! ToggleAutoChecktime let b:autochecktime=!get(b:, 'autochecktime', 0) | echom "b:autochecktime:" b:autochecktime
342 " allow both <space> and \ to be <leader>
346 nnoremap <leader>r :make!<cr>
347 nnoremap <leader><cr> :make!<cr>
350 nnoremap <silent> <Leader>/ :silent nohl<CR>
353 nnoremap <leader>[ :tabprev<cr>
354 nnoremap <leader>] :tabnext<cr>
356 " paste from selection
357 nnoremap <leader>p* :silent! set paste<CR>"*p:set nopaste<CR>
358 " paste from clipboard
359 nnoremap <leader>p+ :silent! set paste<CR>"+p:set nopaste<CR>
361 " strip trailing whitespace
362 function! StripWhitespace(line1, line2, ...) " {{{2
363 let s_report = &report
365 let pattern = a:0 ? a:1 : '\s\+$'
366 let oldview = winsaveview()
367 exe 'keepjumps keeppatterns '.a:line1.','.a:line2.'substitute/'.pattern.'//e'
368 if oldview != winsaveview()
371 call winrestview(oldview)
372 let &report = s_report
374 command! -range=% -nargs=0 -bar Untrail keepjumps call StripWhitespace(<line1>,<line2>)
375 nnoremap <silent> <leader>ww :Untrail<CR>
378 vnoremap <leader>S y:execute @@<cr>:echo 'Sourced selection.'<cr>
379 nnoremap <leader>S ^vg_y:execute @@<cr>:echo 'Sourced line.'<cr>
381 " jump to last cursor position
384 " Select (charwise) the contents of the current line, excluding indentation.
388 nnoremap U :syntax sync fromstart<cr>:AirlineRefresh<cr>:redraw!<cr>
391 " nnoremap <leader>r :silent !ranger %:h<cr>:redraw!<cr>
392 " nnoremap <leader>R :silent !ranger<cr>:redraw!<cr>
399 " display the number of matches for the last search
400 nmap <Leader># :%s:<C-R>/::gn<CR>
402 " center cursor after search and open folds
406 " same when jumping around
409 nnoremap <c-o> <c-o>zzzv
410 nnoremap <c-i> <c-i>zzzv
412 " Not using the default mappings of 'To line from top/bottom'
418 " Heresy, emacs insert bindings
419 inoremap <C-A> <Esc>I
420 inoremap <C-E> <Esc>A
421 cnoremap <C-A> <Home>
424 " proper movement when lines are wrapped
425 noremap <expr> j (v:count == 0 ? 'gj' : 'j')
426 noremap <expr> k (v:count == 0 ? 'gk' : 'k')
432 noremap <Right> <NOP>
434 inoremap <Down> <NOP>
435 inoremap <Left> <NOP>
436 inoremap <Right> <NOP>
438 cnoremap <Down> <NOP>
439 cnoremap <Left> <NOP>
440 cnoremap <Right> <NOP>
442 cnoremap <C-J> <Down>
443 cnoremap <C-H> <Left>
444 cnoremap <C-L> <Right>
446 " close all folds open fold in cursor
449 map <F1> :ls<CR>:b<space>
451 " move between windows (skip previewwindow)
452 nnoremap <silent> <C-L> <C-W>w:if &previewwindow \| wincmd w \| endif<CR>
453 nnoremap <silent> <C-H> <C-W>W:if &previewwindow \| wincmd W \| endif<CR>
455 "xterm mouse with middleclick paste
456 nnoremap <MiddleMouse> i<MiddleMouse>
457 vnoremap <MiddleMouse> s<MiddleMouse>
459 " fix legacy vi inconsistency
464 " allow repeat operator on visual
465 vnoremap . :normal .<CR>
467 " add line without changing position or leaving mode
468 noremap <silent> <Leader>o :set paste<CR>m`o<ESC>``:set nopaste<CR>
469 noremap <silent> <Leader>O :set paste<CR>m`O<ESC>``:set nopaste<CR>
471 " Don't use Ex mode, use Q for formatting
474 " break undo sequence before removing word
475 inoremap <C-W> <C-G>u<C-W>
477 nnoremap coe :set <C-R>=&expandtab ? 'noexpandtab' : 'expandtab'<CR><CR>
478 nnoremap [oe :set expandtab<CR>
479 nnoremap ]oe :set noexpandtab<CR>
481 for idt in range(1,8)
482 exe 'nnoremap co'.idt.' :setlocal tabstop='.idt.' shiftwidth='.idt.' softtabstop='.idt.'<CR>'
485 " toggle auto format of text
486 nnoremap coa :set <C-R>=&formatoptions =~ "a" ? 'formatoptions-=a' : 'formatoptions+=a'<CR><CR>
487 nnoremap [oa :set formatoptions+=a<CR>
488 nnoremap ]oa :set formatoptions-=a<CR>
490 " space will toggle current fold in normal mode
491 nnoremap <leader><Space> za
492 " create folds around visual selection
493 vnoremap <leader><Space> zf
496 cabbrev w!! w !sudo tee % > /dev/null
498 " uppercase previous word
499 inoremap <C-C> <Esc>gUiwgi
501 " http://git.io/v3ZeU
502 nmap <silent> <leader>qq :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR>
504 " plugins options {{{1
506 let g:airline#extensions#whitespace#enabled = 1
507 let g:airline#extensions#tabline#enabled = 1
508 let g:airline_powerline_fonts = 1
511 let g:checkattach_filebrowser = 'ranger'
512 let g:checkattach_once = 'y'
515 let delimitMate_expand_cr = 2
516 let g:delimitMate_expand_space = 1
519 nnoremap <silent> <Leader>ff :FSHere<CR>
520 nnoremap <silent> <Leader>fl :FSRight<CR>
521 nnoremap <silent> <Leader>fh :FSLeft<CR>
522 nnoremap <silent> <Leader>fj :FSBelow<CR>
523 nnoremap <silent> <Leader>fk :FSAbove<CR>
524 nnoremap <silent> <Leader>fL :FSSplitRight<CR>
525 nnoremap <silent> <Leader>fH :FSSplitLeft<CR>
526 nnoremap <silent> <Leader>fJ :FSSplitBelow<CR>
527 nnoremap <silent> <Leader>fK :FSSplitAbove<CR>
530 nmap <silent> <leader>dd :tab split \| Gdiff \| wincmd h<CR>
531 " delete fugitive buffers when closed
532 autocmd BufReadPost fugitive://* set bufhidden=delete
534 nnoremap <silent> <leader>gs :Gstatus<CR>
535 nnoremap <silent> <leader>gd :Gdiff<CR>
536 nnoremap <silent> <leader>gc :Gcommit -v<CR>
537 nnoremap <silent> <leader>ga :Gwrite<cr>
538 nnoremap <silent> <leader>gb :Gblame<cr>
541 nnoremap <F7> :GundoToggle<CR>
544 let g:indent_guides_default_mapping = 0
545 let g:indent_guides_guide_size = 1
546 nmap <silent> cog <Plug>IndentGuidesToggle
547 nmap <silent> [og <Plug>IndentGuidesEnable
548 nmap <silent> ]og <Plug>IndentGuidesDisable
550 " close-another-window {{{2
551 nnoremap <silent> <C-W>c <NOP>
552 nnoremap <silent> <C-W>cc <C-W>c
553 nnoremap <silent> <C-W>ch :CloseLeftWindow<CR>
554 nnoremap <silent> <C-W>cl :CloseRightWindow<CR>
555 nnoremap <silent> <C-W>cj :CloseBelowWindow<CR>
556 nnoremap <silent> <C-W>ck :CloseAboveWindow<CR>
560 let g:pymode_rope_completion = 0
561 let g:pymode_rope = 0
563 let g:pymode_folding = 1
564 let g:pymode_lint_ignore = "E221,E266,E501"
565 let g:pymode_lint_cwindow = 0 " don't open cwindow when linting
566 let g:pymode_syntax_space_errors = 0 " don't bother me when I'm typing
569 " disable '[ mappings
571 let g:SignatureMap = {
572 \ 'GotoNextLineAlpha' : "",
573 \ 'GotoPrevLineAlpha' : "",
574 \ 'GotoNextSpotAlpha' : "",
575 \ 'GotoPrevSpotAlpha' : "",
579 let g:switch_mapping = "<Leader>s"
582 nmap <silent> z] <Plug>(SpellRotateForward)
583 nmap <silent> z[ <Plug>(SpellRotateBackward)
584 vmap <silent> z] <Plug>(SpellRotateForwardV)
585 vmap <silent> z[ <Plug>(SpellRotateBackwardV)
588 let g:syntastic_enable_highlighting = 0
589 let g:syntastic_error_symbol='E'
590 let g:syntastic_style_error_symbol='S'
591 let g:syntastic_warning_symbol='W'
592 let g:syntastic_style_warning_symbol='S'
593 let g:syntastic_always_populate_loc_list=1
594 nmap <silent> <leader>y :SyntasticCheck<cr>
597 let g:syntastic_check_on_open=1
601 map <F5> :TagbarToggle<cr>
602 let g:tagbar_sort = 0
603 let g:tagbar_compact = 1
604 let g:tagbar_autoshowtag = 1
605 let g:tagbar_width = 25
606 let g:tagbar_iconchars = ['+', '-']
609 let g:tcommentTextObjectInlineComment = 'gic'
612 let g:UltiSnipsEditSplit = 'vertical'
613 let g:UltiSnipsSnippetsDir = expand("$XDG_CONFIG_HOME/vim/ultisnips")
615 let g:UltiSnipsSnippetDirectories = ["UltiSnips", "ultisnips"]
617 let g:UltiSnipsExpandTrigger = "<tab>"
618 let g:UltiSnipsJumpForwardTrigger = "<tab>"
619 let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
621 " UltiSnips completion function that tries to expand a snippet. If there's no
622 " snippet for expanding, it checks for completion window and if it's shown,
623 " selects first element. If there's no completion window it tries to jump to
624 " next placeholder. If there's no placeholder it just returns TAB key
625 " https://github.com/Valloric/YouCompleteMe/issues/36#issuecomment-15451411
626 function! g:UltiSnips_Complete()
627 call UltiSnips#ExpandSnippet()
628 if g:ulti_expand_res == 0
632 call UltiSnips#JumpForwards()
633 if g:ulti_jump_forwards_res == 0
640 au InsertEnter * exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=g:UltiSnips_Complete()<cr>"
641 let g:UltiSnipsListSnippets="<c-e>"
644 call unite#filters#matcher_default#use(['matcher_fuzzy'])
645 call unite#custom#profile('default', 'context', {
647 \ 'direction': 'botright'
650 nnoremap [unite] <Nop>
651 nmap <leader>u [unite]
652 nnoremap [unite]u :UniteResume<CR>
655 " seems not respected
656 let g:unite_source_grep_max_candidates = 2000
658 " Use ag in unite grep source.
659 let g:unite_source_grep_command = 'ag'
660 let g:unite_source_grep_default_opts = '--smart-case --vimgrep --ignore ''.hg'' --ignore ''.svn'' --ignore ''.git'' --ignore ''.bzr'''
661 let g:unite_source_grep_recursive_opt = ''
663 nnoremap <silent> [unite]a :<C-u>Unite grep:.::
\12\17<CR>
664 command! -nargs=1 Ag Unite grep:.::<args>
666 " unite-file_rec {{{3
668 " Use ag in unite rec source
669 let g:unite_source_rec_async_command = ['ag', '--follow', '--nocolor', '--nogroup', '-g', '']
671 nnoremap <silent> [unite]f :<C-u>Unite -start-insert file_rec/async<CR>
672 call unite#custom#source('file_rec/async', 'sorters', 'sorter_selecta')
675 call unite#custom#default_action('buffer', 'open')
676 nnoremap <silent> [unite]b :<C-u>Unite buffer:-<CR>
679 let g:unite_source_menu_menus = {}
680 let g:unite_source_menu_menus.fugitive = { 'description' : 'fugitive menu'}
681 let g:unite_source_menu_menus.fugitive.command_candidates = {
682 \ 'Gstatus <Leader>gs' : 'Gstatus',
683 \ 'Gcommit -v <Leader>gc' : 'Gcommit -v',
687 nnoremap <silent> <leader>gg :<C-u>Unite menu:fugitive<CR>
689 let g:unite_source_history_yank_enable = 1
690 nnoremap <silent> [unite]p :<C-u>Unite history/yank<CR>
693 nnoremap <silent> <leader>p :YRShow<cr>
694 let g:yankring_history_dir = expand('$XDG_CACHE_HOME/vim')
695 let g:yankring_replace_n_pkey = ''
696 let g:yankring_replace_n_nkey = ''
698 " map Y to y$ for the yank ring
699 function! YRRunAfterMaps()
700 nnoremap Y :<C-U>YRYankCount 'y$'<CR>
704 let g:ycm_extra_conf_globlist = ['~/src/*','/mnt/data/src/*']
705 let g:ycm_global_ycm_extra_conf = expand('$XDG_CONFIG_HOME/vim/ycm_extra_conf.py')
706 let g:ycm_extra_conf_vim_data = ['getcwd()']
707 let g:ycm_add_preview_to_completeopt = 1
708 let g:ycm_complete_in_comments = 1
709 let g:ycm_complete_in_strings = 1
710 let g:ycm_autoclose_preview_window_after_insertion = 0
711 "let g:ycm_extra_conf_vim_data = ['%:p']
713 " vim-easy-align {{{2
714 " start interactive EasyAlign in visual mode
715 vmap <Enter> <Plug>(EasyAlign)
716 nmap ga <Plug>(EasyAlign)
719 let g:gtest#highlight_failing_tests = 0
721 nnoremap <Leader>tt :GTestRun<CR>
722 nnoremap <Leader>tu :GTestRunUnderCursor<CR>
725 let g:vim_json_syntax_conceal = 0
728 let g:tex_flavor='latex'
729 let g:Tex_DefaultTargetFormat='pdf'
730 let g:Tex_MultipleCompileFormats='pdf'
733 let g:sneak#streak = 1
734 let g:sneak#target_labels = "aoeuisnthdpylrcgfqjkxzmwvz" " dvorak
735 let g:sneak#use_ic_scs = 1 " follow 'ignorecase' and 'smartcase'
752 let g:vimwiki_list = [{'path': '$XDG_DATA_HOME/vimwiki'}]
753 let g:vimwiki_auto_chdir = 1
755 au! BufRead $XDG_DATA_HOME/vimwiki/index.wiki !git -C "%:p:h" pull -q
756 au! BufRead,BufNewFile $XDG_DATA_HOME/vimwiki/diary/*.wiki !git -C "%:p:h" pull -q
757 au! BufWritePost $XDG_DATA_HOME/vimwiki/*.wiki exe '!git add "<afile>";git commit -qm"' . strftime("%FT%R") . '";git push -q'
762 " Convenient command to see the difference between the current buffer and the
763 " file it was loaded from, thus the changes you made.
764 " Only define it when not defined already.
765 if !exists(":DiffOrig")
766 command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
767 \ | wincmd p | diffthis
771 function! SortLinesOpFunc(...)
774 nnoremap <silent> gs :<C-U>set operatorfunc=SortLinesOpFunc<CR>g@
775 vnoremap <silent> gs :sort<cr>
778 function! EditConfig(what)
779 let l:dir = split(&runtimepath,',')[0]
781 let l:file = expand($MYVIMRC)
782 elseif ! isdirectory(globpath(l:dir, a:what))
783 echoe a:what." is not valid!"
784 elseif empty(&filetype)
785 echoe 'filetype is empty!'
787 let l:file = l:dir.'/'.a:what.'/'.&filetype.'.vim'
790 execute ':vsplit '.file
793 nmap <leader>ev :call EditConfig('vimrc')<CR>
794 nmap <leader>ef :call EditConfig('ftplugin')<CR>
795 nmap <leader>es :call EditConfig('syntax')<CR>
796 nmap <leader>ei :call EditConfig('indent')<CR>
797 nmap <leader>eu :UltiSnipsEdit<CR>:lcd %:p:h<CR>
800 " http://tex.stackexchange.com/a/52932
801 let g:myLangList=["en_gb","en_us","de","fr"]
803 function! ToggleSpell()
804 if !exists("b:myLang")
807 execute "setlocal spell!"
809 echo "setlocal spelllang=" g:myLangList[b:myLang]
813 function! SwitchSpell()
814 if !exists("b:myLang")
818 let b:myLang=b:myLang+1
819 if b:myLang>=len(g:myLangList) | let b:myLang=0 | endif
821 execute "setlocal spell spelllang=".get(g:myLangList, b:myLang)
822 echo "setlocal spelllang=" g:myLangList[b:myLang]
825 nnoremap <silent> coS :call SwitchSpell()<CR>
826 " fix spelling with first choice
827 nnoremap <Leader>f 1z=
829 " gitdir or home {{{2
831 " http://git.io/v3GAV
832 function! FindGitDirOrHome()
833 let filedir = expand('%:p:h')
834 if isdirectory(filedir)
835 let cmd = 'bash -c "(cd ' . filedir . '; git rev-parse --show-toplevel 2>/dev/null)"'
836 let gitdir = system(cmd)
837 if strlen(gitdir) == 0
847 command! Cr execute('cd ' . FindGitDirOrHome())
849 command! LCr execute('lcd ' . FindGitDirOrHome())
851 " vim:set et sw=2 ts=2 tw=78: