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 " prefer other signs such as ycm diags
 
  23 let g:gitgutter_sign_priority = 1
 
  24 " don't clobber other signs
 
  25 let g:gitgutter_sign_allow_clobber = 0
 
  27 Plug 'alepez/vim-gtest'
 
  29 Plug 'andrewradev/switch.vim'
 
  30 Plug 'bling/vim-airline'
 
  31 Plug 'chrisbra/checkattach'
 
  32 Plug 'derekwyatt/vim-fswitch'
 
  34 Plug 'firef0x/pkgbuild.vim'
 
  35 Plug 'junegunn/vim-easy-align'
 
  36 Plug 'justinmk/vim-sneak'
 
  37 Plug 'klen/python-mode'
 
  38 Plug 'kshenoy/vim-signature'
 
  39 Plug 'majutsushi/tagbar'
 
  40 Plug 'octol/vim-cpp-enhanced-highlight'
 
  41 Plug 'raimondi/delimitmate'
 
  42 Plug 'sgeb/vim-diff-fold'
 
  43 Plug 'shougo/unite.vim'
 
  44 Plug 'shougo/vimproc.vim', {'do': 'make'}
 
  46 Plug 'thinca/vim-qfreplace'
 
  47 Plug 'tomtom/tcomment_vim'
 
  48 Plug 'tpope/vim-abolish'
 
  49 Plug 'tpope/vim-endwise'
 
  50 Plug 'tpope/vim-eunuch'
 
  51 Plug 'tpope/vim-fugitive'
 
  52 Plug 'tpope/vim-repeat'
 
  53 Plug 'tpope/vim-scriptease'
 
  54 Plug 'tpope/vim-speeddating'
 
  55 Plug 'tpope/vim-surround'  "investigate vim-sandwich
 
  56 Plug 'tpope/vim-unimpaired'
 
  57 Plug 'tweekmonster/spellrotate.vim'
 
  58 Plug 'valloric/youcompleteme', { 'do': './install.py --clangd-completer --clang-completer' }
 
  59 Plug 'vim-scripts/mediawiki.vim'
 
  60 Plug 'vim-scripts/replacewithregister'
 
  61 Plug 'vim-scripts/yankring.vim'
 
  65 Plug 'morhetz/gruvbox' " {{{2
 
  66 let g:gruvbox_contrast_dark  = 'hard'
 
  67 let g:gruvbox_contrast_light = 'soft'
 
  69 Plug 'arcticicestudio/nord-vim' " {{{2
 
  72 let g:nord_italic_comments = 1
 
  73 let g:nord_underline = 1
 
  74 let g:nord_uniform_status_lines = 0
 
  75 let g:nord_uniform_diff_background = 0
 
  76 let g:nord_cursor_line_number_background = 0
 
  77 let g:nord_bold_vertical_split_line = 0
 
  82 Plug 'sirver/ultisnips'
 
  83 Plug 'honza/vim-snippets'
 
  86 Plug 'kana/vim-textobj-user'
 
  87 Plug 'julian/vim-textobj-variable-segment'
 
  88 Plug 'sgur/vim-textobj-parameter'
 
  89 Plug 'kana/vim-operator-user'
 
  92 " Check LucHermites plugins: https://github.com/LucHermitte/lh-cpp
 
  94 Plug 'git@github.com:/ram-z/vim-orgmode', { 'branch': 'dev' } " {{{2
 
  95 Plug 'vim-scripts/syntaxrange'
 
  97 let g:org_agenda_files = ['~/org/*.org']
 
  99 Plug 'neovimhaskell/haskell-vim'  " {{{2
 
 100 let g:haskell_enable_quantification = 1   " to enable highlighting of `forall`
 
 101 let g:haskell_enable_recursivedo = 1      " to enable highlighting of `mdo` and `rec`
 
 102 let g:haskell_enable_arrowsyntax = 1      " to enable highlighting of `proc`
 
 103 let g:haskell_enable_pattern_synonyms = 1 " to enable highlighting of `pattern`
 
 104 let g:haskell_enable_typeroles = 1        " to enable highlighting of type roles
 
 105 let g:haskell_enable_static_pointers = 1  " to enable highlighting of `static`
 
 106 let g:haskell_backpack = 1                " to enable highlighting of backpack keywords
 
 108 let g:haskell_indent_before_where = 2
 
 111 Plug 'aklt/plantuml-syntax'
 
 113 Plug 'mtth/scratch.vim'  " {{{2
 
 114   let g:scratch_no_mappings = 1
 
 115   let g:scratch_autohide = 0
 
 118 Plug 'vim-utils/vim-man'  " {{{2
 
 124 filetype plugin indent on
 
 129 let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
 
 130 let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
 
 133 "TODO see how I can integrate this into a theme that customises upstream Nord
 
 134 hi debugPC term=reverse ctermbg=8
 
 137 " moving around, searching and patterns {{{2
 
 138 set incsearch           " show match for partly typed search command
 
 139 set ignorecase          " ignore case when using a search pattern
 
 140 set smartcase           " override 'ignorecase' when pattern has upper case characters
 
 141 set hlsearch            " highlight all matches for the last used search pattern
 
 143 set nostartofline       " don't move the cursor to the first non-blank char of a line
 
 146 set path+=../include/
 
 147 set path+=/usr/include/c++/*
 
 149 " displaying text {{{2
 
 150 set nowrap                      " long lines wrap
 
 151 set linebreak                   " wrap long lines at a character in 'breakat'
 
 152 set showbreak=↪                 " show these chars for wrapped lines
 
 153 set breakindent                 " preserve indentation in wrapped text
 
 155 set lazyredraw                  " don't redraw while executing macros
 
 157 set list                        " show chars defined in 'listchars'
 
 158 set listchars=tab:❭\            " list of strings used for list mode
 
 159 set listchars+=extends:❯,precedes:❮
 
 160 " Only shown when not in insert mode
 
 161 set listchars+=trail:·
 
 164     au FileType qf setlocal listchars-=trail:·
 
 165     au InsertEnter * set listchars-=trail:·
 
 166     au InsertLeave * set listchars+=trail:·
 
 169 set scrolloff=5                 " number of screen lines to show around the cursor
 
 170 set sidescroll=1                " number of collumns to scroll
 
 171 set sidescrolloff=1             " don't scroll over the listchars
 
 173 set fillchars=diff:⣿,vert:│
 
 175 set nonumber                    " show the line number for each line
 
 176 set norelativenumber            " show the relative line number for each line
 
 178 " syntax, highlighting and spelling {{{2
 
 179 set synmaxcol=800               " don't highlight long lines
 
 181 set dictionary=spell            " list of dictionary files for keyword completion
 
 185 " multiple windows {{{2
 
 186 set laststatus=2                " 0, 1 or 2; when to use a status line for the last window
 
 188 set previewheight=20            " default height for the preview window
 
 192 " set splitbelow                  " a new window is put below of the current one
 
 193 set splitright                  " a new window is put right of the current one
 
 198 " using the mouse {{{2
 
 199 set mouse=rnv                   " list of flags for using the mouse
 
 200 set ttymouse=xterm              " type of mouse
 
 202 " messages and info {{{2
 
 203 set showcmd         " Show (partial) command in status line.
 
 204 set ruler           " show the cursor position all the time
 
 205 set confirm         " Ask what to do when closing unsaved documents
 
 206 set shortmess=      " reset option
 
 207 set shortmess+=a    " all abbreviations
 
 208 set shortmess+=o    " overwrite file-written message
 
 209 set shortmess+=O    " file-read message overrides previous
 
 210 set shortmess+=t    " truncate file message at start
 
 211 set shortmess+=T    " truncate other messages in the middle
 
 212 set shortmess+=W    " don't give 'written' or '[w]' when writing a file
 
 213 set shortmess+=A    " ignore swapfile warning
 
 214 set shortmess+=I    " no splash screen
 
 217 set backspace=indent,eol,start  " allow backspacing over everything in insert mode
 
 219 set showmatch                   " Show matching brackets.
 
 221 set nojoinspaces                " don't use two spaces after '.' when joining a line
 
 222 set formatoptions+=j    " Delete comment leader when joining lines
 
 223 set formatoptions+=c    " Autowrap comments using textwidth
 
 224 set formatoptions+=r    " Insert comment leader after hitting <Enter>
 
 225 set formatoptions+=n    " Recognize numbered lists
 
 226 set formatoptions+=q    " Allow formatting of comments with "gq".
 
 227 set formatoptions+=l    " do not wrap lines that have been longer when starting insert mode already
 
 228 set formatoptions+=t    " Auto-wrap text using textwidth
 
 229 set formatoptions-=o    " Do not insert comment leader after hitting o or O in normal mode
 
 231 set nrformats=hex               " number formats recognized for CTRL-A and CTRL-X commands
 
 233 set complete=.       " scan the current buffer ( 'wrapscan' is ignored)
 
 234 set complete+=w      " scan buffers from other windows
 
 235 set complete+=b      " scan other loaded buffers that are in the buffer list
 
 236 set complete+=u      " scan the unloaded buffers that are in the buffer list
 
 237 set complete+=t      " scan tags
 
 238 set complete+=i      " scan current and included files
 
 239 set complete+=kspell " use the currently active spell checking |spell|
 
 241 " whether to use a popup menu for Insert mode completion
 
 242 set completeopt=longest,menuone,preview
 
 244 " tabs and indent {{{2
 
 245 set shiftwidth=4                " number of spaces used for each step of (auto)indent
 
 246 set smarttab                    " a <Tab> in an indent inserts 'shiftwidth' spaces
 
 247 set softtabstop=4               " if non-zero, number of spaces to insert for a <Tab>
 
 248 set shiftround                  " round to 'shiftwidth' for "<<" and ">>"
 
 249 set expandtab                   " expand <Tab> to spaces in Insert mode
 
 252 set pastetoggle=<F11>           " key sequence to toggle paste mode
 
 255 set foldmethod=marker           " folding type
 
 256 set foldlevelstart=0            " value for 'foldlevel' when starting to edit a file
 
 258 " open folds when jumping to line
 
 261 set viewoptions=cursor          " save cursor position
 
 262 set viewoptions+=folds          " save folds
 
 265 set diffopt+=filler         " show filler lines
 
 266 set diffopt+=vertical       " always vertical split
 
 267 set diffopt+=context:10     " 10 lines context between changes
 
 268 set diffopt+=internal
 
 269 set diffopt+=algorithm:patience
 
 271 " reading and writing files {{{2
 
 272 set modeline                    " read modelines
 
 273 set modelines=2                 " only check first/last 2 lines
 
 275 set writebackup                 " write a backup file before overwriting a file
 
 276 set backup                      " keep a backup after owerwriting a file
 
 277 set backupdir=$XDG_CACHE_HOME/vim/backup//
 
 279 set backupskip+=.netrc          " skip netrc
 
 280 set backupskip+=/dev/shm/pass*  " skip passwordstore files
 
 282 set undofile                    " persistent undo history
 
 283 set undodir=$XDG_CACHE_HOME/vim/undo//
 
 287     au BufWritePre .netrc         setlocal noundofile
 
 288     au BufWritePre /dev/shm/pass* setlocal noundofile
 
 289     au BufWritePre /tmp/*         setlocal noundofile
 
 292 set autowrite                   " automatically write a file when leaving a modified buffer
 
 293 set autoread                    " automatically read a file that has been modified
 
 297 set directory=$XDG_CACHE_HOME/vim/swap//
 
 299 " command line editing {{{2
 
 300 set history=5000                " how many command lines are remembered
 
 301 set wildmenu                    " command-line completion shows a list of matches
 
 302 set wildmode=longest:full,full  " specifies how command line completion works
 
 303 set wildignorecase              " ignore case when completing file names
 
 305 set wildignore+=.hg,.git,.svn                    " Version control
 
 306 set wildignore+=*.aux,*.out,*.toc                " LaTeX intermediate files
 
 307 set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg   " binary images
 
 308 set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
 
 309 set wildignore+=*.spl                            " compiled spelling word lists
 
 310 set wildignore+=*.sw?                            " Vim swap files
 
 311 set wildignore+=*.luac                           " Lua byte code
 
 312 set wildignore+=*.pyc                            " Python byte code
 
 313 set wildignore+=*.orig                           " Merge resolution files
 
 315 " running make and jumping to errors {{{2
 
 316 set makeprg=make\ -w     " print changing directories
 
 318 set grepprg=ag\ --vimgrep\ $*
 
 320 " language specific {{{2
 
 321 set isfname-==    " don't treat `=` as being part of filenames
 
 324 set virtualedit+=block     " let cursor move past last char in <C-V> mode
 
 325 set virtualedit+=onemore   " allow the cursor to move just past the end of the line
 
 326 set viminfo='100,<50,s10,h,n$XDG_CACHE_HOME/vim/viminfo " viminfo defaults but save file in .cache
 
 328 set viewdir=$XDG_CACHE_HOME/vim/view//
 
 330 set sessionoptions+=unix,slash  " damn windows and it's silly ways
 
 333 " Resize splits when the window is resized {{{2
 
 336     autocmd VimResized * :wincmd =
 
 339 " Only show cursorline in the current window and in normal mode {{{2
 
 342     au WinLeave,InsertEnter * set nocursorline
 
 343     au WinEnter,InsertLeave * set cursorline
 
 346 " Treat buffers from stdin (e.g.: echo foo | vim -) as scratch {{{2
 
 349     au StdinReadPost * :set buftype=nofile
 
 352 " Jump to last known cursor position {{{2
 
 355     " blacklist certain filetype
 
 356     let blacklist = ['gitcommit']
 
 357     autocmd BufReadPost *
 
 358                 \ if index(blacklist, &ft) < 0 && line("'\"") > 1 && line("'\"") <= line("$") |
 
 359                 \   exe "normal! g`\"" |
 
 363 " Check for file modifications automatically {{{2
 
 364 " (current buffer only)
 
 365 " Use :NoAutoChecktime to disable it (uses b:autochecktime)
 
 366 fun! MyAutoCheckTime()
 
 367   " only check timestamp for normal files
 
 368   if &buftype != '' | return | endif
 
 369   if ! exists('b:autochecktime') || b:autochecktime
 
 371     let b:autochecktime = 1
 
 374 augroup MyAutoChecktime
 
 376   au FocusGained,BufEnter,CursorHold,InsertEnter * call MyAutoCheckTime()
 
 378 command! NoAutoChecktime let b:autochecktime=0
 
 379 command! ToggleAutoChecktime let b:autochecktime=!get(b:, 'autochecktime', 0) | echom "b:autochecktime:" b:autochecktime
 
 383   au TerminalOpen * if &buftype == 'terminal' | setlocal bufhidden=hide | endif
 
 388 " allow both <space> and \ to be <leader>
 
 394   if exists("b:make_dir")
 
 395     let l:make_dir = "-C ".b:make_dir
 
 396   elseif exists("g:make_dir")
 
 397     let l:make_dir = "-C ".g:make_dir
 
 400   let l:make_targets = ""
 
 401   if exists("g:make_targets")
 
 402     let l:make_targets = g:make_targets
 
 404   execute "make! ".l:make_dir." ".l:make_targets
 
 406 nnoremap <leader>r :call Make()<cr>
 
 409 nnoremap <silent> <Leader>/ :silent nohl<CR>
 
 412 nnoremap <leader>[ :tabprev<cr>
 
 413 nnoremap <leader>] :tabnext<cr>
 
 415 " paste from selection
 
 416 nnoremap <leader>p* :silent! set paste<CR>"*p:set nopaste<CR>
 
 417 " paste from clipboard
 
 418 nnoremap <leader>p+ :silent! set paste<CR>"+p:set nopaste<CR>
 
 420 " strip trailing whitespace
 
 421 function! StripWhitespace(line1, line2, ...)  " {{{2
 
 422   let s_report = &report
 
 424   let pattern = a:0 ? a:1 : '\s\+$'
 
 425   let oldview = winsaveview()
 
 426   exe 'keepjumps keeppatterns '.a:line1.','.a:line2.'substitute/'.pattern.'//e'
 
 427   if oldview != winsaveview()
 
 430   call winrestview(oldview)
 
 431   let &report = s_report
 
 433 command! -range=% -nargs=0 -bar Untrail keepjumps call StripWhitespace(<line1>,<line2>)
 
 434 nnoremap <silent> <leader>ww :Untrail<CR>
 
 437 vnoremap <leader>S y:execute @@<cr>:echo 'Sourced selection.'<cr>
 
 438 nnoremap <leader>S ^vg_y:execute @@<cr>:echo 'Sourced line.'<cr>
 
 440 " jump to last cursor position
 
 443 " Select (charwise) the contents of the current line, excluding indentation.
 
 448       \ :syntax sync fromstart<cr>
 
 449       \ :AirlineRefresh<cr>
 
 450       \ :call popup_clear(1)<cr>
 
 454 " nnoremap <leader>r :silent !ranger %:h<cr>:redraw!<cr>
 
 455 " nnoremap <leader>R :silent !ranger<cr>:redraw!<cr>
 
 462 " display the number of matches for the last search
 
 463 nmap <Leader># :%s:<C-R>/::gn<CR>
 
 465 " center cursor after search and open folds
 
 469 " same when jumping around
 
 472 nnoremap <c-o> <c-o>zzzv
 
 473 nnoremap <c-i> <c-i>zzzv
 
 475 " Not using the default mappings of 'To line from top/bottom'
 
 481 " Heresy, emacs insert bindings
 
 482 inoremap <C-A> <Esc>I
 
 483 inoremap <C-E> <Esc>A
 
 484 cnoremap <C-A> <Home>
 
 487 " proper movement when lines are wrapped
 
 488 noremap <silent><expr> j (v:count == 0 ? 'gj' : 'j')
 
 489 noremap <silent><expr> k (v:count == 0 ? 'gk' : 'k')
 
 495 noremap  <Right> <NOP>
 
 497 inoremap <Down>  <NOP>
 
 498 inoremap <Left>  <NOP>
 
 499 inoremap <Right> <NOP>
 
 501 cnoremap <Down>  <NOP>
 
 502 cnoremap <Left>  <NOP>
 
 503 cnoremap <Right> <NOP>
 
 505 cnoremap <C-J>   <Down>
 
 506 cnoremap <C-H>   <Left>
 
 507 cnoremap <C-L>   <Right>
 
 509 " close all folds open fold in cursor
 
 512 map <F1> :ls<CR>:b<space>
 
 514 " move between windows (skip previewwindow)
 
 515 nnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
 
 516 nnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
 
 517 tnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
 
 518 tnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
 
 520 "xterm mouse with middleclick paste
 
 521 nnoremap <MiddleMouse> i<MiddleMouse>
 
 522 vnoremap <MiddleMouse> s<MiddleMouse>
 
 524 " fix legacy vi inconsistency
 
 529 " allow repeat operator on visual
 
 530 vnoremap . :normal .<CR>
 
 532 " add line without changing position or leaving mode
 
 533 noremap <silent> <Leader>o :set paste<CR>m`o<ESC>``:set nopaste<CR>
 
 534 noremap <silent> <Leader>O :set paste<CR>m`O<ESC>``:set nopaste<CR>
 
 536 " Don't use Ex mode, use Q for formatting
 
 539 " break undo sequence before removing word
 
 540 inoremap <C-W> <C-G>u<C-W>
 
 542 nnoremap coe :set <C-R>=&expandtab ? 'noexpandtab' : 'expandtab'<CR><CR>
 
 543 nnoremap [oe :set expandtab<CR>
 
 544 nnoremap ]oe :set noexpandtab<CR>
 
 546 for idt in range(1,8)
 
 547   exe 'nnoremap co'.idt.' :setlocal tabstop='.idt.' shiftwidth='.idt.' softtabstop='.idt.'<CR>'
 
 550 " toggle auto format of text
 
 551 nnoremap coa :set <C-R>=&formatoptions =~ "a" ? 'formatoptions-=a' : 'formatoptions+=a'<CR><CR>
 
 552 nnoremap [oa :set formatoptions+=a<CR>
 
 553 nnoremap ]oa :set formatoptions-=a<CR>
 
 555 " space will toggle current fold in normal mode
 
 556 nnoremap <leader><Space> za
 
 557 " create folds around visual selection
 
 558 vnoremap <leader><Space> zf
 
 561 cabbrev w!! SudoWrite
 
 563 " uppercase previous word
 
 564 inoremap <C-C> <Esc>gUiwgi
 
 566 " http://git.io/v3ZeU
 
 567 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>
 
 569 " plugins options {{{1
 
 571 let g:airline#extensions#whitespace#enabled = 1
 
 572 let g:airline#extensions#tabline#enabled = 1
 
 573 let g:airline#extensions#searchcount#enabled = 0
 
 574 let g:airline_powerline_fonts = 1
 
 577 let g:checkattach_filebrowser = 'ranger'
 
 578 let g:checkattach_once = 'y'
 
 581 let delimitMate_expand_cr = 2
 
 582 let g:delimitMate_expand_space = 1
 
 585 nnoremap <silent> <Leader>ff :FSHere<CR>
 
 586 nnoremap <silent> <Leader>fl :FSRight<CR>
 
 587 nnoremap <silent> <Leader>fh :FSLeft<CR>
 
 588 nnoremap <silent> <Leader>fj :FSBelow<CR>
 
 589 nnoremap <silent> <Leader>fk :FSAbove<CR>
 
 590 nnoremap <silent> <Leader>fL :FSSplitRight<CR>
 
 591 nnoremap <silent> <Leader>fH :FSSplitLeft<CR>
 
 592 nnoremap <silent> <Leader>fJ :FSSplitBelow<CR>
 
 593 nnoremap <silent> <Leader>fK :FSSplitAbove<CR>
 
 596 nmap <silent> <leader>dd :tab split \| Gdiff \| wincmd h<CR>
 
 597 " delete fugitive buffers when closed
 
 598 autocmd BufReadPost fugitive://* set bufhidden=delete
 
 600 nnoremap <silent> <leader>gs :Git<CR>
 
 601 nnoremap <silent> <leader>gd :Gdiffsplit<CR>
 
 602 nnoremap <silent> <leader>gc :echohl WarningMsg \| echo "use \<leader>gcc instead" \| echohl None<CR> 
 
 603 nnoremap <silent> <leader>gcc :tab G commit -v<CR>
 
 604 nnoremap <silent> <leader>gca :tab G commit -v --amend<CR>
 
 605 nnoremap          <leader>gcf :tab G commit -v --fixup=
 
 606 nnoremap <silent> <leader>gp :echohl WarningMsg \| echo "use \<leader>gpp instead" \| echohl None<CR> 
 
 607 nnoremap <silent> <leader>gpp :Git push \| copen<CR>
 
 608 nnoremap <silent> <leader>gpf :Git push --force-with-lease \| copen<CR>
 
 609 nnoremap <silent> <leader>gll :Git pull<CR>
 
 610 nnoremap <silent> <leader>gru :Git rebase --interactive @{upstream}<CR>
 
 611 nnoremap <silent> <leader>grp :Git rebase --interactive @{push}<CR>
 
 612 nnoremap <silent> <leader>ga :Gwrite<cr>
 
 613 nnoremap <silent> <leader>gb :G blame<cr>
 
 615 augroup fugitive_gstatus
 
 617     autocmd BufWinEnter */.git/index resize 16
 
 621 nnoremap <F7> :GundoToggle<CR>
 
 622 let g:gundo_prefer_python3 = 1
 
 625 let g:indent_guides_default_mapping = 0
 
 626 let g:indent_guides_guide_size = 1
 
 627 nmap <silent> cog <Plug>IndentGuidesToggle
 
 628 nmap <silent> [og <Plug>IndentGuidesEnable
 
 629 nmap <silent> ]og <Plug>IndentGuidesDisable
 
 631 " close-another-window {{{2
 
 632 nnoremap <silent> <C-W>c  <NOP>
 
 633 nnoremap <silent> <C-W>cc <C-W>c
 
 634 nnoremap <silent> <C-W>ch :CloseLeftWindow<CR>
 
 635 nnoremap <silent> <C-W>cl :CloseRightWindow<CR>
 
 636 nnoremap <silent> <C-W>cj :CloseBelowWindow<CR>
 
 637 nnoremap <silent> <C-W>ck :CloseAboveWindow<CR>
 
 641 let g:pymode_rope_completion = 0
 
 642 let g:pymode_rope = 0
 
 644 let g:pymode_folding = 1
 
 645 let g:pymode_lint_ignore = "E221,E266,E501"
 
 646 let g:pymode_lint_cwindow = 0           " don't open cwindow when linting
 
 647 let g:pymode_syntax_space_errors = 0    " don't bother me when I'm typing
 
 650 " disable '[ mappings
 
 652 let g:SignatureMap = {
 
 653   \ 'GotoNextLineAlpha'  :  "",
 
 654   \ 'GotoPrevLineAlpha'  :  "",
 
 655   \ 'GotoNextSpotAlpha'  :  "",
 
 656   \ 'GotoPrevSpotAlpha'  :  "",
 
 660 let g:switch_mapping = "<Leader>s"
 
 663 nmap <silent> z] <Plug>(SpellRotateForward)
 
 664 nmap <silent> z[ <Plug>(SpellRotateBackward)
 
 665 vmap <silent> z] <Plug>(SpellRotateForwardV)
 
 666 vmap <silent> z[ <Plug>(SpellRotateBackwardV)
 
 669 let g:syntastic_enable_highlighting = 0
 
 670 let g:syntastic_error_symbol='E'
 
 671 let g:syntastic_style_error_symbol='S'
 
 672 let g:syntastic_warning_symbol='W'
 
 673 let g:syntastic_style_warning_symbol='S'
 
 674 let g:syntastic_always_populate_loc_list=1
 
 675 nmap <silent> <leader>y :SyntasticCheck<cr>
 
 677 let g:syntastic_cpp_clang_tidy_post_args = "-p build*"
 
 680   let g:syntastic_check_on_open=1
 
 684 map <F5> :TagbarToggle<cr>
 
 685 let g:tagbar_sort = 0
 
 686 let g:tagbar_compact = 1
 
 687 let g:tagbar_autoshowtag = 1
 
 688 let g:tagbar_width = 25
 
 689 let g:tagbar_iconchars = ['+', '-']
 
 692 let g:tcomment_textobject_inlinecomment = 'gic'
 
 693 let g:tcomment#filetype#guess = 0
 
 696 let g:UltiSnipsEditSplit = 'vertical'
 
 697 let g:UltiSnipsSnippetDirectories = [ expand("$XDG_CONFIG_HOME/vim/ultisnips") ]
 
 699   let g:UltiSnipsSnippetDirectories = ["UltiSnips", "ultisnips"]
 
 701 let g:UltiSnipsExpandTrigger       = "<tab>"
 
 702 let g:UltiSnipsJumpForwardTrigger  = "<tab>"
 
 703 let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
 
 705 " UltiSnips completion function that tries to expand a snippet. If there's no
 
 706 " snippet for expanding, it checks for completion window and if it's shown,
 
 707 " selects first element. If there's no completion window it tries to jump to
 
 708 " next placeholder. If there's no placeholder it just returns TAB key
 
 709 " https://github.com/Valloric/YouCompleteMe/issues/36#issuecomment-15451411
 
 710 function! g:UltiSnips_Complete()
 
 711     call UltiSnips#ExpandSnippet()
 
 712     if g:ulti_expand_res == 0
 
 716             call UltiSnips#JumpForwards()
 
 717             if g:ulti_jump_forwards_res == 0
 
 724 au InsertEnter * exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=g:UltiSnips_Complete()<cr>"
 
 725 let g:UltiSnipsListSnippets="<c-e>"
 
 728 call unite#filters#matcher_default#use(['matcher_fuzzy'])
 
 729 call unite#custom#profile('default', 'context', {
 
 731             \ 'direction': 'botright'
 
 734 nnoremap [unite] <Nop>
 
 735 nmap <leader>u [unite]
 
 736 nnoremap [unite]u :UniteResume<CR>
 
 737 nnoremap <silent> [u :UnitePrevious<CR>
 
 738 nnoremap <silent> ]u :UniteNext<CR>
 
 741 " seems not respected
 
 742 let g:unite_source_grep_max_candidates = 2000
 
 744     " Use ag in unite grep source.
 
 745     let g:unite_source_grep_command = 'ag'
 
 746     let g:unite_source_grep_default_opts = '--smart-case --vimgrep --ignore ''.hg'' --ignore ''.svn'' --ignore ''.git'' --ignore ''.bzr'''
 
 747     let g:unite_source_grep_recursive_opt = ''
 
 749 nnoremap <silent> [unite]a :<C-u>Unite grep:.::
\12\17<CR>
 
 750 nnoremap <silent> [unite]A :<C-u>Unite grep:.:-w:
\12\17<CR>
 
 751 command! -nargs=+ Ag Unite -input=<args> grep:.:
 
 753 " unite-file_rec {{{3
 
 755     " Use ag in unite rec source
 
 756     let g:unite_source_rec_async_command = ['ag', '--follow', '--nocolor', '--nogroup', '-g', '']
 
 758 nnoremap <silent> [unite]f :<C-u>Unite -start-insert file_rec/async<CR>
 
 759 call unite#custom#source('file_rec/async', 'sorters', 'sorter_selecta')
 
 762 call unite#custom#default_action('buffer', 'open')
 
 763 nnoremap <silent> [unite]b :<C-u>Unite buffer:-<CR>
 
 765 " unite-jumplist {{{3
 
 766 nnoremap <silent> [unite]j :<C-u>Unite output:jumps:<CR>
 
 769 let g:unite_source_menu_menus = {}
 
 770 let g:unite_source_menu_menus.fugitive = { 'description' : 'fugitive menu'}
 
 771 let g:unite_source_menu_menus.fugitive.command_candidates = {
 
 772             \ 'Gstatus <Leader>gs' : 'Gstatus',
 
 773             \ 'Gcommit -v <Leader>gc' : 'Gcommit -v',
 
 777 nnoremap <silent> <leader>gg :<C-u>Unite menu:fugitive<CR>
 
 779 let g:unite_source_history_yank_enable = 1
 
 780 nnoremap <silent> [unite]p :<C-u>Unite history/yank<CR>
 
 783 nnoremap <silent> <leader>p :YRShow<cr>
 
 784 let g:yankring_history_dir = expand('$XDG_CACHE_HOME/vim')
 
 785 let g:yankring_replace_n_pkey = ''
 
 786 let g:yankring_replace_n_nkey = ''
 
 788 " map Y to y$ for the yank ring
 
 789 function! YRRunAfterMaps()
 
 790     nnoremap Y   :<C-U>YRYankCount 'y$'<CR>
 
 794 let g:ycm_clangd_binary_path = 'clangd'   " use clangd in path
 
 795 let g:ycm_clangd_args = ['--clang-tidy']
 
 796 let g:ycm_extra_conf_vim_data = ['getcwd()']
 
 797 let g:ycm_add_preview_to_completeopt = 1
 
 798 let g:ycm_complete_in_comments = 1
 
 799 let g:ycm_complete_in_strings  = 1
 
 800 let g:ycm_autoclose_preview_window_after_insertion = 0
 
 802 let g:ycm_language_server =
 
 806     \     'cmdline': [ 'haskell-language-server-wrapper', '--lsp' ],
 
 807     \     'filetypes': [ 'haskell', 'lhaskell'  ]
 
 811 " vim-easy-align {{{2
 
 812 " start interactive EasyAlign in visual mode
 
 813 vmap <Enter> <Plug>(EasyAlign)
 
 814 nmap ga <Plug>(EasyAlign)
 
 817 let g:gtest#highlight_failing_tests = 0
 
 819 nnoremap <silent> <Leader>tt :GTestRun<CR>
 
 820 nnoremap          <Leader>tc :GTestCase<space>
 
 821 nnoremap          <Leader>tn :GTestName<space>
 
 822 nnoremap <silent> <Leader>ta :GTestCase *<CR>:GTestName *<CR>:GTestRun<CR>
 
 823 nnoremap <silent> <Leader>tu :GTestRunUnderCursor<CR>
 
 826 let g:vim_json_syntax_conceal = 0
 
 829 let g:sneak#streak = 1
 
 830 let g:sneak#target_labels = "aoeuisnthdpylrcgfqjkxzmwvz" " dvorak
 
 831 let g:sneak#use_ic_scs = 1  " follow 'ignorecase' and 'smartcase'
 
 849 " Convenient command to see the difference between the current buffer and the
 
 850 " file it was loaded from, thus the changes you made.
 
 851 " Only define it when not defined already.
 
 852 if !exists(":DiffOrig")
 
 853   command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
 
 854                   \ | wincmd p | diffthis
 
 858 function! SortLinesOpFunc(...)
 
 861 nnoremap <silent> gs :<C-U>set operatorfunc=SortLinesOpFunc<CR>g@
 
 862 vnoremap <silent> gs :sort<cr>
 
 865 function! EditConfig(what, ext = '.vim')
 
 866     let l:dir = split(&runtimepath,',')[0]
 
 868         let l:file = expand($MYVIMRC)
 
 869     elseif ! isdirectory(globpath(l:dir, a:what))
 
 870         echoe a:what." is not valid!"
 
 871     elseif empty(&filetype)
 
 872         echoe 'filetype is empty!'
 
 874         let l:file = l:dir.'/'.a:what.'/'.&filetype.a:ext
 
 877     execute ':vsplit '.file
 
 880 nmap <leader>ev :call EditConfig('vimrc')<CR>
 
 881 nmap <leader>ef :call EditConfig('ftplugin')<CR>
 
 882 nmap <leader>es :call EditConfig('syntax')<CR>
 
 883 nmap <leader>ei :call EditConfig('indent')<CR>
 
 884 nmap <leader>eu :call EditConfig('ultisnips', '.snippets')<CR>
 
 887 " http://tex.stackexchange.com/a/52932
 
 888 let g:myLangList=["en_gb","en_us","de","fr"]
 
 890 function! ToggleSpell()
 
 891   if !exists("b:myLang")
 
 894   execute "setlocal spell!"
 
 896     echo "setlocal spelllang=" g:myLangList[b:myLang]
 
 900 function! SwitchSpell()
 
 901   if !exists("b:myLang")
 
 905     let b:myLang=b:myLang+1
 
 906     if b:myLang>=len(g:myLangList) | let b:myLang=0 | endif
 
 908   execute "setlocal spell spelllang=".get(g:myLangList, b:myLang)
 
 909   echo "setlocal spelllang=" g:myLangList[b:myLang]
 
 912 nnoremap <silent> coS :call SwitchSpell()<CR>
 
 913 " fix spelling with first choice
 
 914 nnoremap <Leader>f 1z=
 
 916 " gitdir or home {{{2
 
 918 " http://git.io/v3GAV
 
 919 function! FindGitDirOrHome()
 
 920   let filedir = expand('%:p:h')
 
 921   if isdirectory(filedir)
 
 922     let cmd = 'bash -c "(cd ' . filedir . '; git rev-parse --show-toplevel 2>/dev/null)"'
 
 923     let gitdir = system(cmd)
 
 924     if strlen(gitdir) == 0
 
 934 command! Cdr execute('cd ' . FindGitDirOrHome())
 
 936 command! LCdr execute('lcd ' . FindGitDirOrHome())
 
 938 " vim:set et sw=2 ts=2 tw=78: