3 " Author:   Samir Benmendil <samir.benmendil[at]gmail[dot]com>
 
   7 set runtimepath ^=$XDG_CONFIG_HOME/vim
 
   8 set runtimepath +=$XDG_CONFIG_HOME/vim/after
 
  11 if has('python3') | endif
 
  14 " remove all autocommands
 
  17 call plug#begin('$XDG_DATA_HOME/vim')
 
  18 " This does not update vim-plug, use PlugUpgrade instead
 
  19 Plug 'junegunn/vim-plug'
 
  21 Plug 'airblade/vim-gitgutter'
 
  22 Plug 'alepez/vim-gtest'
 
  24 Plug 'andrewradev/switch.vim'
 
  25 Plug 'bling/vim-airline'
 
  26 Plug 'chrisbra/checkattach'
 
  27 Plug 'derekwyatt/vim-fswitch'
 
  29 Plug 'firef0x/pkgbuild.vim'
 
  30 Plug 'junegunn/vim-easy-align'
 
  31 Plug 'justinmk/vim-sneak'
 
  32 Plug 'klen/python-mode'
 
  33 Plug 'kshenoy/vim-signature'
 
  34 Plug 'majutsushi/tagbar'
 
  35 Plug 'octol/vim-cpp-enhanced-highlight'
 
  36 Plug 'raimondi/delimitmate'
 
  37 Plug 'vimwiki/vimwiki', { 'branch': 'dev' }
 
  38 " Plug 'scrooloose/syntastic'
 
  39 Plug 'sgeb/vim-diff-fold'
 
  40 Plug 'shougo/unite.vim'
 
  41 Plug 'shougo/vimproc.vim', {'do': 'make'}
 
  43 Plug 'thinca/vim-qfreplace'
 
  44 Plug 'tomtom/tcomment_vim'
 
  45 Plug 'tpope/vim-abolish'
 
  46 Plug 'tpope/vim-endwise'
 
  47 Plug 'tpope/vim-eunuch'
 
  48 Plug 'tpope/vim-fugitive'
 
  49 Plug 'tpope/vim-repeat'
 
  50 Plug 'tpope/vim-scriptease'
 
  51 Plug 'tpope/vim-speeddating'
 
  52 Plug 'tpope/vim-surround'  "investigate vim-sandwich
 
  53 Plug 'tpope/vim-unimpaired'
 
  54 Plug 'tweekmonster/spellrotate.vim'
 
  55 Plug 'valloric/youcompleteme', { 'do': './install.py --clangd-completer --clang-completer' }
 
  56 Plug 'vim-scripts/mediawiki.vim'
 
  57 Plug 'vim-scripts/replacewithregister'
 
  58 Plug 'vim-scripts/yankring.vim'
 
  62 Plug 'morhetz/gruvbox'
 
  65 Plug 'sirver/ultisnips'
 
  66 Plug 'honza/vim-snippets'
 
  69 Plug 'kana/vim-textobj-user'
 
  70 Plug 'julian/vim-textobj-variable-segment'
 
  71 Plug 'sgur/vim-textobj-parameter'
 
  72 Plug 'kana/vim-operator-user'
 
  75 " Check LucHermites plugins: https://github.com/LucHermitte/lh-cpp
 
  76 Plug 'dense-analysis/ale' " {{{2
 
  77 let g:ale_echo_msg_format = '[%linter%] %code: %%s'
 
  78 let g:ale_c_parse_compile_commands = 1
 
  79 let g:ale_cpp_parse_compile_commands = 1
 
  80 " don't use loclist as it's being populated by ycm
 
  81 " (might want to enable for other filetypes)
 
  82 let g:ale_set_loclist = 0
 
  83 let g:ale_cpp_gcc_options = ''
 
  84 let g:ale_linters_ignore = { 'cpp': ['clangd', 'clangtidy', 'clang'] }
 
  86 Plug 'git@github.com:/ram-z/vim-orgmode', { 'branch': 'dev' } " {{{2
 
  87 Plug 'vim-scripts/syntaxrange'
 
  89 let g:org_agenda_files = ['~/org/*.org']
 
  93 filetype plugin indent on
 
  98 let g:gruvbox_contrast_dark  = 'hard'
 
  99 let g:gruvbox_contrast_light = 'soft'
 
 101 " override the background to be black
 
 102 highligh Normal ctermbg=None
 
 105 " moving around, searching and patterns {{{2
 
 106 set incsearch           " show match for partly typed search command
 
 107 set ignorecase          " ignore case when using a search pattern
 
 108 set smartcase           " override 'ignorecase' when pattern has upper case characters
 
 109 set hlsearch            " highlight all matches for the last used search pattern
 
 111 set nostartofline       " don't move the cursor to the first non-blank char of a line
 
 114 set path+=../include/
 
 115 set path+=/usr/include/c++/*
 
 117 " displaying text {{{2
 
 118 set nowrap                      " long lines wrap
 
 119 set linebreak                   " wrap long lines at a character in 'breakat'
 
 120 set showbreak=↪                 " show these chars for wrapped lines
 
 121 set breakindent                 " preserve indentation in wrapped text
 
 123 set lazyredraw                  " don't redraw while executing macros
 
 125 set list                        " show chars defined in 'listchars'
 
 126 set listchars=tab:❭\            " list of strings used for list mode
 
 127 set listchars+=extends:❯,precedes:❮
 
 128 " Only shown when not in insert mode
 
 129 set listchars+=trail:·
 
 132     au InsertEnter * :set listchars-=trail:·
 
 133     au InsertLeave * :set listchars+=trail:·
 
 136 set scrolloff=5                 " number of screen lines to show around the cursor
 
 137 set sidescroll=1                " number of collumns to scroll
 
 138 set sidescrolloff=1             " don't scroll over the listchars
 
 140 set fillchars=diff:⣿,vert:│
 
 142 set nonumber                    " show the line number for each line
 
 143 set norelativenumber            " show the relative line number for each line
 
 145 " syntax, highlighting and spelling {{{2
 
 146 set synmaxcol=800               " don't highlight long lines
 
 148 set dictionary=spell            " list of dictionary files for keyword completion
 
 152 " multiple windows {{{2
 
 153 set laststatus=2                " 0, 1 or 2; when to use a status line for the last window
 
 155 set previewheight=20            " default height for the preview window
 
 159 " set splitbelow                  " a new window is put below of the current one
 
 160 set splitright                  " a new window is put right of the current one
 
 165 " using the mouse {{{2
 
 166 set mouse=rnv                   " list of flags for using the mouse
 
 167 set ttymouse=xterm              " type of mouse
 
 169 " messages and info {{{2
 
 170 set showcmd         " Show (partial) command in status line.
 
 171 set ruler           " show the cursor position all the time
 
 172 set confirm         " Ask what to do when closing unsaved documents
 
 173 set shortmess=      " reset option
 
 174 set shortmess+=a    " all abbreviations
 
 175 set shortmess+=o    " overwrite file-written message
 
 176 set shortmess+=O    " file-read message overrides previous
 
 177 set shortmess+=t    " truncate file message at start
 
 178 set shortmess+=T    " truncate other messages in the middle
 
 179 set shortmess+=W    " don't give 'written' or '[w]' when writing a file
 
 180 set shortmess+=A    " ignore swapfile warning
 
 181 set shortmess+=I    " no splash screen
 
 184 set backspace=indent,eol,start  " allow backspacing over everything in insert mode
 
 186 set showmatch                   " Show matching brackets.
 
 188 set nojoinspaces                " don't use two spaces after '.' when joining a line
 
 189 set formatoptions+=j    " Delete comment leader when joining lines
 
 190 set formatoptions+=c    " Autowrap comments using textwidth
 
 191 set formatoptions+=r    " Insert comment leader after hitting <Enter>
 
 192 set formatoptions+=n    " Recognize numbered lists
 
 193 set formatoptions+=q    " Allow formatting of comments with "gq".
 
 194 set formatoptions+=l    " do not wrap lines that have been longer when starting insert mode already
 
 195 set formatoptions+=t    " Auto-wrap text using textwidth
 
 196 set formatoptions-=o    " Do not insert comment leader after hitting o or O in normal mode
 
 198 set nrformats=hex               " number formats recognized for CTRL-A and CTRL-X commands
 
 200 set complete=.       " scan the current buffer ( 'wrapscan' is ignored)
 
 201 set complete+=w      " scan buffers from other windows
 
 202 set complete+=b      " scan other loaded buffers that are in the buffer list
 
 203 set complete+=u      " scan the unloaded buffers that are in the buffer list
 
 204 set complete+=t      " scan tags
 
 205 set complete+=i      " scan current and included files
 
 206 set complete+=kspell " use the currently active spell checking |spell|
 
 208 " whether to use a popup menu for Insert mode completion
 
 209 set completeopt=longest,menuone,preview
 
 211 " tabs and indent {{{2
 
 212 set shiftwidth=4                " number of spaces used for each step of (auto)indent
 
 213 set smarttab                    " a <Tab> in an indent inserts 'shiftwidth' spaces
 
 214 set softtabstop=4               " if non-zero, number of spaces to insert for a <Tab>
 
 215 set shiftround                  " round to 'shiftwidth' for "<<" and ">>"
 
 216 set expandtab                   " expand <Tab> to spaces in Insert mode
 
 219 set pastetoggle=<F11>           " key sequence to toggle paste mode
 
 222 set foldmethod=marker           " folding type
 
 223 set foldlevelstart=0            " value for 'foldlevel' when starting to edit a file
 
 225 " open folds when jumping to line
 
 228 set viewoptions=cursor          " save cursor position
 
 229 set viewoptions+=folds          " save folds
 
 232 set diffopt+=filler         " show filler lines
 
 233 set diffopt+=vertical       " always vertical split
 
 234 set diffopt+=context:10     " 10 lines context between changes
 
 236 " reading and writing files {{{2
 
 237 set modeline                    " read modelines
 
 238 set modelines=2                 " only check first/last 2 lines
 
 240 set writebackup                 " write a backup file before overwriting a file
 
 241 set backup                      " keep a backup after owerwriting a file
 
 242 set backupdir=$XDG_CACHE_HOME/vim/backup//
 
 244 set backupskip+=.netrc          " skip netrc
 
 245 set backupskip+=/dev/shm/pass*  " skip passwordstore files
 
 247 set undofile                    " persistent undo history
 
 248 set undodir=$XDG_CACHE_HOME/vim/undo//
 
 252     au BufWritePre .netrc         setlocal noundofile
 
 253     au BufWritePre /dev/shm/pass* setlocal noundofile
 
 254     au BufWritePre /tmp/*         setlocal noundofile
 
 257 set autowrite                   " automatically write a file when leaving a modified buffer
 
 258 set autoread                    " automatically read a file that has been modified
 
 262 set directory=$XDG_CACHE_HOME/vim/swap//
 
 264 " command line editing {{{2
 
 265 set history=5000                " how many command lines are remembered
 
 266 set wildmenu                    " command-line completion shows a list of matches
 
 267 set wildmode=longest:full,full  " specifies how command line completion works
 
 268 set wildignorecase              " ignore case when completing file names
 
 270 set wildignore+=.hg,.git,.svn                    " Version control
 
 271 set wildignore+=*.aux,*.out,*.toc                " LaTeX intermediate files
 
 272 set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg   " binary images
 
 273 set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
 
 274 set wildignore+=*.spl                            " compiled spelling word lists
 
 275 set wildignore+=*.sw?                            " Vim swap files
 
 276 set wildignore+=*.luac                           " Lua byte code
 
 277 set wildignore+=*.pyc                            " Python byte code
 
 278 set wildignore+=*.orig                           " Merge resolution files
 
 280 " running make and jumping to errors {{{2
 
 281 set makeprg=make\ -w     " print changing directories
 
 283 set grepprg=ag\ --vimgrep\ $*
 
 285 " language specific {{{2
 
 286 set isfname-==    " don't treat `=` as being part of filenames
 
 289 set virtualedit+=block     " let cursor move past last char in <C-V> mode
 
 290 set virtualedit+=onemore   " allow the cursor to move just past the end of the line
 
 291 set viminfo='100,<50,s10,h,n$XDG_CACHE_HOME/vim/viminfo " viminfo defaults but save file in .cache
 
 293 set viewdir=$XDG_CACHE_HOME/vim/view//
 
 295 set sessionoptions+=unix,slash  " damn windows and it's silly ways
 
 298 " Resize splits when the window is resized {{{2
 
 301     autocmd VimResized * :wincmd =
 
 304 " Only show cursorline in the current window and in normal mode {{{2
 
 307     au WinLeave,InsertEnter * set nocursorline
 
 308     au WinEnter,InsertLeave * set cursorline
 
 311 " Treat buffers from stdin (e.g.: echo foo | vim -) as scratch {{{2
 
 314     au StdinReadPost * :set buftype=nofile
 
 317 " Jump to last known cursor position {{{2
 
 320     " blacklist certain filetype
 
 321     let blacklist = ['gitcommit']
 
 322     autocmd BufReadPost *
 
 323                 \ if index(blacklist, &ft) < 0 && line("'\"") > 1 && line("'\"") <= line("$") |
 
 324                 \   exe "normal! g`\"" |
 
 328 " Check for file modifications automatically {{{2
 
 329 " (current buffer only)
 
 330 " Use :NoAutoChecktime to disable it (uses b:autochecktime)
 
 331 fun! MyAutoCheckTime()
 
 332   " only check timestamp for normal files
 
 333   if &buftype != '' | return | endif
 
 334   if ! exists('b:autochecktime') || b:autochecktime
 
 336     let b:autochecktime = 1
 
 339 augroup MyAutoChecktime
 
 341   au FocusGained,BufEnter,CursorHold,InsertEnter * call MyAutoCheckTime()
 
 343 command! NoAutoChecktime let b:autochecktime=0
 
 344 command! ToggleAutoChecktime let b:autochecktime=!get(b:, 'autochecktime', 0) | echom "b:autochecktime:" b:autochecktime
 
 348   au TerminalOpen * if &buftype == 'terminal' | setlocal bufhidden=hide | endif
 
 353 " allow both <space> and \ to be <leader>
 
 359   if exists("b:make_dir")
 
 360     let l:make_dir = "-C ".b:make_dir
 
 361   elseif exists("g:make_dir")
 
 362     let l:make_dir = "-C ".g:make_dir
 
 365   let l:make_targets = ""
 
 366   if exists("g:make_targets")
 
 367     let l:make_targets = g:make_targets
 
 369   execute "make! ".l:make_dir." ".l:make_targets
 
 371 nnoremap <leader>r :call Make()<cr>
 
 374 nnoremap <silent> <Leader>/ :silent nohl<CR>
 
 377 nnoremap <leader>[ :tabprev<cr>
 
 378 nnoremap <leader>] :tabnext<cr>
 
 380 " paste from selection
 
 381 nnoremap <leader>p* :silent! set paste<CR>"*p:set nopaste<CR>
 
 382 " paste from clipboard
 
 383 nnoremap <leader>p+ :silent! set paste<CR>"+p:set nopaste<CR>
 
 385 " strip trailing whitespace
 
 386 function! StripWhitespace(line1, line2, ...)  " {{{2
 
 387   let s_report = &report
 
 389   let pattern = a:0 ? a:1 : '\s\+$'
 
 390   let oldview = winsaveview()
 
 391   exe 'keepjumps keeppatterns '.a:line1.','.a:line2.'substitute/'.pattern.'//e'
 
 392   if oldview != winsaveview()
 
 395   call winrestview(oldview)
 
 396   let &report = s_report
 
 398 command! -range=% -nargs=0 -bar Untrail keepjumps call StripWhitespace(<line1>,<line2>)
 
 399 nnoremap <silent> <leader>ww :Untrail<CR>
 
 402 vnoremap <leader>S y:execute @@<cr>:echo 'Sourced selection.'<cr>
 
 403 nnoremap <leader>S ^vg_y:execute @@<cr>:echo 'Sourced line.'<cr>
 
 405 " jump to last cursor position
 
 408 " Select (charwise) the contents of the current line, excluding indentation.
 
 412 nnoremap U :syntax sync fromstart<cr>:AirlineRefresh<cr>:redraw!<cr>
 
 415 " nnoremap <leader>r :silent !ranger %:h<cr>:redraw!<cr>
 
 416 " nnoremap <leader>R :silent !ranger<cr>:redraw!<cr>
 
 423 " display the number of matches for the last search
 
 424 nmap <Leader># :%s:<C-R>/::gn<CR>
 
 426 " center cursor after search and open folds
 
 430 " same when jumping around
 
 433 nnoremap <c-o> <c-o>zzzv
 
 434 nnoremap <c-i> <c-i>zzzv
 
 436 " Not using the default mappings of 'To line from top/bottom'
 
 442 " Heresy, emacs insert bindings
 
 443 inoremap <C-A> <Esc>I
 
 444 inoremap <C-E> <Esc>A
 
 445 cnoremap <C-A> <Home>
 
 448 " proper movement when lines are wrapped
 
 449 noremap <silent><expr> j (v:count == 0 ? 'gj' : 'j')
 
 450 noremap <silent><expr> k (v:count == 0 ? 'gk' : 'k')
 
 456 noremap  <Right> <NOP>
 
 458 inoremap <Down>  <NOP>
 
 459 inoremap <Left>  <NOP>
 
 460 inoremap <Right> <NOP>
 
 462 cnoremap <Down>  <NOP>
 
 463 cnoremap <Left>  <NOP>
 
 464 cnoremap <Right> <NOP>
 
 466 cnoremap <C-J>   <Down>
 
 467 cnoremap <C-H>   <Left>
 
 468 cnoremap <C-L>   <Right>
 
 470 " close all folds open fold in cursor
 
 473 map <F1> :ls<CR>:b<space>
 
 475 " move between windows (skip previewwindow)
 
 476 nnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
 
 477 nnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
 
 478 tnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
 
 479 tnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
 
 481 "xterm mouse with middleclick paste
 
 482 nnoremap <MiddleMouse> i<MiddleMouse>
 
 483 vnoremap <MiddleMouse> s<MiddleMouse>
 
 485 " fix legacy vi inconsistency
 
 490 " allow repeat operator on visual
 
 491 vnoremap . :normal .<CR>
 
 493 " add line without changing position or leaving mode
 
 494 noremap <silent> <Leader>o :set paste<CR>m`o<ESC>``:set nopaste<CR>
 
 495 noremap <silent> <Leader>O :set paste<CR>m`O<ESC>``:set nopaste<CR>
 
 497 " Don't use Ex mode, use Q for formatting
 
 500 " break undo sequence before removing word
 
 501 inoremap <C-W> <C-G>u<C-W>
 
 503 nnoremap coe :set <C-R>=&expandtab ? 'noexpandtab' : 'expandtab'<CR><CR>
 
 504 nnoremap [oe :set expandtab<CR>
 
 505 nnoremap ]oe :set noexpandtab<CR>
 
 507 for idt in range(1,8)
 
 508   exe 'nnoremap co'.idt.' :setlocal tabstop='.idt.' shiftwidth='.idt.' softtabstop='.idt.'<CR>'
 
 511 " toggle auto format of text
 
 512 nnoremap coa :set <C-R>=&formatoptions =~ "a" ? 'formatoptions-=a' : 'formatoptions+=a'<CR><CR>
 
 513 nnoremap [oa :set formatoptions+=a<CR>
 
 514 nnoremap ]oa :set formatoptions-=a<CR>
 
 516 " space will toggle current fold in normal mode
 
 517 nnoremap <leader><Space> za
 
 518 " create folds around visual selection
 
 519 vnoremap <leader><Space> zf
 
 522 cabbrev w!! SudoWrite
 
 524 " uppercase previous word
 
 525 inoremap <C-C> <Esc>gUiwgi
 
 527 " http://git.io/v3ZeU
 
 528 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>
 
 530 " plugins options {{{1
 
 532 let g:airline#extensions#whitespace#enabled = 1
 
 533 let g:airline#extensions#tabline#enabled = 1
 
 534 let g:airline_powerline_fonts = 1
 
 537 let g:checkattach_filebrowser = 'ranger'
 
 538 let g:checkattach_once = 'y'
 
 541 let delimitMate_expand_cr = 2
 
 542 let g:delimitMate_expand_space = 1
 
 545 nnoremap <silent> <Leader>ff :FSHere<CR>
 
 546 nnoremap <silent> <Leader>fl :FSRight<CR>
 
 547 nnoremap <silent> <Leader>fh :FSLeft<CR>
 
 548 nnoremap <silent> <Leader>fj :FSBelow<CR>
 
 549 nnoremap <silent> <Leader>fk :FSAbove<CR>
 
 550 nnoremap <silent> <Leader>fL :FSSplitRight<CR>
 
 551 nnoremap <silent> <Leader>fH :FSSplitLeft<CR>
 
 552 nnoremap <silent> <Leader>fJ :FSSplitBelow<CR>
 
 553 nnoremap <silent> <Leader>fK :FSSplitAbove<CR>
 
 556 nmap <silent> <leader>dd :tab split \| Gdiff \| wincmd h<CR>
 
 557 " delete fugitive buffers when closed
 
 558 autocmd BufReadPost fugitive://* set bufhidden=delete
 
 560 nnoremap <silent> <leader>gs :Gstatus<CR>
 
 561 nnoremap <silent> <leader>gd :Gdiff<CR>
 
 562 nnoremap <silent> <leader>gc :Gcommit -v<CR>
 
 563 nnoremap <silent> <leader>ga :Gwrite<cr>
 
 564 nnoremap <silent> <leader>gb :Gblame<cr>
 
 566 augroup fugitive_gstatus
 
 568     autocmd BufWinEnter */.git/index resize 16
 
 572 nnoremap <F7> :GundoToggle<CR>
 
 575 let g:indent_guides_default_mapping = 0
 
 576 let g:indent_guides_guide_size = 1
 
 577 nmap <silent> cog <Plug>IndentGuidesToggle
 
 578 nmap <silent> [og <Plug>IndentGuidesEnable
 
 579 nmap <silent> ]og <Plug>IndentGuidesDisable
 
 581 " close-another-window {{{2
 
 582 nnoremap <silent> <C-W>c  <NOP>
 
 583 nnoremap <silent> <C-W>cc <C-W>c
 
 584 nnoremap <silent> <C-W>ch :CloseLeftWindow<CR>
 
 585 nnoremap <silent> <C-W>cl :CloseRightWindow<CR>
 
 586 nnoremap <silent> <C-W>cj :CloseBelowWindow<CR>
 
 587 nnoremap <silent> <C-W>ck :CloseAboveWindow<CR>
 
 591 let g:pymode_rope_completion = 0
 
 592 let g:pymode_rope = 0
 
 594 let g:pymode_folding = 1
 
 595 let g:pymode_lint_ignore = "E221,E266,E501"
 
 596 let g:pymode_lint_cwindow = 0           " don't open cwindow when linting
 
 597 let g:pymode_syntax_space_errors = 0    " don't bother me when I'm typing
 
 600 " disable '[ mappings
 
 602 let g:SignatureMap = {
 
 603   \ 'GotoNextLineAlpha'  :  "",
 
 604   \ 'GotoPrevLineAlpha'  :  "",
 
 605   \ 'GotoNextSpotAlpha'  :  "",
 
 606   \ 'GotoPrevSpotAlpha'  :  "",
 
 610 let g:switch_mapping = "<Leader>s"
 
 613 nmap <silent> z] <Plug>(SpellRotateForward)
 
 614 nmap <silent> z[ <Plug>(SpellRotateBackward)
 
 615 vmap <silent> z] <Plug>(SpellRotateForwardV)
 
 616 vmap <silent> z[ <Plug>(SpellRotateBackwardV)
 
 619 let g:syntastic_enable_highlighting = 0
 
 620 let g:syntastic_error_symbol='E'
 
 621 let g:syntastic_style_error_symbol='S'
 
 622 let g:syntastic_warning_symbol='W'
 
 623 let g:syntastic_style_warning_symbol='S'
 
 624 let g:syntastic_always_populate_loc_list=1
 
 625 nmap <silent> <leader>y :SyntasticCheck<cr>
 
 627 let g:syntastic_cpp_clang_tidy_post_args = "-p build*"
 
 630   let g:syntastic_check_on_open=1
 
 634 map <F5> :TagbarToggle<cr>
 
 635 let g:tagbar_sort = 0
 
 636 let g:tagbar_compact = 1
 
 637 let g:tagbar_autoshowtag = 1
 
 638 let g:tagbar_width = 25
 
 639 let g:tagbar_iconchars = ['+', '-']
 
 642 let g:tcomment_textobject_inlinecomment = 'gic'
 
 643 let g:tcomment#filetype#guess = 0
 
 646 let g:UltiSnipsEditSplit = 'vertical'
 
 647 let g:UltiSnipsSnippetsDir = expand("$XDG_CONFIG_HOME/vim/ultisnips")
 
 649   let g:UltiSnipsSnippetDirectories = ["UltiSnips", "ultisnips"]
 
 651 let g:UltiSnipsExpandTrigger       = "<tab>"
 
 652 let g:UltiSnipsJumpForwardTrigger  = "<tab>"
 
 653 let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
 
 655 " UltiSnips completion function that tries to expand a snippet. If there's no
 
 656 " snippet for expanding, it checks for completion window and if it's shown,
 
 657 " selects first element. If there's no completion window it tries to jump to
 
 658 " next placeholder. If there's no placeholder it just returns TAB key
 
 659 " https://github.com/Valloric/YouCompleteMe/issues/36#issuecomment-15451411
 
 660 function! g:UltiSnips_Complete()
 
 661     call UltiSnips#ExpandSnippet()
 
 662     if g:ulti_expand_res == 0
 
 666             call UltiSnips#JumpForwards()
 
 667             if g:ulti_jump_forwards_res == 0
 
 674 au InsertEnter * exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=g:UltiSnips_Complete()<cr>"
 
 675 let g:UltiSnipsListSnippets="<c-e>"
 
 678 call unite#filters#matcher_default#use(['matcher_fuzzy'])
 
 679 call unite#custom#profile('default', 'context', {
 
 681             \ 'direction': 'botright'
 
 684 nnoremap [unite] <Nop>
 
 685 nmap <leader>u [unite]
 
 686 nnoremap [unite]u :UniteResume<CR>
 
 687 nnoremap <silent> [u :UnitePrevious<CR>
 
 688 nnoremap <silent> ]u :UniteNext<CR>
 
 691 " seems not respected
 
 692 let g:unite_source_grep_max_candidates = 2000
 
 694     " Use ag in unite grep source.
 
 695     let g:unite_source_grep_command = 'ag'
 
 696     let g:unite_source_grep_default_opts = '--smart-case --vimgrep --ignore ''.hg'' --ignore ''.svn'' --ignore ''.git'' --ignore ''.bzr'''
 
 697     let g:unite_source_grep_recursive_opt = ''
 
 699 nnoremap <silent> [unite]a :<C-u>Unite grep:.::
\12\17<CR>
 
 700 nnoremap <silent> [unite]A :<C-u>Unite grep:.:-w:
\12\17<CR>
 
 701 command! -nargs=1 Ag Unite grep:.::<args>
 
 703 " unite-file_rec {{{3
 
 705     " Use ag in unite rec source
 
 706     let g:unite_source_rec_async_command = ['ag', '--follow', '--nocolor', '--nogroup', '-g', '']
 
 708 nnoremap <silent> [unite]f :<C-u>Unite -start-insert file_rec/async<CR>
 
 709 call unite#custom#source('file_rec/async', 'sorters', 'sorter_selecta')
 
 712 call unite#custom#default_action('buffer', 'open')
 
 713 nnoremap <silent> [unite]b :<C-u>Unite buffer:-<CR>
 
 715 " unite-jumplist {{{3
 
 716 nnoremap <silent> [unite]j :<C-u>Unite output:jumps:<CR>
 
 719 let g:unite_source_menu_menus = {}
 
 720 let g:unite_source_menu_menus.fugitive = { 'description' : 'fugitive menu'}
 
 721 let g:unite_source_menu_menus.fugitive.command_candidates = {
 
 722             \ 'Gstatus <Leader>gs' : 'Gstatus',
 
 723             \ 'Gcommit -v <Leader>gc' : 'Gcommit -v',
 
 727 nnoremap <silent> <leader>gg :<C-u>Unite menu:fugitive<CR>
 
 729 let g:unite_source_history_yank_enable = 1
 
 730 nnoremap <silent> [unite]p :<C-u>Unite history/yank<CR>
 
 733 nnoremap <silent> <leader>p :YRShow<cr>
 
 734 let g:yankring_history_dir = expand('$XDG_CACHE_HOME/vim')
 
 735 let g:yankring_replace_n_pkey = ''
 
 736 let g:yankring_replace_n_nkey = ''
 
 738 " map Y to y$ for the yank ring
 
 739 function! YRRunAfterMaps()
 
 740     nnoremap Y   :<C-U>YRYankCount 'y$'<CR>
 
 744 let g:ycm_clangd_binary_path = 'clangd'   " use clangd in path
 
 745 let g:ycm_extra_conf_vim_data = ['getcwd()']
 
 746 let g:ycm_add_preview_to_completeopt = 1
 
 747 let g:ycm_complete_in_comments = 1
 
 748 let g:ycm_complete_in_strings  = 1
 
 749 let g:ycm_autoclose_preview_window_after_insertion = 0
 
 751 " vim-easy-align {{{2
 
 752 " start interactive EasyAlign in visual mode
 
 753 vmap <Enter> <Plug>(EasyAlign)
 
 754 nmap ga <Plug>(EasyAlign)
 
 757 let g:gtest#highlight_failing_tests = 0
 
 759 nnoremap <Leader>tt :GTestRun<CR>
 
 760 nnoremap <Leader>ta :GTestCase *<CR>:GTestName *<CR>:GTestRun<CR>
 
 761 nnoremap <Leader>tu :GTestRunUnderCursor<CR>
 
 764 let g:vim_json_syntax_conceal = 0
 
 767 let g:sneak#streak = 1
 
 768 let g:sneak#target_labels = "aoeuisnthdpylrcgfqjkxzmwvz" " dvorak
 
 769 let g:sneak#use_ic_scs = 1  " follow 'ignorecase' and 'smartcase'
 
 786 let g:vimwiki_list = [{'path': '$XDG_DATA_HOME/vimwiki'}]
 
 787 let g:vimwiki_auto_chdir = 1
 
 789   au! BufRead            $XDG_DATA_HOME/vimwiki/index.wiki   !git -C "%:p:h" pull -q
 
 790   au! BufRead,BufNewFile $XDG_DATA_HOME/vimwiki/diary/*.wiki !git -C "%:p:h" pull -q
 
 791   au! BufWritePost       $XDG_DATA_HOME/vimwiki/*.wiki       exe '!git add "<afile>";git commit -qm"' . strftime("%FT%R") . '";git push -q'
 
 796 " Convenient command to see the difference between the current buffer and the
 
 797 " file it was loaded from, thus the changes you made.
 
 798 " Only define it when not defined already.
 
 799 if !exists(":DiffOrig")
 
 800   command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
 
 801                   \ | wincmd p | diffthis
 
 805 function! SortLinesOpFunc(...)
 
 808 nnoremap <silent> gs :<C-U>set operatorfunc=SortLinesOpFunc<CR>g@
 
 809 vnoremap <silent> gs :sort<cr>
 
 812 function! EditConfig(what, ext = '.vim')
 
 813     let l:dir = split(&runtimepath,',')[0]
 
 815         let l:file = expand($MYVIMRC)
 
 816     elseif ! isdirectory(globpath(l:dir, a:what))
 
 817         echoe a:what." is not valid!"
 
 818     elseif empty(&filetype)
 
 819         echoe 'filetype is empty!'
 
 821         let l:file = l:dir.'/'.a:what.'/'.&filetype.a:ext
 
 824     execute ':vsplit '.file
 
 827 nmap <leader>ev :call EditConfig('vimrc')<CR>
 
 828 nmap <leader>ef :call EditConfig('ftplugin')<CR>
 
 829 nmap <leader>es :call EditConfig('syntax')<CR>
 
 830 nmap <leader>ei :call EditConfig('indent')<CR>
 
 831 nmap <leader>eu :call EditConfig('ultisnips', '.snippets')<CR>
 
 834 " http://tex.stackexchange.com/a/52932
 
 835 let g:myLangList=["en_gb","en_us","de","fr"]
 
 837 function! ToggleSpell()
 
 838   if !exists("b:myLang")
 
 841   execute "setlocal spell!"
 
 843     echo "setlocal spelllang=" g:myLangList[b:myLang]
 
 847 function! SwitchSpell()
 
 848   if !exists("b:myLang")
 
 852     let b:myLang=b:myLang+1
 
 853     if b:myLang>=len(g:myLangList) | let b:myLang=0 | endif
 
 855   execute "setlocal spell spelllang=".get(g:myLangList, b:myLang)
 
 856   echo "setlocal spelllang=" g:myLangList[b:myLang]
 
 859 nnoremap <silent> coS :call SwitchSpell()<CR>
 
 860 " fix spelling with first choice
 
 861 nnoremap <Leader>f 1z=
 
 863 " gitdir or home {{{2
 
 865 " http://git.io/v3GAV
 
 866 function! FindGitDirOrHome()
 
 867   let filedir = expand('%:p:h')
 
 868   if isdirectory(filedir)
 
 869     let cmd = 'bash -c "(cd ' . filedir . '; git rev-parse --show-toplevel 2>/dev/null)"'
 
 870     let gitdir = system(cmd)
 
 871     if strlen(gitdir) == 0
 
 881 command! Cdr execute('cd ' . FindGitDirOrHome())
 
 883 command! LCdr execute('lcd ' . FindGitDirOrHome())
 
 885 " vim:set et sw=2 ts=2 tw=78: