2 if has('python3') | endif
 
   8 set runtimepath ^=$XDG_CONFIG_HOME/vim
 
   9 set runtimepath +=$XDG_CONFIG_HOME/vim/after
 
  12 call plug#begin('$XDG_DATA_HOME/vim')
 
  13 " This does not update vim-plug, use PlugUpgrade instead
 
  14 Plug 'junegunn/vim-plug'
 
  16 Plug 'airblade/vim-gitgutter' " {{{
 
  17 " prefer other signs such as ycm diags
 
  18 let g:gitgutter_sign_priority = 1
 
  19 " don't clobber other signs
 
  20 let g:gitgutter_sign_allow_clobber = 0
 
  22 Plug 'alepez/vim-gtest'
 
  24 Plug 'andrewradev/sideways.vim' " {{{2
 
  25 nnoremap <silent> ,h :SidewaysLeft<CR>:delmarks z<CR>
 
  26 nnoremap <silent> ,l :SidewaysRight<CR>:delmarks z<CR>
 
  28 Plug 'andrewradev/switch.vim'
 
  30   Plug 'bling/vim-airline' "{{{2
 
  31   let g:airline#extensions#whitespace#enabled = 1
 
  32   let g:airline#extensions#tabline#enabled = 1
 
  33   let g:airline#extensions#searchcount#enabled = 0
 
  34   let g:airline_powerline_fonts = 1
 
  36   let g:asyncrun_status = "stopped"
 
  37   " let g:airline_section_error = airline#section#create_right(['%{g:asyncrun_status}'])
 
  41 Plug 'chrisbra/checkattach'
 
  42 Plug 'derekwyatt/vim-fswitch'
 
  44 Plug 'firef0x/pkgbuild.vim'
 
  45 Plug 'junegunn/vim-easy-align'
 
  46 Plug 'justinmk/vim-sneak'
 
  47 Plug 'klen/python-mode'
 
  48 Plug 'kshenoy/vim-signature'
 
  49 Plug 'majutsushi/tagbar'
 
  50 Plug 'octol/vim-cpp-enhanced-highlight'
 
  51 Plug 'raimondi/delimitmate'
 
  52 Plug 'sgeb/vim-diff-fold'
 
  53 Plug 'skywind3000/asyncrun.vim' " {{{2
 
  54 command! -bang -nargs=* -complete=file Make AsyncRun -save=2 -program=make @ <args>
 
  55 let g:asyncrun_open = 10
 
  57 Plug 'shougo/unite.vim'
 
  58 Plug 'shougo/vimproc.vim', {'do': 'make'}
 
  60 Plug 'thinca/vim-qfreplace'
 
  61 Plug 'tomtom/tcomment_vim'
 
  62 Plug 'tpope/vim-abolish'
 
  63 Plug 'tpope/vim-characterize'
 
  64 Plug 'tpope/vim-endwise'
 
  65 Plug 'tpope/vim-eunuch'
 
  66 Plug 'tpope/vim-fugitive'
 
  67 Plug 'tpope/vim-repeat'
 
  68 Plug 'tpope/vim-scriptease'
 
  69 Plug 'tpope/vim-speeddating'
 
  70 Plug 'tpope/vim-surround'  "investigate vim-sandwich
 
  71 Plug 'tpope/vim-unimpaired'
 
  72 Plug 'tweekmonster/spellrotate.vim'
 
  74   " Plug 'valloric/youcompleteme' {{{2
 
  75   Plug 'valloric/youcompleteme',
 
  76         \{ 'do': './install.py --clangd-completer --clang-completer' }
 
  77   let g:ycm_clangd_binary_path = 'clangd'   " use clangd in path
 
  78   let g:ycm_clangd_args = ['--clang-tidy']
 
  79   let g:ycm_extra_conf_vim_data = ['getcwd()']
 
  80   let g:ycm_add_preview_to_completeopt = 1
 
  81   let g:ycm_complete_in_comments = 1
 
  82   let g:ycm_complete_in_strings  = 1
 
  83   let g:ycm_autoclose_preview_window_after_insertion = 0
 
  85   let g:ycm_language_server =
 
  89         \     'cmdline': [ 'haskell-language-server-wrapper', '--lsp' ],
 
  90         \     'filetypes': [ 'haskell', 'lhaskell'  ]
 
  95 Plug 'vim-scripts/mediawiki.vim'
 
  96 Plug 'vim-scripts/replacewithregister'
 
  97 Plug 'vim-scripts/yankring.vim'
 
 101 Plug 'morhetz/gruvbox' " {{{2
 
 102 let g:gruvbox_contrast_dark  = 'hard'
 
 103 let g:gruvbox_contrast_light = 'soft'
 
 106   Plug 'arcticicestudio/nord-vim' " {{{2
 
 108   let g:nord_italic = 1
 
 109   let g:nord_italic_comments = 1
 
 110   let g:nord_underline = 1
 
 111   let g:nord_uniform_status_lines = 0
 
 112   let g:nord_uniform_diff_background = 0
 
 113   let g:nord_cursor_line_number_background = 0
 
 114   let g:nord_bold_vertical_split_line = 0
 
 120   Plug 'sirver/ultisnips' " {{{
 
 121   Plug 'honza/vim-snippets'
 
 123   let g:UltiSnipsEditSplit = 'vertical'
 
 124   let g:UltiSnipsSnippetDirectories = [ expand("$XDG_CONFIG_HOME/vim/ultisnips") ]
 
 126     let g:UltiSnipsSnippetDirectories = ["UltiSnips", "ultisnips"]
 
 128   let g:UltiSnipsExpandTrigger       = "<tab>"
 
 129   let g:UltiSnipsJumpForwardTrigger  = "<tab>"
 
 130   let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
 
 132   " UltiSnips completion function that tries to expand a snippet. If there's no
 
 133   " snippet for expanding, it checks for completion window and if it's shown,
 
 134   " selects first element. If there's no completion window it tries to jump to
 
 135   " next placeholder. If there's no placeholder it just returns TAB key
 
 136   " https://github.com/Valloric/YouCompleteMe/issues/36#issuecomment-15451411
 
 137   function! g:UltiSnips_Complete()
 
 138       call UltiSnips#ExpandSnippet()
 
 139       if g:ulti_expand_res == 0
 
 143               call UltiSnips#JumpForwards()
 
 144               if g:ulti_jump_forwards_res == 0
 
 151   au InsertEnter * exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=g:UltiSnips_Complete()<cr>"
 
 152   let g:UltiSnipsListSnippets="<c-e>"
 
 157 Plug 'kana/vim-textobj-user'
 
 158 Plug 'julian/vim-textobj-variable-segment'
 
 159 Plug 'sgur/vim-textobj-parameter'
 
 160 Plug 'kana/vim-operator-user'
 
 163 " Check LucHermites plugins: https://github.com/LucHermitte/lh-cpp
 
 164 Plug 'imsnif/kdl.vim'
 
 166 Plug 'puremourning/vimspector'
 
 167 Plug 'ilyachur/cmake4vim'
 
 168 Plug 'ilyachur/gtest-vim'
 
 170 Plug 'git@github.com:/ram-z/vim-orgmode', { 'branch': 'dev' } " {{{2
 
 171 Plug 'vim-scripts/syntaxrange'
 
 173 let g:org_agenda_files = ['~/org/*.org']
 
 175 Plug 'neovimhaskell/haskell-vim'  " {{{2
 
 176 let g:haskell_enable_quantification = 1   " to enable highlighting of `forall`
 
 177 let g:haskell_enable_recursivedo = 1      " to enable highlighting of `mdo` and `rec`
 
 178 let g:haskell_enable_arrowsyntax = 1      " to enable highlighting of `proc`
 
 179 let g:haskell_enable_pattern_synonyms = 1 " to enable highlighting of `pattern`
 
 180 let g:haskell_enable_typeroles = 1        " to enable highlighting of type roles
 
 181 let g:haskell_enable_static_pointers = 1  " to enable highlighting of `static`
 
 182 let g:haskell_backpack = 1                " to enable highlighting of backpack keywords
 
 184 let g:haskell_indent_before_where = 2
 
 187 Plug 'aklt/plantuml-syntax'
 
 189 Plug 'mtth/scratch.vim'  " {{{2
 
 190   let g:scratch_no_mappings = 1
 
 191   let g:scratch_autohide = 0
 
 194 let g:man_hardwrap = 80
 
 196   Plug 'vim-utils/vim-man'  " {{{2
 
 201 Plug 'jenterkin/vim-autosource'  " {{{2
 
 202   let g:autosource_hashdir = $XDG_CACHE_HOME . '/vim/vim-autosource'
 
 203   let g:autosource_conf_names = ['.vimrc', '.vimrc.lua']
 
 207 filetype plugin indent on
 
 212 let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
 
 213 let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
 
 218 "TODO see how I can integrate this into a theme that customises upstream Nord
 
 219 hi debugPC term=reverse ctermbg=8
 
 222 " moving around, searching and patterns {{{2
 
 223 set incsearch           " show match for partly typed search command
 
 224 set ignorecase          " ignore case when using a search pattern
 
 225 set smartcase           " override 'ignorecase' when pattern has upper case characters
 
 226 set hlsearch            " highlight all matches for the last used search pattern
 
 228 set nostartofline       " don't move the cursor to the first non-blank char of a line
 
 231 set path+=../include/
 
 232 set path+=/usr/include/c++/*
 
 234 " displaying text {{{2
 
 235 set nowrap                      " long lines wrap
 
 236 set linebreak                   " wrap long lines at a character in 'breakat'
 
 237 set showbreak=↪                 " show these chars for wrapped lines
 
 238 set breakindent                 " preserve indentation in wrapped text
 
 240 set list                        " show chars defined in 'listchars'
 
 241 set listchars=tab:❭\            " list of strings used for list mode
 
 242 set listchars+=extends:❯,precedes:❮
 
 243 set listchars+=nbsp:␣
 
 244 " Only shown when not in insert mode
 
 245 set listchars+=trail:·
 
 248     au FileType qf setlocal listchars-=trail:·
 
 249     au InsertEnter * set listchars-=trail:·
 
 250     au InsertLeave * set listchars+=trail:·
 
 253 set scrolloff=5                 " number of screen lines to show around the cursor
 
 254 set sidescroll=1                " number of collumns to scroll
 
 255 set sidescrolloff=1             " don't scroll over the listchars
 
 256 set display+=lastline           " display as much as possible of last line
 
 258 set fillchars=diff:⣿,vert:│
 
 260 set nonumber                    " show the line number for each line
 
 261 set norelativenumber            " show the relative line number for each line
 
 263 " syntax, highlighting and spelling {{{2
 
 264 set synmaxcol=800               " don't highlight long lines
 
 266 set dictionary=spell            " list of dictionary files for keyword completion
 
 270 " multiple windows {{{2
 
 271 set laststatus=2                " 0, 1 or 2; when to use a status line for the last window
 
 273 set previewheight=20            " default height for the preview window
 
 277 " set splitbelow                  " a new window is put below of the current one
 
 278 set splitright                  " a new window is put right of the current one
 
 283 " using the mouse {{{2
 
 284 set mouse=rnv                   " list of flags for using the mouse
 
 286   set ttymouse=xterm              " type of mouse
 
 289 " messages and info {{{2
 
 290 set showcmd         " Show (partial) command in status line.
 
 291 set ruler           " show the cursor position all the time
 
 292 set confirm         " Ask what to do when closing unsaved documents
 
 293 set shortmess=      " reset option
 
 294 set shortmess+=a    " all abbreviations
 
 295 set shortmess+=o    " overwrite file-written message
 
 296 set shortmess+=O    " file-read message overrides previous
 
 297 set shortmess+=t    " truncate file message at start
 
 298 set shortmess+=T    " truncate other messages in the middle
 
 299 set shortmess+=W    " don't give 'written' or '[w]' when writing a file
 
 300 set shortmess+=A    " ignore swapfile warning
 
 301 set shortmess+=I    " no splash screen
 
 302 set shortmess+=c    " don't give |ins-completion-menu| messages
 
 305 set backspace=indent,eol,start  " allow backspacing over everything in insert mode
 
 307 set showmatch                   " Show matching brackets.
 
 309 set nojoinspaces                " don't use two spaces after '.' when joining a line
 
 310 set formatoptions+=j    " Delete comment leader when joining lines
 
 311 set formatoptions+=c    " Autowrap comments using textwidth
 
 312 set formatoptions+=r    " Insert comment leader after hitting <Enter>
 
 313 set formatoptions+=n    " Recognize numbered lists
 
 314 set formatoptions+=q    " Allow formatting of comments with "gq".
 
 315 set formatoptions+=l    " do not wrap lines that have been longer when starting insert mode already
 
 316 set formatoptions+=t    " Auto-wrap text using textwidth
 
 317 set formatoptions-=o    " Do not insert comment leader after hitting o or O in normal mode
 
 319 set nrformats-=octal    " don't inc/dec octal numbers with ^[AX]
 
 320 set nrformats+=unsigned " treat all numbers as unsigned
 
 322 set complete=.       " scan the current buffer ( 'wrapscan' is ignored)
 
 323 set complete+=w      " scan buffers from other windows
 
 324 set complete+=b      " scan other loaded buffers that are in the buffer list
 
 325 set complete+=u      " scan the unloaded buffers that are in the buffer list
 
 326 set complete+=t      " scan tags
 
 327 set complete+=i      " scan current and included files
 
 328 set complete+=kspell " use the currently active spell checking |spell|
 
 330 " whether to use a popup menu for Insert mode completion
 
 331 set completeopt=longest,menuone,preview
 
 333 " tabs and indent {{{2
 
 334 set shiftwidth=4                " number of spaces used for each step of (auto)indent
 
 335 set smarttab                    " a <Tab> in an indent inserts 'shiftwidth' spaces
 
 336 set softtabstop=4               " if non-zero, number of spaces to insert for a <Tab>
 
 337 set shiftround                  " round to 'shiftwidth' for "<<" and ">>"
 
 338 set expandtab                   " expand <Tab> to spaces in Insert mode
 
 341 set pastetoggle=<F11>           " key sequence to toggle paste mode
 
 344 set foldmethod=marker           " folding type
 
 345 set foldlevelstart=0            " value for 'foldlevel' when starting to edit a file
 
 347 " open folds when jumping to line
 
 350 set viewoptions=cursor          " save cursor position
 
 351 set viewoptions+=folds          " save folds
 
 354 set diffopt+=filler         " show filler lines
 
 355 set diffopt+=vertical       " always vertical split
 
 356 set diffopt+=context:10     " 10 lines context between changes
 
 357 set diffopt+=internal
 
 358 set diffopt+=algorithm:patience
 
 360 " reading and writing files {{{2
 
 361 set modeline                    " read modelines
 
 362 set modelines=2                 " only check first/last 2 lines
 
 364 set writebackup                 " write a backup file before overwriting a file
 
 365 set backup                      " keep a backup after owerwriting a file
 
 366 set backupdir=$XDG_CACHE_HOME/vim/backup//
 
 368 set backupskip+=.netrc          " skip netrc
 
 369 set backupskip+=/dev/shm/pass*  " skip passwordstore files
 
 371 set undofile                    " persistent undo history
 
 372 set undolevels=10000            " moar undos
 
 374   set undodir=$XDG_CACHE_HOME/vim/undo//
 
 379     au BufWritePre .netrc         setlocal noundofile
 
 380     au BufWritePre /dev/shm/pass* setlocal noundofile
 
 381     au BufWritePre /tmp/*         setlocal noundofile
 
 384 set autowrite                   " automatically write a file when leaving a modified buffer
 
 385 set autoread                    " automatically read a file that has been modified
 
 389 set directory=$XDG_CACHE_HOME/vim/swap//
 
 391 " command line editing {{{2
 
 392 set history=5000                " how many command lines are remembered
 
 393 set wildmenu                    " command-line completion shows a list of matches
 
 394 set wildmode=longest:full,full  " specifies how command line completion works
 
 395 set wildignorecase              " ignore case when completing file names
 
 397 set wildignore+=.hg,.git,.svn                    " Version control
 
 398 set wildignore+=*.aux,*.out,*.toc                " LaTeX intermediate files
 
 399 set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg   " binary images
 
 400 set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
 
 401 set wildignore+=*.spl                            " compiled spelling word lists
 
 402 set wildignore+=*.sw?                            " Vim swap files
 
 403 set wildignore+=*.luac                           " Lua byte code
 
 404 set wildignore+=*.pyc                            " Python byte code
 
 405 set wildignore+=*.orig                           " Merge resolution files
 
 407 " running make and jumping to errors {{{2
 
 408 set makeprg=make\ -w     " print changing directories
 
 410 set grepformat=%f:%l:%c:%m
 
 411 set grepprg=ag\ --vimgrep\ $*
 
 413 " language specific {{{2
 
 414 set isfname-==    " don't treat `=` as being part of filenames
 
 417 set virtualedit+=block     " let cursor move past last char in <C-V> mode
 
 418 set virtualedit+=onemore   " allow the cursor to move just past the end of the line
 
 420   " viminfo defaults but save file in .cache
 
 421   set viminfo='100,<50,s10,h,n$XDG_CACHE_HOME/vim/viminfo
 
 423   " shada is the replacement format for viminfo
 
 424   " this setting is probably not needed as it's most likely the default
 
 425   " the default path is in XDG_DATA_HOME, which is fine
 
 426   set shada='100,<50,s10,h
 
 429 set viewdir=$XDG_CACHE_HOME/vim/view//
 
 431 set sessionoptions+=unix,slash  " damn windows and it's silly ways
 
 434 " Resize splits when the window is resized {{{2
 
 435 augroup resize_splits
 
 437     autocmd VimResized * :tabdo wincmd =
 
 440 " Only show cursorline in the current window and in normal mode {{{2
 
 443     au WinLeave,InsertEnter * set nocursorline
 
 444     au WinEnter,InsertLeave * set cursorline
 
 447 " Treat buffers from stdin (e.g.: echo foo | vim -) as scratch {{{2
 
 450     au StdinReadPost * :set buftype=nofile
 
 453 " Jump to last known cursor position {{{2
 
 456     " blacklist certain filetype
 
 457     let blacklist = ['gitcommit']
 
 458     autocmd BufReadPost *
 
 459                 \ if index(blacklist, &ft) < 0 && line("'\"") > 1 && line("'\"") <= line("$") |
 
 460                 \   exe "normal! g`\"" |
 
 464 " Check for file modifications automatically {{{2
 
 465 " (current buffer only)
 
 466 " Use :NoAutoChecktime to disable it (uses b:autochecktime)
 
 467 fun! MyAutoCheckTime()
 
 468   " only check timestamp for normal files
 
 469   if &buftype != '' | return | endif
 
 470   if ! exists('b:autochecktime') || b:autochecktime
 
 472     let b:autochecktime = 1
 
 475 augroup MyAutoChecktime
 
 477   au FocusGained,BufEnter,CursorHold,InsertEnter * call MyAutoCheckTime()
 
 479 command! NoAutoChecktime let b:autochecktime=0
 
 480 command! ToggleAutoChecktime let b:autochecktime=!get(b:, 'autochecktime', 0) | echom "b:autochecktime:" b:autochecktime
 
 485 function! MakeWithOpt()
 
 486   " TODO only do this if makeprg matches make
 
 487   " if &makeprg =~ "make"
 
 489   if exists("b:make_dir")
 
 490     let l:make_dir = "-C ".b:make_dir
 
 491   elseif exists("t:make_dir")
 
 492     let l:make_dir = "-C ".t:make_dir
 
 493   elseif exists("g:make_dir")
 
 494     let l:make_dir = "-C ".g:make_dir
 
 497   let l:make_targets = ""
 
 498   if exists("g:make_targets")
 
 499     let l:make_targets = g:make_targets
 
 501   execute "Make ".l:make_dir." ".l:make_targets
 
 503 nnoremap <silent> <leader>r :call MakeWithOpt()<cr>
 
 506 nnoremap <silent> <Leader>/ :silent nohl<CR>
 
 509 nnoremap <leader>[ :tabprev<cr>
 
 510 nnoremap <leader>] :tabnext<cr>
 
 512 " paste from selection
 
 513 nnoremap <leader>p* :silent! set paste<CR>"*p:set nopaste<CR>
 
 514 " paste from clipboard
 
 515 nnoremap <leader>p+ :silent! set paste<CR>"+p:set nopaste<CR>
 
 517 " strip trailing whitespace
 
 518 function! StripWhitespace(line1, line2, ...)  " {{{2
 
 519   let s_report = &report
 
 521   let pattern = a:0 ? a:1 : '\s\+$'
 
 522   let oldview = winsaveview()
 
 523   exe 'keepjumps keeppatterns '.a:line1.','.a:line2.'substitute/'.pattern.'//e'
 
 524   if oldview != winsaveview()
 
 527   call winrestview(oldview)
 
 528   let &report = s_report
 
 530 command! -range=% -nargs=0 -bar Untrail keepjumps call StripWhitespace(<line1>,<line2>)
 
 531 nnoremap <silent> <leader>ww :Untrail<CR>
 
 534 vnoremap <leader>S y:execute @@<cr>:echo 'Sourced selection.'<cr>
 
 535 nnoremap <leader>S ^vg_y:execute @@<cr>:echo 'Sourced line.'<cr>
 
 537 " jump to last cursor position
 
 540 " Select (charwise) the contents of the current line, excluding indentation.
 
 545       \ :syntax sync fromstart<cr>
 
 546       \ :AirlineRefresh<cr>
 
 547       \ :call popup_clear(1)<cr>
 
 551 " nnoremap <leader>r :silent !ranger %:h<cr>:redraw!<cr>
 
 552 " nnoremap <leader>R :silent !ranger<cr>:redraw!<cr>
 
 559 " display the number of matches for the last search
 
 560 nmap <Leader># :%s:<C-R>/::gn<CR>
 
 562 " center cursor after search and open folds
 
 566 " same when jumping around
 
 569 nnoremap <c-o> <c-o>zzzv
 
 570 nnoremap <c-i> <c-i>zzzv
 
 572 " Not using the default mappings of 'To line from top/bottom'
 
 578 " Heresy, emacs insert bindings
 
 579 inoremap <C-A> <Esc>I
 
 580 inoremap <C-E> <Esc>A
 
 581 cnoremap <C-A> <Home>
 
 584 " proper movement when lines are wrapped
 
 585 noremap <silent><expr> j (v:count == 0 ? 'gj' : 'j')
 
 586 noremap <silent><expr> k (v:count == 0 ? 'gk' : 'k')
 
 592 noremap  <Right> <NOP>
 
 594 inoremap <Down>  <NOP>
 
 595 inoremap <Left>  <NOP>
 
 596 inoremap <Right> <NOP>
 
 598 cnoremap <Down>  <NOP>
 
 599 cnoremap <Left>  <NOP>
 
 600 cnoremap <Right> <NOP>
 
 602 cnoremap <C-J>   <Down>
 
 603 cnoremap <C-H>   <Left>
 
 604 cnoremap <C-L>   <Right>
 
 606 " close all folds open fold in cursor
 
 609 map <F1> :ls<CR>:b<space>
 
 611 " move between windows (skip previewwindow)
 
 612 nnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
 
 613 nnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
 
 614 tnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
 
 615 tnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
 
 617 "xterm mouse with middleclick paste
 
 618 nnoremap <MiddleMouse> i<MiddleMouse>
 
 619 vnoremap <MiddleMouse> s<MiddleMouse>
 
 621 " fix legacy vi inconsistency
 
 626 " allow repeat operator on visual
 
 627 vnoremap . :normal .<CR>
 
 629 " add line without changing position or leaving mode
 
 630 noremap <silent> <Leader>o :set paste<CR>m`o<ESC>``:set nopaste<CR>
 
 631 noremap <silent> <Leader>O :set paste<CR>m`O<ESC>``:set nopaste<CR>
 
 633 " Don't use Ex mode, use Q for formatting
 
 636 " break undo sequence before removing word
 
 637 inoremap <C-W> <C-G>u<C-W>
 
 639 nnoremap coe :set <C-R>=&expandtab ? 'noexpandtab' : 'expandtab'<CR><CR>
 
 640 nnoremap [oe :set expandtab<CR>
 
 641 nnoremap ]oe :set noexpandtab<CR>
 
 643 for idt in range(1,8)
 
 644   exe 'nnoremap co'.idt.' :setlocal tabstop='.idt.' shiftwidth='.idt.' softtabstop='.idt.'<CR>'
 
 647 " toggle auto format of text
 
 648 nnoremap coa :set <C-R>=&formatoptions =~ "a" ? 'formatoptions-=a' : 'formatoptions+=a'<CR><CR>
 
 649 nnoremap [oa :set formatoptions+=a<CR>
 
 650 nnoremap ]oa :set formatoptions-=a<CR>
 
 652 " space will toggle current fold in normal mode
 
 653 nnoremap <leader><Space> za
 
 654 " create folds around visual selection
 
 655 vnoremap <leader><Space> zf
 
 658 cabbrev w!! SudoWrite
 
 660 " uppercase previous word
 
 661 inoremap <C-C> <Esc>gUiwgi
 
 663 " http://git.io/v3ZeU
 
 664 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>
 
 666 " plugins options {{{1
 
 668 let g:checkattach_filebrowser = 'ranger'
 
 669 let g:checkattach_once = 'y'
 
 671 " close-another-window {{{2
 
 672 nnoremap <silent> <C-W>c  <NOP>
 
 673 nnoremap <silent> <C-W>cc <C-W>c
 
 674 nnoremap <silent> <C-W>ch :CloseLeftWindow<CR>
 
 675 nnoremap <silent> <C-W>cl :CloseRightWindow<CR>
 
 676 nnoremap <silent> <C-W>cj :CloseBelowWindow<CR>
 
 677 nnoremap <silent> <C-W>ck :CloseAboveWindow<CR>
 
 680 let delimitMate_expand_cr = 2
 
 681 let g:delimitMate_expand_space = 1
 
 684 nnoremap <silent> <Leader>ff :FSHere<CR>
 
 685 nnoremap <silent> <Leader>fl :FSRight<CR>
 
 686 nnoremap <silent> <Leader>fh :FSLeft<CR>
 
 687 nnoremap <silent> <Leader>fj :FSBelow<CR>
 
 688 nnoremap <silent> <Leader>fk :FSAbove<CR>
 
 689 nnoremap <silent> <Leader>fL :FSSplitRight<CR>
 
 690 nnoremap <silent> <Leader>fH :FSSplitLeft<CR>
 
 691 nnoremap <silent> <Leader>fJ :FSSplitBelow<CR>
 
 692 nnoremap <silent> <Leader>fK :FSSplitAbove<CR>
 
 695 nmap <silent> <leader>dd :tab split \| Gdiff \| wincmd h<CR>
 
 696 " delete fugitive buffers when closed
 
 697 autocmd BufReadPost fugitive://* set bufhidden=delete
 
 699 function! GitToggle()
 
 700   let l:status_buffer = bufname('^fugitive:///*/.git{/worktrees/*,}//$')
 
 701   if buflisted(l:status_buffer)
 
 702     execute 'bdelete '.l:status_buffer
 
 705     if !empty(FugitiveGitDir())
 
 706       " only resize status if Git was sucessful
 
 711 command! GitToggle :call GitToggle()
 
 712 command! GToggle GitToggle
 
 713 nnoremap <silent> <leader>gs :GitToggle<CR>
 
 715 nnoremap <silent> <leader>gd :Gdiffsplit<CR>
 
 716 nnoremap <silent> <leader>gc :echohl WarningMsg \| echo "use \<leader>gcc instead" \| echohl None<CR> 
 
 717 nnoremap <silent> <leader>gcc :tab G commit -v<CR>
 
 718 nnoremap <silent> <leader>gca :tab G commit -v --amend<CR>
 
 719 nnoremap          <leader>gcf :tab G commit -v --fixup=
 
 720 nnoremap <silent> <leader>gp :echohl WarningMsg \| echo "use \<leader>gpp instead" \| echohl None<CR> 
 
 721 nnoremap <silent> <leader>gpp :Git push \| copen<CR>
 
 722 nnoremap <silent> <leader>gpf :Git push --force-with-lease \| copen<CR>
 
 723 nnoremap <silent> <leader>gll :Git pull<CR>
 
 724 nnoremap <silent> <leader>gru :Git rebase --interactive @{upstream}<CR>
 
 725 nnoremap <silent> <leader>grp :Git rebase --interactive @{push}<CR>
 
 726 nnoremap <silent> <leader>ga :Gwrite<cr>
 
 727 nnoremap <silent> <leader>gb :G blame<cr>
 
 729 augroup fugitive_gstatus
 
 731     autocmd User FugitiveIndex setlocal winfixheight
 
 732     autocmd User FugitiveIndex nmap <buffer> <leader><space> =
 
 736 nnoremap <F7> :GundoToggle<CR>
 
 737 let g:gundo_prefer_python3 = 1
 
 740 let g:indent_guides_default_mapping = 0
 
 741 let g:indent_guides_guide_size = 1
 
 742 nmap <silent> cog <Plug>IndentGuidesToggle
 
 743 nmap <silent> [og <Plug>IndentGuidesEnable
 
 744 nmap <silent> ]og <Plug>IndentGuidesDisable
 
 748 let g:pymode_rope_completion = 0
 
 749 let g:pymode_rope = 0
 
 751 let g:pymode_folding = 1
 
 752 let g:pymode_lint_ignore = "E221,E266,E501"
 
 753 let g:pymode_lint_cwindow = 0           " don't open cwindow when linting
 
 754 let g:pymode_syntax_space_errors = 0    " don't bother me when I'm typing
 
 757 " disable '[ mappings
 
 759 let g:SignatureMap = {
 
 760   \ 'GotoNextLineAlpha'  :  "",
 
 761   \ 'GotoPrevLineAlpha'  :  "",
 
 762   \ 'GotoNextSpotAlpha'  :  "",
 
 763   \ 'GotoPrevSpotAlpha'  :  "",
 
 767 let g:switch_mapping = "<Leader>s"
 
 768 let g:switch_custom_definitions = [
 
 773 nmap <silent> z] <Plug>(SpellRotateForward)
 
 774 nmap <silent> z[ <Plug>(SpellRotateBackward)
 
 775 vmap <silent> z] <Plug>(SpellRotateForwardV)
 
 776 vmap <silent> z[ <Plug>(SpellRotateBackwardV)
 
 779 let g:syntastic_enable_highlighting = 0
 
 780 let g:syntastic_error_symbol='E'
 
 781 let g:syntastic_style_error_symbol='S'
 
 782 let g:syntastic_warning_symbol='W'
 
 783 let g:syntastic_style_warning_symbol='S'
 
 784 let g:syntastic_always_populate_loc_list=1
 
 785 nmap <silent> <leader>y :SyntasticCheck<cr>
 
 787 let g:syntastic_cpp_clang_tidy_post_args = "-p build*"
 
 790   let g:syntastic_check_on_open=1
 
 794 map <F5> :TagbarToggle<cr>
 
 795 let g:tagbar_sort = 0
 
 796 let g:tagbar_compact = 1
 
 797 let g:tagbar_autoshowtag = 1
 
 798 let g:tagbar_width = 25
 
 799 let g:tagbar_iconchars = ['+', '-']
 
 802 let g:tcomment_textobject_inlinecomment = 'gic'
 
 803 let g:tcomment#filetype#guess = 0
 
 804 "let g:tcomment#options = {'whitespace' : 'no'}
 
 807 call unite#filters#matcher_default#use(['matcher_fuzzy'])
 
 808 call unite#custom#profile('default', 'context', {
 
 810             \ 'direction': 'botright'
 
 813 nnoremap [unite] <Nop>
 
 814 nmap <leader>u [unite]
 
 815 nnoremap [unite]u :UniteResume<CR>
 
 816 nnoremap <silent> [u :UnitePrevious<CR>
 
 817 nnoremap <silent> ]u :UniteNext<CR>
 
 820 " seems not respected
 
 821 let g:unite_source_grep_max_candidates = 2000
 
 823     " Use ag in unite grep source.
 
 824     let g:unite_source_grep_command = 'ag'
 
 825     let g:unite_source_grep_default_opts = '--smart-case --vimgrep --ignore ''.hg'' --ignore ''.svn'' --ignore ''.git'' --ignore ''.bzr'''
 
 826     let g:unite_source_grep_recursive_opt = ''
 
 828 nnoremap <silent> [unite]a :<C-u>Unite grep:.::
\12\17<CR>
 
 829 nnoremap <silent> [unite]A :<C-u>Unite grep:.:-w:
\12\17<CR>
 
 830 command! -nargs=+ Ag Unite grep:.::<args>
 
 832 " unite-file_rec {{{3
 
 834     " Use ag in unite rec source
 
 835     let g:unite_source_rec_async_command = ['ag', '--follow', '--nocolor', '--nogroup', '-g', '']
 
 837 nnoremap <silent> [unite]f :<C-u>Unite -start-insert file_rec/async<CR>
 
 838 call unite#custom#source('file_rec/async', 'sorters', 'sorter_selecta')
 
 841 call unite#custom#default_action('buffer', 'open')
 
 842 nnoremap <silent> [unite]b :<C-u>Unite buffer:-<CR>
 
 844 " unite-jumplist {{{3
 
 845 nnoremap <silent> [unite]j :<C-u>Unite output:jumps:<CR>
 
 848 let g:unite_source_menu_menus = {}
 
 849 let g:unite_source_menu_menus.fugitive = { 'description' : 'fugitive menu'}
 
 850 let g:unite_source_menu_menus.fugitive.command_candidates = {
 
 851             \ 'Gstatus <Leader>gs' : 'Gstatus',
 
 852             \ 'Gcommit -v <Leader>gc' : 'Gcommit -v',
 
 856 nnoremap <silent> <leader>gg :<C-u>Unite menu:fugitive<CR>
 
 858 let g:unite_source_history_yank_enable = 1
 
 859 nnoremap <silent> [unite]p :<C-u>Unite history/yank<CR>
 
 862 nnoremap <silent> <leader>p :YRShow<cr>
 
 863 let g:yankring_history_dir = expand('$XDG_CACHE_HOME/vim')
 
 864 let g:yankring_replace_n_pkey = ''
 
 865 let g:yankring_replace_n_nkey = ''
 
 867 " map Y to y$ for the yank ring
 
 868 function! YRRunAfterMaps()
 
 869     nnoremap Y   :<C-U>YRYankCount 'y$'<CR>
 
 872 " vim-easy-align {{{2
 
 873 " start interactive EasyAlign in visual mode
 
 874 vmap <Enter>   <Esc>:echohl WarningMsg \| echo "EasyAlign mapped to 
\16<leader>a now" \| echohl None<CR>
 
 875 vmap <leader>a <Plug>(EasyAlign)
 
 876 nmap <leader>a <Plug>(EasyAlign)
 
 879 let g:gtest#highlight_failing_tests = 0
 
 881 nnoremap <silent> <Leader>tt :GTestRun<CR>
 
 882 nnoremap          <Leader>tc :GTestCase<space>
 
 883 nnoremap          <Leader>tn :GTestName<space>
 
 884 nnoremap <silent> <Leader>ta :GTestCase *<CR>:GTestName *<CR>:GTestRun<CR>
 
 885 nnoremap <silent> <Leader>tu :GTestRunUnderCursor<CR>
 
 888 let g:vim_json_syntax_conceal = 0
 
 891 let g:sneak#streak = 1
 
 892 let g:sneak#target_labels = "aoeuisnthdpylrcgfqjkxzmwvz" " dvorak
 
 893 let g:sneak#use_ic_scs = 1  " follow 'ignorecase' and 'smartcase'
 
 911 " Convenient command to see the difference between the current buffer and the
 
 912 " file it was loaded from, thus the changes you made.
 
 913 " Only define it when not defined already.
 
 914 if !exists(":DiffOrig")
 
 915   command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
 
 916                   \ | wincmd p | diffthis
 
 920 function! SortLinesOpFunc(...)
 
 923 nnoremap <silent> gs :<C-U>set operatorfunc=SortLinesOpFunc<CR>g@
 
 924 vnoremap <silent> gs :sort<cr>
 
 927 function! EditConfig(what, ext = '.vim')
 
 928     let l:dir = split(&runtimepath,',')[0]
 
 930         let l:file = expand($MYVIMRC)
 
 931     elseif ! isdirectory(globpath(l:dir, a:what))
 
 932         echoe a:what." is not valid!"
 
 933     elseif empty(&filetype)
 
 934         echoe 'filetype is empty!'
 
 936         let l:file = l:dir.'/'.a:what.'/'.&filetype.a:ext
 
 939     execute ':vsplit '.file
 
 942 nmap <leader>ev :call EditConfig('vimrc')<CR>
 
 943 nmap <leader>ef :call EditConfig('ftplugin')<CR>
 
 944 nmap <leader>es :call EditConfig('syntax')<CR>
 
 945 nmap <leader>ei :call EditConfig('indent')<CR>
 
 946 nmap <leader>eu :call EditConfig('ultisnips', '.snippets')<CR>
 
 949 " http://tex.stackexchange.com/a/52932
 
 950 let g:myLangList=["en_gb","en_us","de","fr"]
 
 952 function! ToggleSpell()
 
 953   if !exists("b:myLang")
 
 956   execute "setlocal spell!"
 
 958     echo "setlocal spelllang=" g:myLangList[b:myLang]
 
 962 function! SwitchSpell()
 
 963   if !exists("b:myLang")
 
 967     let b:myLang=b:myLang+1
 
 968     if b:myLang>=len(g:myLangList) | let b:myLang=0 | endif
 
 970   execute "setlocal spell spelllang=".get(g:myLangList, b:myLang)
 
 971   echo "setlocal spelllang=" g:myLangList[b:myLang]
 
 974 nnoremap <silent> coS :call SwitchSpell()<CR>
 
 975 " fix spelling with first choice
 
 976 nnoremap <Leader>f 1z=
 
 978 " gitdir or home {{{2
 
 980 " http://git.io/v3GAV
 
 981 function! FindGitDirOrHome()
 
 982   let filedir = expand('%:p:h')
 
 983   if isdirectory(filedir)
 
 984     let cmd = 'bash -c "(cd ' . filedir . '; git rev-parse --show-toplevel 2>/dev/null)"'
 
 985     let gitdir = system(cmd)
 
 986     if strlen(gitdir) == 0
 
 996 command! Cdr execute('cd ' . FindGitDirOrHome())
 
 998 command! LCdr execute('lcd ' . FindGitDirOrHome())
 
1000 " vim:set et sw=2 ts=2 tw=78: