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 'sgeb/vim-diff-fold'
 
  38 Plug 'shougo/unite.vim'
 
  39 Plug 'shougo/vimproc.vim', {'do': 'make'}
 
  41 Plug 'thinca/vim-qfreplace'
 
  42 Plug 'tomtom/tcomment_vim'
 
  43 Plug 'tpope/vim-abolish'
 
  44 Plug 'tpope/vim-endwise'
 
  45 Plug 'tpope/vim-eunuch'
 
  46 Plug 'tpope/vim-fugitive'
 
  47 Plug 'tpope/vim-repeat'
 
  48 Plug 'tpope/vim-scriptease'
 
  49 Plug 'tpope/vim-speeddating'
 
  50 Plug 'tpope/vim-surround'  "investigate vim-sandwich
 
  51 Plug 'tpope/vim-unimpaired'
 
  52 Plug 'tweekmonster/spellrotate.vim'
 
  53 Plug 'valloric/youcompleteme', { 'do': './install.py --clangd-completer --clang-completer' }
 
  54 Plug 'vim-scripts/mediawiki.vim'
 
  55 Plug 'vim-scripts/replacewithregister'
 
  56 Plug 'vim-scripts/yankring.vim'
 
  60 Plug 'morhetz/gruvbox'
 
  63 Plug 'sirver/ultisnips'
 
  64 Plug 'honza/vim-snippets'
 
  67 Plug 'kana/vim-textobj-user'
 
  68 Plug 'julian/vim-textobj-variable-segment'
 
  69 Plug 'sgur/vim-textobj-parameter'
 
  70 Plug 'kana/vim-operator-user'
 
  73 " Check LucHermites plugins: https://github.com/LucHermitte/lh-cpp
 
  74 Plug 'dense-analysis/ale' " {{{2
 
  75 let g:ale_echo_msg_format = '[%linter%] %code: %%s'
 
  76 let g:ale_c_parse_compile_commands = 1
 
  77 let g:ale_cpp_parse_compile_commands = 1
 
  78 " don't use loclist as it's being populated by ycm
 
  79 " (might want to enable for other filetypes)
 
  80 let g:ale_set_loclist = 0
 
  81 let g:ale_cpp_gcc_options = ''
 
  82 let g:ale_linters_ignore = { 'cpp': ['clangd', 'clangtidy', 'clang'] }
 
  84 Plug 'git@github.com:/ram-z/vim-orgmode', { 'branch': 'dev' } " {{{2
 
  85 Plug 'vim-scripts/syntaxrange'
 
  87 let g:org_agenda_files = ['~/org/*.org']
 
  89 Plug 'neovimhaskell/haskell-vim'  " {{{2
 
  90 let g:haskell_enable_quantification = 1   " to enable highlighting of `forall`
 
  91 let g:haskell_enable_recursivedo = 1      " to enable highlighting of `mdo` and `rec`
 
  92 let g:haskell_enable_arrowsyntax = 1      " to enable highlighting of `proc`
 
  93 let g:haskell_enable_pattern_synonyms = 1 " to enable highlighting of `pattern`
 
  94 let g:haskell_enable_typeroles = 1        " to enable highlighting of type roles
 
  95 let g:haskell_enable_static_pointers = 1  " to enable highlighting of `static`
 
  96 let g:haskell_backpack = 1                " to enable highlighting of backpack keywords
 
  99 Plug 'aklt/plantuml-syntax'
 
 103 filetype plugin indent on
 
 108 let g:gruvbox_contrast_dark  = 'hard'
 
 109 let g:gruvbox_contrast_light = 'soft'
 
 111 " override the background to be black
 
 112 highligh Normal ctermbg=None
 
 115 " moving around, searching and patterns {{{2
 
 116 set incsearch           " show match for partly typed search command
 
 117 set ignorecase          " ignore case when using a search pattern
 
 118 set smartcase           " override 'ignorecase' when pattern has upper case characters
 
 119 set hlsearch            " highlight all matches for the last used search pattern
 
 121 set nostartofline       " don't move the cursor to the first non-blank char of a line
 
 124 set path+=../include/
 
 125 set path+=/usr/include/c++/*
 
 127 " displaying text {{{2
 
 128 set nowrap                      " long lines wrap
 
 129 set linebreak                   " wrap long lines at a character in 'breakat'
 
 130 set showbreak=↪                 " show these chars for wrapped lines
 
 131 set breakindent                 " preserve indentation in wrapped text
 
 133 set lazyredraw                  " don't redraw while executing macros
 
 135 set list                        " show chars defined in 'listchars'
 
 136 set listchars=tab:❭\            " list of strings used for list mode
 
 137 set listchars+=extends:❯,precedes:❮
 
 138 " Only shown when not in insert mode
 
 139 set listchars+=trail:·
 
 142     au InsertEnter * :set listchars-=trail:·
 
 143     au InsertLeave * :set listchars+=trail:·
 
 146 set scrolloff=5                 " number of screen lines to show around the cursor
 
 147 set sidescroll=1                " number of collumns to scroll
 
 148 set sidescrolloff=1             " don't scroll over the listchars
 
 150 set fillchars=diff:⣿,vert:│
 
 152 set nonumber                    " show the line number for each line
 
 153 set norelativenumber            " show the relative line number for each line
 
 155 " syntax, highlighting and spelling {{{2
 
 156 set synmaxcol=800               " don't highlight long lines
 
 158 set dictionary=spell            " list of dictionary files for keyword completion
 
 162 " multiple windows {{{2
 
 163 set laststatus=2                " 0, 1 or 2; when to use a status line for the last window
 
 165 set previewheight=20            " default height for the preview window
 
 169 " set splitbelow                  " a new window is put below of the current one
 
 170 set splitright                  " a new window is put right of the current one
 
 175 " using the mouse {{{2
 
 176 set mouse=rnv                   " list of flags for using the mouse
 
 177 set ttymouse=xterm              " type of mouse
 
 179 " messages and info {{{2
 
 180 set showcmd         " Show (partial) command in status line.
 
 181 set ruler           " show the cursor position all the time
 
 182 set confirm         " Ask what to do when closing unsaved documents
 
 183 set shortmess=      " reset option
 
 184 set shortmess+=a    " all abbreviations
 
 185 set shortmess+=o    " overwrite file-written message
 
 186 set shortmess+=O    " file-read message overrides previous
 
 187 set shortmess+=t    " truncate file message at start
 
 188 set shortmess+=T    " truncate other messages in the middle
 
 189 set shortmess+=W    " don't give 'written' or '[w]' when writing a file
 
 190 set shortmess+=A    " ignore swapfile warning
 
 191 set shortmess+=I    " no splash screen
 
 194 set backspace=indent,eol,start  " allow backspacing over everything in insert mode
 
 196 set showmatch                   " Show matching brackets.
 
 198 set nojoinspaces                " don't use two spaces after '.' when joining a line
 
 199 set formatoptions+=j    " Delete comment leader when joining lines
 
 200 set formatoptions+=c    " Autowrap comments using textwidth
 
 201 set formatoptions+=r    " Insert comment leader after hitting <Enter>
 
 202 set formatoptions+=n    " Recognize numbered lists
 
 203 set formatoptions+=q    " Allow formatting of comments with "gq".
 
 204 set formatoptions+=l    " do not wrap lines that have been longer when starting insert mode already
 
 205 set formatoptions+=t    " Auto-wrap text using textwidth
 
 206 set formatoptions-=o    " Do not insert comment leader after hitting o or O in normal mode
 
 208 set nrformats=hex               " number formats recognized for CTRL-A and CTRL-X commands
 
 210 set complete=.       " scan the current buffer ( 'wrapscan' is ignored)
 
 211 set complete+=w      " scan buffers from other windows
 
 212 set complete+=b      " scan other loaded buffers that are in the buffer list
 
 213 set complete+=u      " scan the unloaded buffers that are in the buffer list
 
 214 set complete+=t      " scan tags
 
 215 set complete+=i      " scan current and included files
 
 216 set complete+=kspell " use the currently active spell checking |spell|
 
 218 " whether to use a popup menu for Insert mode completion
 
 219 set completeopt=longest,menuone,preview
 
 221 " tabs and indent {{{2
 
 222 set shiftwidth=4                " number of spaces used for each step of (auto)indent
 
 223 set smarttab                    " a <Tab> in an indent inserts 'shiftwidth' spaces
 
 224 set softtabstop=4               " if non-zero, number of spaces to insert for a <Tab>
 
 225 set shiftround                  " round to 'shiftwidth' for "<<" and ">>"
 
 226 set expandtab                   " expand <Tab> to spaces in Insert mode
 
 229 set pastetoggle=<F11>           " key sequence to toggle paste mode
 
 232 set foldmethod=marker           " folding type
 
 233 set foldlevelstart=0            " value for 'foldlevel' when starting to edit a file
 
 235 " open folds when jumping to line
 
 238 set viewoptions=cursor          " save cursor position
 
 239 set viewoptions+=folds          " save folds
 
 242 set diffopt+=filler         " show filler lines
 
 243 set diffopt+=vertical       " always vertical split
 
 244 set diffopt+=context:10     " 10 lines context between changes
 
 246 " reading and writing files {{{2
 
 247 set modeline                    " read modelines
 
 248 set modelines=2                 " only check first/last 2 lines
 
 250 set writebackup                 " write a backup file before overwriting a file
 
 251 set backup                      " keep a backup after owerwriting a file
 
 252 set backupdir=$XDG_CACHE_HOME/vim/backup//
 
 254 set backupskip+=.netrc          " skip netrc
 
 255 set backupskip+=/dev/shm/pass*  " skip passwordstore files
 
 257 set undofile                    " persistent undo history
 
 258 set undodir=$XDG_CACHE_HOME/vim/undo//
 
 262     au BufWritePre .netrc         setlocal noundofile
 
 263     au BufWritePre /dev/shm/pass* setlocal noundofile
 
 264     au BufWritePre /tmp/*         setlocal noundofile
 
 267 set autowrite                   " automatically write a file when leaving a modified buffer
 
 268 set autoread                    " automatically read a file that has been modified
 
 272 set directory=$XDG_CACHE_HOME/vim/swap//
 
 274 " command line editing {{{2
 
 275 set history=5000                " how many command lines are remembered
 
 276 set wildmenu                    " command-line completion shows a list of matches
 
 277 set wildmode=longest:full,full  " specifies how command line completion works
 
 278 set wildignorecase              " ignore case when completing file names
 
 280 set wildignore+=.hg,.git,.svn                    " Version control
 
 281 set wildignore+=*.aux,*.out,*.toc                " LaTeX intermediate files
 
 282 set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg   " binary images
 
 283 set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
 
 284 set wildignore+=*.spl                            " compiled spelling word lists
 
 285 set wildignore+=*.sw?                            " Vim swap files
 
 286 set wildignore+=*.luac                           " Lua byte code
 
 287 set wildignore+=*.pyc                            " Python byte code
 
 288 set wildignore+=*.orig                           " Merge resolution files
 
 290 " running make and jumping to errors {{{2
 
 291 set makeprg=make\ -w     " print changing directories
 
 293 set grepprg=ag\ --vimgrep\ $*
 
 295 " language specific {{{2
 
 296 set isfname-==    " don't treat `=` as being part of filenames
 
 299 set virtualedit+=block     " let cursor move past last char in <C-V> mode
 
 300 set virtualedit+=onemore   " allow the cursor to move just past the end of the line
 
 301 set viminfo='100,<50,s10,h,n$XDG_CACHE_HOME/vim/viminfo " viminfo defaults but save file in .cache
 
 303 set viewdir=$XDG_CACHE_HOME/vim/view//
 
 305 set sessionoptions+=unix,slash  " damn windows and it's silly ways
 
 308 " Resize splits when the window is resized {{{2
 
 311     autocmd VimResized * :wincmd =
 
 314 " Only show cursorline in the current window and in normal mode {{{2
 
 317     au WinLeave,InsertEnter * set nocursorline
 
 318     au WinEnter,InsertLeave * set cursorline
 
 321 " Treat buffers from stdin (e.g.: echo foo | vim -) as scratch {{{2
 
 324     au StdinReadPost * :set buftype=nofile
 
 327 " Jump to last known cursor position {{{2
 
 330     " blacklist certain filetype
 
 331     let blacklist = ['gitcommit']
 
 332     autocmd BufReadPost *
 
 333                 \ if index(blacklist, &ft) < 0 && line("'\"") > 1 && line("'\"") <= line("$") |
 
 334                 \   exe "normal! g`\"" |
 
 338 " Check for file modifications automatically {{{2
 
 339 " (current buffer only)
 
 340 " Use :NoAutoChecktime to disable it (uses b:autochecktime)
 
 341 fun! MyAutoCheckTime()
 
 342   " only check timestamp for normal files
 
 343   if &buftype != '' | return | endif
 
 344   if ! exists('b:autochecktime') || b:autochecktime
 
 346     let b:autochecktime = 1
 
 349 augroup MyAutoChecktime
 
 351   au FocusGained,BufEnter,CursorHold,InsertEnter * call MyAutoCheckTime()
 
 353 command! NoAutoChecktime let b:autochecktime=0
 
 354 command! ToggleAutoChecktime let b:autochecktime=!get(b:, 'autochecktime', 0) | echom "b:autochecktime:" b:autochecktime
 
 358   au TerminalOpen * if &buftype == 'terminal' | setlocal bufhidden=hide | endif
 
 363 " allow both <space> and \ to be <leader>
 
 369   if exists("b:make_dir")
 
 370     let l:make_dir = "-C ".b:make_dir
 
 371   elseif exists("g:make_dir")
 
 372     let l:make_dir = "-C ".g:make_dir
 
 375   let l:make_targets = ""
 
 376   if exists("g:make_targets")
 
 377     let l:make_targets = g:make_targets
 
 379   execute "make! ".l:make_dir." ".l:make_targets
 
 381 nnoremap <leader>r :call Make()<cr>
 
 384 nnoremap <silent> <Leader>/ :silent nohl<CR>
 
 387 nnoremap <leader>[ :tabprev<cr>
 
 388 nnoremap <leader>] :tabnext<cr>
 
 390 " paste from selection
 
 391 nnoremap <leader>p* :silent! set paste<CR>"*p:set nopaste<CR>
 
 392 " paste from clipboard
 
 393 nnoremap <leader>p+ :silent! set paste<CR>"+p:set nopaste<CR>
 
 395 " strip trailing whitespace
 
 396 function! StripWhitespace(line1, line2, ...)  " {{{2
 
 397   let s_report = &report
 
 399   let pattern = a:0 ? a:1 : '\s\+$'
 
 400   let oldview = winsaveview()
 
 401   exe 'keepjumps keeppatterns '.a:line1.','.a:line2.'substitute/'.pattern.'//e'
 
 402   if oldview != winsaveview()
 
 405   call winrestview(oldview)
 
 406   let &report = s_report
 
 408 command! -range=% -nargs=0 -bar Untrail keepjumps call StripWhitespace(<line1>,<line2>)
 
 409 nnoremap <silent> <leader>ww :Untrail<CR>
 
 412 vnoremap <leader>S y:execute @@<cr>:echo 'Sourced selection.'<cr>
 
 413 nnoremap <leader>S ^vg_y:execute @@<cr>:echo 'Sourced line.'<cr>
 
 415 " jump to last cursor position
 
 418 " Select (charwise) the contents of the current line, excluding indentation.
 
 422 nnoremap U :syntax sync fromstart<cr>:AirlineRefresh<cr>:redraw!<cr>
 
 425 " nnoremap <leader>r :silent !ranger %:h<cr>:redraw!<cr>
 
 426 " nnoremap <leader>R :silent !ranger<cr>:redraw!<cr>
 
 433 " display the number of matches for the last search
 
 434 nmap <Leader># :%s:<C-R>/::gn<CR>
 
 436 " center cursor after search and open folds
 
 440 " same when jumping around
 
 443 nnoremap <c-o> <c-o>zzzv
 
 444 nnoremap <c-i> <c-i>zzzv
 
 446 " Not using the default mappings of 'To line from top/bottom'
 
 452 " Heresy, emacs insert bindings
 
 453 inoremap <C-A> <Esc>I
 
 454 inoremap <C-E> <Esc>A
 
 455 cnoremap <C-A> <Home>
 
 458 " proper movement when lines are wrapped
 
 459 noremap <silent><expr> j (v:count == 0 ? 'gj' : 'j')
 
 460 noremap <silent><expr> k (v:count == 0 ? 'gk' : 'k')
 
 466 noremap  <Right> <NOP>
 
 468 inoremap <Down>  <NOP>
 
 469 inoremap <Left>  <NOP>
 
 470 inoremap <Right> <NOP>
 
 472 cnoremap <Down>  <NOP>
 
 473 cnoremap <Left>  <NOP>
 
 474 cnoremap <Right> <NOP>
 
 476 cnoremap <C-J>   <Down>
 
 477 cnoremap <C-H>   <Left>
 
 478 cnoremap <C-L>   <Right>
 
 480 " close all folds open fold in cursor
 
 483 map <F1> :ls<CR>:b<space>
 
 485 " move between windows (skip previewwindow)
 
 486 nnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
 
 487 nnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
 
 488 tnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
 
 489 tnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
 
 491 "xterm mouse with middleclick paste
 
 492 nnoremap <MiddleMouse> i<MiddleMouse>
 
 493 vnoremap <MiddleMouse> s<MiddleMouse>
 
 495 " fix legacy vi inconsistency
 
 500 " allow repeat operator on visual
 
 501 vnoremap . :normal .<CR>
 
 503 " add line without changing position or leaving mode
 
 504 noremap <silent> <Leader>o :set paste<CR>m`o<ESC>``:set nopaste<CR>
 
 505 noremap <silent> <Leader>O :set paste<CR>m`O<ESC>``:set nopaste<CR>
 
 507 " Don't use Ex mode, use Q for formatting
 
 510 " break undo sequence before removing word
 
 511 inoremap <C-W> <C-G>u<C-W>
 
 513 nnoremap coe :set <C-R>=&expandtab ? 'noexpandtab' : 'expandtab'<CR><CR>
 
 514 nnoremap [oe :set expandtab<CR>
 
 515 nnoremap ]oe :set noexpandtab<CR>
 
 517 for idt in range(1,8)
 
 518   exe 'nnoremap co'.idt.' :setlocal tabstop='.idt.' shiftwidth='.idt.' softtabstop='.idt.'<CR>'
 
 521 " toggle auto format of text
 
 522 nnoremap coa :set <C-R>=&formatoptions =~ "a" ? 'formatoptions-=a' : 'formatoptions+=a'<CR><CR>
 
 523 nnoremap [oa :set formatoptions+=a<CR>
 
 524 nnoremap ]oa :set formatoptions-=a<CR>
 
 526 " space will toggle current fold in normal mode
 
 527 nnoremap <leader><Space> za
 
 528 " create folds around visual selection
 
 529 vnoremap <leader><Space> zf
 
 532 cabbrev w!! SudoWrite
 
 534 " uppercase previous word
 
 535 inoremap <C-C> <Esc>gUiwgi
 
 537 " http://git.io/v3ZeU
 
 538 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>
 
 540 " plugins options {{{1
 
 542 let g:airline#extensions#whitespace#enabled = 1
 
 543 let g:airline#extensions#tabline#enabled = 1
 
 544 let g:airline_powerline_fonts = 1
 
 547 let g:checkattach_filebrowser = 'ranger'
 
 548 let g:checkattach_once = 'y'
 
 551 let delimitMate_expand_cr = 2
 
 552 let g:delimitMate_expand_space = 1
 
 555 nnoremap <silent> <Leader>ff :FSHere<CR>
 
 556 nnoremap <silent> <Leader>fl :FSRight<CR>
 
 557 nnoremap <silent> <Leader>fh :FSLeft<CR>
 
 558 nnoremap <silent> <Leader>fj :FSBelow<CR>
 
 559 nnoremap <silent> <Leader>fk :FSAbove<CR>
 
 560 nnoremap <silent> <Leader>fL :FSSplitRight<CR>
 
 561 nnoremap <silent> <Leader>fH :FSSplitLeft<CR>
 
 562 nnoremap <silent> <Leader>fJ :FSSplitBelow<CR>
 
 563 nnoremap <silent> <Leader>fK :FSSplitAbove<CR>
 
 566 nmap <silent> <leader>dd :tab split \| Gdiff \| wincmd h<CR>
 
 567 " delete fugitive buffers when closed
 
 568 autocmd BufReadPost fugitive://* set bufhidden=delete
 
 570 nnoremap <silent> <leader>gs :Git<CR>
 
 571 nnoremap <silent> <leader>gd :Gdiffsplit<CR>
 
 572 nnoremap <silent> <leader>gc :tab G commit -v<CR>
 
 573 nnoremap <silent> <leader>ga :Gwrite<cr>
 
 574 nnoremap <silent> <leader>gb :G blame<cr>
 
 576 augroup fugitive_gstatus
 
 578     autocmd BufWinEnter */.git/index resize 16
 
 582 nnoremap <F7> :GundoToggle<CR>
 
 585 let g:indent_guides_default_mapping = 0
 
 586 let g:indent_guides_guide_size = 1
 
 587 nmap <silent> cog <Plug>IndentGuidesToggle
 
 588 nmap <silent> [og <Plug>IndentGuidesEnable
 
 589 nmap <silent> ]og <Plug>IndentGuidesDisable
 
 591 " close-another-window {{{2
 
 592 nnoremap <silent> <C-W>c  <NOP>
 
 593 nnoremap <silent> <C-W>cc <C-W>c
 
 594 nnoremap <silent> <C-W>ch :CloseLeftWindow<CR>
 
 595 nnoremap <silent> <C-W>cl :CloseRightWindow<CR>
 
 596 nnoremap <silent> <C-W>cj :CloseBelowWindow<CR>
 
 597 nnoremap <silent> <C-W>ck :CloseAboveWindow<CR>
 
 601 let g:pymode_rope_completion = 0
 
 602 let g:pymode_rope = 0
 
 604 let g:pymode_folding = 1
 
 605 let g:pymode_lint_ignore = "E221,E266,E501"
 
 606 let g:pymode_lint_cwindow = 0           " don't open cwindow when linting
 
 607 let g:pymode_syntax_space_errors = 0    " don't bother me when I'm typing
 
 610 " disable '[ mappings
 
 612 let g:SignatureMap = {
 
 613   \ 'GotoNextLineAlpha'  :  "",
 
 614   \ 'GotoPrevLineAlpha'  :  "",
 
 615   \ 'GotoNextSpotAlpha'  :  "",
 
 616   \ 'GotoPrevSpotAlpha'  :  "",
 
 620 let g:switch_mapping = "<Leader>s"
 
 623 nmap <silent> z] <Plug>(SpellRotateForward)
 
 624 nmap <silent> z[ <Plug>(SpellRotateBackward)
 
 625 vmap <silent> z] <Plug>(SpellRotateForwardV)
 
 626 vmap <silent> z[ <Plug>(SpellRotateBackwardV)
 
 629 let g:syntastic_enable_highlighting = 0
 
 630 let g:syntastic_error_symbol='E'
 
 631 let g:syntastic_style_error_symbol='S'
 
 632 let g:syntastic_warning_symbol='W'
 
 633 let g:syntastic_style_warning_symbol='S'
 
 634 let g:syntastic_always_populate_loc_list=1
 
 635 nmap <silent> <leader>y :SyntasticCheck<cr>
 
 637 let g:syntastic_cpp_clang_tidy_post_args = "-p build*"
 
 640   let g:syntastic_check_on_open=1
 
 644 map <F5> :TagbarToggle<cr>
 
 645 let g:tagbar_sort = 0
 
 646 let g:tagbar_compact = 1
 
 647 let g:tagbar_autoshowtag = 1
 
 648 let g:tagbar_width = 25
 
 649 let g:tagbar_iconchars = ['+', '-']
 
 652 let g:tcomment_textobject_inlinecomment = 'gic'
 
 653 let g:tcomment#filetype#guess = 0
 
 656 let g:UltiSnipsEditSplit = 'vertical'
 
 657 let g:UltiSnipsSnippetDirectories = [ expand("$XDG_CONFIG_HOME/vim/ultisnips") ]
 
 659   let g:UltiSnipsSnippetDirectories = ["UltiSnips", "ultisnips"]
 
 661 let g:UltiSnipsExpandTrigger       = "<tab>"
 
 662 let g:UltiSnipsJumpForwardTrigger  = "<tab>"
 
 663 let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
 
 665 " UltiSnips completion function that tries to expand a snippet. If there's no
 
 666 " snippet for expanding, it checks for completion window and if it's shown,
 
 667 " selects first element. If there's no completion window it tries to jump to
 
 668 " next placeholder. If there's no placeholder it just returns TAB key
 
 669 " https://github.com/Valloric/YouCompleteMe/issues/36#issuecomment-15451411
 
 670 function! g:UltiSnips_Complete()
 
 671     call UltiSnips#ExpandSnippet()
 
 672     if g:ulti_expand_res == 0
 
 676             call UltiSnips#JumpForwards()
 
 677             if g:ulti_jump_forwards_res == 0
 
 684 au InsertEnter * exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=g:UltiSnips_Complete()<cr>"
 
 685 let g:UltiSnipsListSnippets="<c-e>"
 
 688 call unite#filters#matcher_default#use(['matcher_fuzzy'])
 
 689 call unite#custom#profile('default', 'context', {
 
 691             \ 'direction': 'botright'
 
 694 nnoremap [unite] <Nop>
 
 695 nmap <leader>u [unite]
 
 696 nnoremap [unite]u :UniteResume<CR>
 
 697 nnoremap <silent> [u :UnitePrevious<CR>
 
 698 nnoremap <silent> ]u :UniteNext<CR>
 
 701 " seems not respected
 
 702 let g:unite_source_grep_max_candidates = 2000
 
 704     " Use ag in unite grep source.
 
 705     let g:unite_source_grep_command = 'ag'
 
 706     let g:unite_source_grep_default_opts = '--smart-case --vimgrep --ignore ''.hg'' --ignore ''.svn'' --ignore ''.git'' --ignore ''.bzr'''
 
 707     let g:unite_source_grep_recursive_opt = ''
 
 709 nnoremap <silent> [unite]a :<C-u>Unite grep:.::
\12\17<CR>
 
 710 nnoremap <silent> [unite]A :<C-u>Unite grep:.:-w:
\12\17<CR>
 
 711 command! -nargs=1 Ag Unite grep:.::<args>
 
 713 " unite-file_rec {{{3
 
 715     " Use ag in unite rec source
 
 716     let g:unite_source_rec_async_command = ['ag', '--follow', '--nocolor', '--nogroup', '-g', '']
 
 718 nnoremap <silent> [unite]f :<C-u>Unite -start-insert file_rec/async<CR>
 
 719 call unite#custom#source('file_rec/async', 'sorters', 'sorter_selecta')
 
 722 call unite#custom#default_action('buffer', 'open')
 
 723 nnoremap <silent> [unite]b :<C-u>Unite buffer:-<CR>
 
 725 " unite-jumplist {{{3
 
 726 nnoremap <silent> [unite]j :<C-u>Unite output:jumps:<CR>
 
 729 let g:unite_source_menu_menus = {}
 
 730 let g:unite_source_menu_menus.fugitive = { 'description' : 'fugitive menu'}
 
 731 let g:unite_source_menu_menus.fugitive.command_candidates = {
 
 732             \ 'Gstatus <Leader>gs' : 'Gstatus',
 
 733             \ 'Gcommit -v <Leader>gc' : 'Gcommit -v',
 
 737 nnoremap <silent> <leader>gg :<C-u>Unite menu:fugitive<CR>
 
 739 let g:unite_source_history_yank_enable = 1
 
 740 nnoremap <silent> [unite]p :<C-u>Unite history/yank<CR>
 
 743 nnoremap <silent> <leader>p :YRShow<cr>
 
 744 let g:yankring_history_dir = expand('$XDG_CACHE_HOME/vim')
 
 745 let g:yankring_replace_n_pkey = ''
 
 746 let g:yankring_replace_n_nkey = ''
 
 748 " map Y to y$ for the yank ring
 
 749 function! YRRunAfterMaps()
 
 750     nnoremap Y   :<C-U>YRYankCount 'y$'<CR>
 
 754 let g:ycm_clangd_binary_path = 'clangd'   " use clangd in path
 
 755 let g:ycm_clangd_args = ['--clang-tidy']
 
 756 let g:ycm_extra_conf_vim_data = ['getcwd()']
 
 757 let g:ycm_add_preview_to_completeopt = 1
 
 758 let g:ycm_complete_in_comments = 1
 
 759 let g:ycm_complete_in_strings  = 1
 
 760 let g:ycm_autoclose_preview_window_after_insertion = 0
 
 762 " vim-easy-align {{{2
 
 763 " start interactive EasyAlign in visual mode
 
 764 vmap <Enter> <Plug>(EasyAlign)
 
 765 nmap ga <Plug>(EasyAlign)
 
 768 let g:gtest#highlight_failing_tests = 0
 
 770 nnoremap <Leader>tt :GTestRun<CR>
 
 771 nnoremap <Leader>ta :GTestCase *<CR>:GTestName *<CR>:GTestRun<CR>
 
 772 nnoremap <Leader>tu :GTestRunUnderCursor<CR>
 
 775 let g:vim_json_syntax_conceal = 0
 
 778 let g:sneak#streak = 1
 
 779 let g:sneak#target_labels = "aoeuisnthdpylrcgfqjkxzmwvz" " dvorak
 
 780 let g:sneak#use_ic_scs = 1  " follow 'ignorecase' and 'smartcase'
 
 798 " Convenient command to see the difference between the current buffer and the
 
 799 " file it was loaded from, thus the changes you made.
 
 800 " Only define it when not defined already.
 
 801 if !exists(":DiffOrig")
 
 802   command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
 
 803                   \ | wincmd p | diffthis
 
 807 function! SortLinesOpFunc(...)
 
 810 nnoremap <silent> gs :<C-U>set operatorfunc=SortLinesOpFunc<CR>g@
 
 811 vnoremap <silent> gs :sort<cr>
 
 814 function! EditConfig(what, ext = '.vim')
 
 815     let l:dir = split(&runtimepath,',')[0]
 
 817         let l:file = expand($MYVIMRC)
 
 818     elseif ! isdirectory(globpath(l:dir, a:what))
 
 819         echoe a:what." is not valid!"
 
 820     elseif empty(&filetype)
 
 821         echoe 'filetype is empty!'
 
 823         let l:file = l:dir.'/'.a:what.'/'.&filetype.a:ext
 
 826     execute ':vsplit '.file
 
 829 nmap <leader>ev :call EditConfig('vimrc')<CR>
 
 830 nmap <leader>ef :call EditConfig('ftplugin')<CR>
 
 831 nmap <leader>es :call EditConfig('syntax')<CR>
 
 832 nmap <leader>ei :call EditConfig('indent')<CR>
 
 833 nmap <leader>eu :call EditConfig('ultisnips', '.snippets')<CR>
 
 836 " http://tex.stackexchange.com/a/52932
 
 837 let g:myLangList=["en_gb","en_us","de","fr"]
 
 839 function! ToggleSpell()
 
 840   if !exists("b:myLang")
 
 843   execute "setlocal spell!"
 
 845     echo "setlocal spelllang=" g:myLangList[b:myLang]
 
 849 function! SwitchSpell()
 
 850   if !exists("b:myLang")
 
 854     let b:myLang=b:myLang+1
 
 855     if b:myLang>=len(g:myLangList) | let b:myLang=0 | endif
 
 857   execute "setlocal spell spelllang=".get(g:myLangList, b:myLang)
 
 858   echo "setlocal spelllang=" g:myLangList[b:myLang]
 
 861 nnoremap <silent> coS :call SwitchSpell()<CR>
 
 862 " fix spelling with first choice
 
 863 nnoremap <Leader>f 1z=
 
 865 " gitdir or home {{{2
 
 867 " http://git.io/v3GAV
 
 868 function! FindGitDirOrHome()
 
 869   let filedir = expand('%:p:h')
 
 870   if isdirectory(filedir)
 
 871     let cmd = 'bash -c "(cd ' . filedir . '; git rev-parse --show-toplevel 2>/dev/null)"'
 
 872     let gitdir = system(cmd)
 
 873     if strlen(gitdir) == 0
 
 883 command! Cdr execute('cd ' . FindGitDirOrHome())
 
 885 command! LCdr execute('lcd ' . FindGitDirOrHome())
 
 887 " vim:set et sw=2 ts=2 tw=78: