2 if has('python3') | endif
5 set runtimepath ^=$XDG_CONFIG_HOME/vim
6 set runtimepath +=$XDG_CONFIG_HOME/vim/after
9 call plug#begin('$XDG_DATA_HOME/vim')
10 " This does not update vim-plug, use PlugUpgrade instead
11 Plug 'junegunn/vim-plug'
13 Plug 'airblade/vim-gitgutter' " {{{
14 " prefer other signs such as ycm diags
15 let g:gitgutter_sign_priority = 1
16 " don't clobber other signs
17 let g:gitgutter_sign_allow_clobber = 0
19 Plug 'alepez/vim-gtest'
21 Plug 'andrewradev/sideways.vim' " {{{2
22 nnoremap <silent> ,h :SidewaysLeft<CR>:delmarks z<CR>
23 nnoremap <silent> ,l :SidewaysRight<CR>:delmarks z<CR>
25 Plug 'andrewradev/switch.vim'
27 Plug 'bling/vim-airline' "{{{2
28 let g:airline#extensions#whitespace#enabled = 1
29 let g:airline#extensions#tabline#enabled = 1
30 let g:airline#extensions#searchcount#enabled = 0
31 let g:airline_powerline_fonts = 1
33 let g:asyncrun_status = "stopped"
34 " let g:airline_section_error = airline#section#create_right(['%{g:asyncrun_status}'])
38 Plug 'chrisbra/checkattach'
39 Plug 'derekwyatt/vim-fswitch'
41 Plug 'firef0x/pkgbuild.vim'
42 Plug 'junegunn/vim-easy-align'
43 Plug 'justinmk/vim-sneak'
44 Plug 'klen/python-mode'
45 Plug 'kshenoy/vim-signature'
46 Plug 'majutsushi/tagbar'
47 Plug 'octol/vim-cpp-enhanced-highlight'
48 Plug 'raimondi/delimitmate'
49 Plug 'sgeb/vim-diff-fold'
50 Plug 'skywind3000/asyncrun.vim' " {{{2
51 command! -bang -nargs=* -complete=file Make AsyncRun -save=2 -program=make @ <args>
52 let g:asyncrun_open = 10
54 Plug 'shougo/unite.vim'
55 Plug 'shougo/vimproc.vim', {'do': 'make'}
57 Plug 'thinca/vim-qfreplace'
58 Plug 'tomtom/tcomment_vim'
59 Plug 'tpope/vim-abolish'
60 Plug 'tpope/vim-characterize'
61 Plug 'tpope/vim-endwise'
62 Plug 'tpope/vim-eunuch'
63 Plug 'tpope/vim-fugitive'
64 Plug 'tpope/vim-repeat'
65 Plug 'tpope/vim-scriptease'
66 Plug 'tpope/vim-speeddating'
67 Plug 'tpope/vim-surround' "investigate vim-sandwich
68 Plug 'tpope/vim-unimpaired'
69 Plug 'tweekmonster/spellrotate.vim'
70 Plug 'valloric/youcompleteme', { 'do': './install.py --clangd-completer --clang-completer' }
71 Plug 'vim-scripts/mediawiki.vim'
72 Plug 'vim-scripts/replacewithregister'
73 Plug 'vim-scripts/yankring.vim'
77 Plug 'morhetz/gruvbox' " {{{2
78 let g:gruvbox_contrast_dark = 'hard'
79 let g:gruvbox_contrast_light = 'soft'
82 Plug 'arcticicestudio/nord-vim' " {{{2
85 let g:nord_italic_comments = 1
86 let g:nord_underline = 1
87 let g:nord_uniform_status_lines = 0
88 let g:nord_uniform_diff_background = 0
89 let g:nord_cursor_line_number_background = 0
90 let g:nord_bold_vertical_split_line = 0
96 Plug 'sirver/ultisnips'
97 Plug 'honza/vim-snippets'
100 Plug 'kana/vim-textobj-user'
101 Plug 'julian/vim-textobj-variable-segment'
102 Plug 'sgur/vim-textobj-parameter'
103 Plug 'kana/vim-operator-user'
106 " Check LucHermites plugins: https://github.com/LucHermitte/lh-cpp
107 Plug 'imsnif/kdl.vim'
109 Plug 'puremourning/vimspector'
110 Plug 'ilyachur/cmake4vim'
111 Plug 'ilyachur/gtest-vim'
113 Plug 'git@github.com:/ram-z/vim-orgmode', { 'branch': 'dev' } " {{{2
114 Plug 'vim-scripts/syntaxrange'
116 let g:org_agenda_files = ['~/org/*.org']
118 Plug 'neovimhaskell/haskell-vim' " {{{2
119 let g:haskell_enable_quantification = 1 " to enable highlighting of `forall`
120 let g:haskell_enable_recursivedo = 1 " to enable highlighting of `mdo` and `rec`
121 let g:haskell_enable_arrowsyntax = 1 " to enable highlighting of `proc`
122 let g:haskell_enable_pattern_synonyms = 1 " to enable highlighting of `pattern`
123 let g:haskell_enable_typeroles = 1 " to enable highlighting of type roles
124 let g:haskell_enable_static_pointers = 1 " to enable highlighting of `static`
125 let g:haskell_backpack = 1 " to enable highlighting of backpack keywords
127 let g:haskell_indent_before_where = 2
130 Plug 'aklt/plantuml-syntax'
132 Plug 'mtth/scratch.vim' " {{{2
133 let g:scratch_no_mappings = 1
134 let g:scratch_autohide = 0
137 let g:man_hardwrap = 80
139 Plug 'vim-utils/vim-man' " {{{2
144 Plug 'jenterkin/vim-autosource' " {{{2
145 let g:autosource_hashdir = $XDG_CACHE_HOME . '/vim/vim-autosource'
146 let g:autosource_conf_names = ['.vimrc', '.vimrc.lua']
150 filetype plugin indent on
155 let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
156 let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
161 "TODO see how I can integrate this into a theme that customises upstream Nord
162 hi debugPC term=reverse ctermbg=8
165 " moving around, searching and patterns {{{2
166 set incsearch " show match for partly typed search command
167 set ignorecase " ignore case when using a search pattern
168 set smartcase " override 'ignorecase' when pattern has upper case characters
169 set hlsearch " highlight all matches for the last used search pattern
171 set nostartofline " don't move the cursor to the first non-blank char of a line
174 set path+=../include/
175 set path+=/usr/include/c++/*
177 " displaying text {{{2
178 set nowrap " long lines wrap
179 set linebreak " wrap long lines at a character in 'breakat'
180 set showbreak=↪ " show these chars for wrapped lines
181 set breakindent " preserve indentation in wrapped text
183 set lazyredraw " don't redraw while executing macros
185 set list " show chars defined in 'listchars'
186 set listchars=tab:❭\ " list of strings used for list mode
187 set listchars+=extends:❯,precedes:❮
188 set listchars+=nbsp:␣
189 " Only shown when not in insert mode
190 set listchars+=trail:·
193 au FileType qf setlocal listchars-=trail:·
194 au InsertEnter * set listchars-=trail:·
195 au InsertLeave * set listchars+=trail:·
198 set scrolloff=5 " number of screen lines to show around the cursor
199 set sidescroll=1 " number of collumns to scroll
200 set sidescrolloff=1 " don't scroll over the listchars
201 set display+=lastline " display as much as possible of last line
203 set fillchars=diff:⣿,vert:│
205 set nonumber " show the line number for each line
206 set norelativenumber " show the relative line number for each line
208 " syntax, highlighting and spelling {{{2
209 set synmaxcol=800 " don't highlight long lines
211 set dictionary=spell " list of dictionary files for keyword completion
215 " multiple windows {{{2
216 set laststatus=2 " 0, 1 or 2; when to use a status line for the last window
218 set previewheight=20 " default height for the preview window
222 " set splitbelow " a new window is put below of the current one
223 set splitright " a new window is put right of the current one
228 " using the mouse {{{2
229 set mouse=rnv " list of flags for using the mouse
231 set ttymouse=xterm " type of mouse
234 " messages and info {{{2
235 set showcmd " Show (partial) command in status line.
236 set ruler " show the cursor position all the time
237 set confirm " Ask what to do when closing unsaved documents
238 set shortmess= " reset option
239 set shortmess+=a " all abbreviations
240 set shortmess+=o " overwrite file-written message
241 set shortmess+=O " file-read message overrides previous
242 set shortmess+=t " truncate file message at start
243 set shortmess+=T " truncate other messages in the middle
244 set shortmess+=W " don't give 'written' or '[w]' when writing a file
245 set shortmess+=A " ignore swapfile warning
246 set shortmess+=I " no splash screen
249 set backspace=indent,eol,start " allow backspacing over everything in insert mode
251 set showmatch " Show matching brackets.
253 set nojoinspaces " don't use two spaces after '.' when joining a line
254 set formatoptions+=j " Delete comment leader when joining lines
255 set formatoptions+=c " Autowrap comments using textwidth
256 set formatoptions+=r " Insert comment leader after hitting <Enter>
257 set formatoptions+=n " Recognize numbered lists
258 set formatoptions+=q " Allow formatting of comments with "gq".
259 set formatoptions+=l " do not wrap lines that have been longer when starting insert mode already
260 set formatoptions+=t " Auto-wrap text using textwidth
261 set formatoptions-=o " Do not insert comment leader after hitting o or O in normal mode
263 set nrformats-=octal " don't inc/dec octal numbers with ^[AX]
265 set complete=. " scan the current buffer ( 'wrapscan' is ignored)
266 set complete+=w " scan buffers from other windows
267 set complete+=b " scan other loaded buffers that are in the buffer list
268 set complete+=u " scan the unloaded buffers that are in the buffer list
269 set complete+=t " scan tags
270 set complete+=i " scan current and included files
271 set complete+=kspell " use the currently active spell checking |spell|
273 " whether to use a popup menu for Insert mode completion
274 set completeopt=longest,menuone,preview
276 " tabs and indent {{{2
277 set shiftwidth=4 " number of spaces used for each step of (auto)indent
278 set smarttab " a <Tab> in an indent inserts 'shiftwidth' spaces
279 set softtabstop=4 " if non-zero, number of spaces to insert for a <Tab>
280 set shiftround " round to 'shiftwidth' for "<<" and ">>"
281 set expandtab " expand <Tab> to spaces in Insert mode
284 set pastetoggle=<F11> " key sequence to toggle paste mode
287 set foldmethod=marker " folding type
288 set foldlevelstart=0 " value for 'foldlevel' when starting to edit a file
290 " open folds when jumping to line
293 set viewoptions=cursor " save cursor position
294 set viewoptions+=folds " save folds
297 set diffopt+=filler " show filler lines
298 set diffopt+=vertical " always vertical split
299 set diffopt+=context:10 " 10 lines context between changes
300 set diffopt+=internal
301 set diffopt+=algorithm:patience
303 " reading and writing files {{{2
304 set modeline " read modelines
305 set modelines=2 " only check first/last 2 lines
307 set writebackup " write a backup file before overwriting a file
308 set backup " keep a backup after owerwriting a file
309 set backupdir=$XDG_CACHE_HOME/vim/backup//
311 set backupskip+=.netrc " skip netrc
312 set backupskip+=/dev/shm/pass* " skip passwordstore files
314 set undofile " persistent undo history
316 set undodir=$XDG_CACHE_HOME/vim/undo//
321 au BufWritePre .netrc setlocal noundofile
322 au BufWritePre /dev/shm/pass* setlocal noundofile
323 au BufWritePre /tmp/* setlocal noundofile
326 set autowrite " automatically write a file when leaving a modified buffer
327 set autoread " automatically read a file that has been modified
331 set directory=$XDG_CACHE_HOME/vim/swap//
333 " command line editing {{{2
334 set history=5000 " how many command lines are remembered
335 set wildmenu " command-line completion shows a list of matches
336 set wildmode=longest:full,full " specifies how command line completion works
337 set wildignorecase " ignore case when completing file names
339 set wildignore+=.hg,.git,.svn " Version control
340 set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
341 set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
342 set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
343 set wildignore+=*.spl " compiled spelling word lists
344 set wildignore+=*.sw? " Vim swap files
345 set wildignore+=*.luac " Lua byte code
346 set wildignore+=*.pyc " Python byte code
347 set wildignore+=*.orig " Merge resolution files
349 " running make and jumping to errors {{{2
350 set makeprg=make\ -w " print changing directories
352 set grepprg=ag\ --vimgrep\ $*
354 " language specific {{{2
355 set isfname-== " don't treat `=` as being part of filenames
358 set virtualedit+=block " let cursor move past last char in <C-V> mode
359 set virtualedit+=onemore " allow the cursor to move just past the end of the line
361 " viminfo defaults but save file in .cache
362 set viminfo='100,<50,s10,h,n$XDG_CACHE_HOME/vim/viminfo
364 " shada is the replacement format for viminfo
365 " this setting is probably not needed as it's most likely the default
366 " the default path is in XDG_DATA_HOME, which is fine
367 set shada='100,<50,s10,h
370 set viewdir=$XDG_CACHE_HOME/vim/view//
372 set sessionoptions+=unix,slash " damn windows and it's silly ways
375 " Resize splits when the window is resized {{{2
378 autocmd VimResized * :wincmd =
381 " Only show cursorline in the current window and in normal mode {{{2
384 au WinLeave,InsertEnter * set nocursorline
385 au WinEnter,InsertLeave * set cursorline
388 " Treat buffers from stdin (e.g.: echo foo | vim -) as scratch {{{2
391 au StdinReadPost * :set buftype=nofile
394 " Jump to last known cursor position {{{2
397 " blacklist certain filetype
398 let blacklist = ['gitcommit']
399 autocmd BufReadPost *
400 \ if index(blacklist, &ft) < 0 && line("'\"") > 1 && line("'\"") <= line("$") |
401 \ exe "normal! g`\"" |
405 " Check for file modifications automatically {{{2
406 " (current buffer only)
407 " Use :NoAutoChecktime to disable it (uses b:autochecktime)
408 fun! MyAutoCheckTime()
409 " only check timestamp for normal files
410 if &buftype != '' | return | endif
411 if ! exists('b:autochecktime') || b:autochecktime
413 let b:autochecktime = 1
416 augroup MyAutoChecktime
418 au FocusGained,BufEnter,CursorHold,InsertEnter * call MyAutoCheckTime()
420 command! NoAutoChecktime let b:autochecktime=0
421 command! ToggleAutoChecktime let b:autochecktime=!get(b:, 'autochecktime', 0) | echom "b:autochecktime:" b:autochecktime
425 " allow both <space> and \ to be <leader>
429 function! MakeWithOpt()
430 " TODO only do this if makeprg matches make
431 " if &makeprg =~ "make"
433 if exists("b:make_dir")
434 let l:make_dir = "-C ".b:make_dir
435 elseif exists("t:make_dir")
436 let l:make_dir = "-C ".t:make_dir
437 elseif exists("g:make_dir")
438 let l:make_dir = "-C ".g:make_dir
441 let l:make_targets = ""
442 if exists("g:make_targets")
443 let l:make_targets = g:make_targets
445 execute "Make ".l:make_dir." ".l:make_targets
447 nnoremap <silent> <leader>r :call MakeWithOpt()<cr>
450 nnoremap <silent> <Leader>/ :silent nohl<CR>
453 nnoremap <leader>[ :tabprev<cr>
454 nnoremap <leader>] :tabnext<cr>
456 " paste from selection
457 nnoremap <leader>p* :silent! set paste<CR>"*p:set nopaste<CR>
458 " paste from clipboard
459 nnoremap <leader>p+ :silent! set paste<CR>"+p:set nopaste<CR>
461 " strip trailing whitespace
462 function! StripWhitespace(line1, line2, ...) " {{{2
463 let s_report = &report
465 let pattern = a:0 ? a:1 : '\s\+$'
466 let oldview = winsaveview()
467 exe 'keepjumps keeppatterns '.a:line1.','.a:line2.'substitute/'.pattern.'//e'
468 if oldview != winsaveview()
471 call winrestview(oldview)
472 let &report = s_report
474 command! -range=% -nargs=0 -bar Untrail keepjumps call StripWhitespace(<line1>,<line2>)
475 nnoremap <silent> <leader>ww :Untrail<CR>
478 vnoremap <leader>S y:execute @@<cr>:echo 'Sourced selection.'<cr>
479 nnoremap <leader>S ^vg_y:execute @@<cr>:echo 'Sourced line.'<cr>
481 " jump to last cursor position
484 " Select (charwise) the contents of the current line, excluding indentation.
489 \ :syntax sync fromstart<cr>
490 \ :AirlineRefresh<cr>
491 \ :call popup_clear(1)<cr>
495 " nnoremap <leader>r :silent !ranger %:h<cr>:redraw!<cr>
496 " nnoremap <leader>R :silent !ranger<cr>:redraw!<cr>
503 " display the number of matches for the last search
504 nmap <Leader># :%s:<C-R>/::gn<CR>
506 " center cursor after search and open folds
510 " same when jumping around
513 nnoremap <c-o> <c-o>zzzv
514 nnoremap <c-i> <c-i>zzzv
516 " Not using the default mappings of 'To line from top/bottom'
522 " Heresy, emacs insert bindings
523 inoremap <C-A> <Esc>I
524 inoremap <C-E> <Esc>A
525 cnoremap <C-A> <Home>
528 " proper movement when lines are wrapped
529 noremap <silent><expr> j (v:count == 0 ? 'gj' : 'j')
530 noremap <silent><expr> k (v:count == 0 ? 'gk' : 'k')
536 noremap <Right> <NOP>
538 inoremap <Down> <NOP>
539 inoremap <Left> <NOP>
540 inoremap <Right> <NOP>
542 cnoremap <Down> <NOP>
543 cnoremap <Left> <NOP>
544 cnoremap <Right> <NOP>
546 cnoremap <C-J> <Down>
547 cnoremap <C-H> <Left>
548 cnoremap <C-L> <Right>
550 " close all folds open fold in cursor
553 map <F1> :ls<CR>:b<space>
555 " move between windows (skip previewwindow)
556 nnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
557 nnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
558 tnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
559 tnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
561 "xterm mouse with middleclick paste
562 nnoremap <MiddleMouse> i<MiddleMouse>
563 vnoremap <MiddleMouse> s<MiddleMouse>
565 " fix legacy vi inconsistency
570 " allow repeat operator on visual
571 vnoremap . :normal .<CR>
573 " add line without changing position or leaving mode
574 noremap <silent> <Leader>o :set paste<CR>m`o<ESC>``:set nopaste<CR>
575 noremap <silent> <Leader>O :set paste<CR>m`O<ESC>``:set nopaste<CR>
577 " Don't use Ex mode, use Q for formatting
580 " break undo sequence before removing word
581 inoremap <C-W> <C-G>u<C-W>
583 nnoremap coe :set <C-R>=&expandtab ? 'noexpandtab' : 'expandtab'<CR><CR>
584 nnoremap [oe :set expandtab<CR>
585 nnoremap ]oe :set noexpandtab<CR>
587 for idt in range(1,8)
588 exe 'nnoremap co'.idt.' :setlocal tabstop='.idt.' shiftwidth='.idt.' softtabstop='.idt.'<CR>'
591 " toggle auto format of text
592 nnoremap coa :set <C-R>=&formatoptions =~ "a" ? 'formatoptions-=a' : 'formatoptions+=a'<CR><CR>
593 nnoremap [oa :set formatoptions+=a<CR>
594 nnoremap ]oa :set formatoptions-=a<CR>
596 " space will toggle current fold in normal mode
597 nnoremap <leader><Space> za
598 " create folds around visual selection
599 vnoremap <leader><Space> zf
602 cabbrev w!! SudoWrite
604 " uppercase previous word
605 inoremap <C-C> <Esc>gUiwgi
607 " http://git.io/v3ZeU
608 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>
610 " plugins options {{{1
612 let g:checkattach_filebrowser = 'ranger'
613 let g:checkattach_once = 'y'
615 " close-another-window {{{2
616 nnoremap <silent> <C-W>c <NOP>
617 nnoremap <silent> <C-W>cc <C-W>c
618 nnoremap <silent> <C-W>ch :CloseLeftWindow<CR>
619 nnoremap <silent> <C-W>cl :CloseRightWindow<CR>
620 nnoremap <silent> <C-W>cj :CloseBelowWindow<CR>
621 nnoremap <silent> <C-W>ck :CloseAboveWindow<CR>
624 let delimitMate_expand_cr = 2
625 let g:delimitMate_expand_space = 1
628 nnoremap <silent> <Leader>ff :FSHere<CR>
629 nnoremap <silent> <Leader>fl :FSRight<CR>
630 nnoremap <silent> <Leader>fh :FSLeft<CR>
631 nnoremap <silent> <Leader>fj :FSBelow<CR>
632 nnoremap <silent> <Leader>fk :FSAbove<CR>
633 nnoremap <silent> <Leader>fL :FSSplitRight<CR>
634 nnoremap <silent> <Leader>fH :FSSplitLeft<CR>
635 nnoremap <silent> <Leader>fJ :FSSplitBelow<CR>
636 nnoremap <silent> <Leader>fK :FSSplitAbove<CR>
639 nmap <silent> <leader>dd :tab split \| Gdiff \| wincmd h<CR>
640 " delete fugitive buffers when closed
641 autocmd BufReadPost fugitive://* set bufhidden=delete
643 function! GitToggle()
644 let l:status_buffer = bufname('^fugitive:///*/.git{/worktrees/*,}//$')
645 if buflisted(l:status_buffer)
646 execute 'bdelete '.l:status_buffer
652 command! GitToggle :call GitToggle()
653 command! GToggle GitToggle
654 nnoremap <silent> <leader>gs :GitToggle<CR>
656 nnoremap <silent> <leader>gd :Gdiffsplit<CR>
657 nnoremap <silent> <leader>gc :echohl WarningMsg \| echo "use \<leader>gcc instead" \| echohl None<CR>
658 nnoremap <silent> <leader>gcc :tab G commit -v<CR>
659 nnoremap <silent> <leader>gca :tab G commit -v --amend<CR>
660 nnoremap <leader>gcf :tab G commit -v --fixup=
661 nnoremap <silent> <leader>gp :echohl WarningMsg \| echo "use \<leader>gpp instead" \| echohl None<CR>
662 nnoremap <silent> <leader>gpp :Git push \| copen<CR>
663 nnoremap <silent> <leader>gpf :Git push --force-with-lease \| copen<CR>
664 nnoremap <silent> <leader>gll :Git pull<CR>
665 nnoremap <silent> <leader>gru :Git rebase --interactive @{upstream}<CR>
666 nnoremap <silent> <leader>grp :Git rebase --interactive @{push}<CR>
667 nnoremap <silent> <leader>ga :Gwrite<cr>
668 nnoremap <silent> <leader>gb :G blame<cr>
670 augroup fugitive_gstatus
672 autocmd User FugitiveIndex setlocal winfixheight
673 autocmd User FugitiveIndex nmap <buffer> <leader><space> =
677 nnoremap <F7> :GundoToggle<CR>
678 let g:gundo_prefer_python3 = 1
681 let g:indent_guides_default_mapping = 0
682 let g:indent_guides_guide_size = 1
683 nmap <silent> cog <Plug>IndentGuidesToggle
684 nmap <silent> [og <Plug>IndentGuidesEnable
685 nmap <silent> ]og <Plug>IndentGuidesDisable
689 let g:pymode_rope_completion = 0
690 let g:pymode_rope = 0
692 let g:pymode_folding = 1
693 let g:pymode_lint_ignore = "E221,E266,E501"
694 let g:pymode_lint_cwindow = 0 " don't open cwindow when linting
695 let g:pymode_syntax_space_errors = 0 " don't bother me when I'm typing
698 " disable '[ mappings
700 let g:SignatureMap = {
701 \ 'GotoNextLineAlpha' : "",
702 \ 'GotoPrevLineAlpha' : "",
703 \ 'GotoNextSpotAlpha' : "",
704 \ 'GotoPrevSpotAlpha' : "",
708 let g:switch_mapping = "<Leader>s"
709 let g:switch_custom_definitions = [
714 nmap <silent> z] <Plug>(SpellRotateForward)
715 nmap <silent> z[ <Plug>(SpellRotateBackward)
716 vmap <silent> z] <Plug>(SpellRotateForwardV)
717 vmap <silent> z[ <Plug>(SpellRotateBackwardV)
720 let g:syntastic_enable_highlighting = 0
721 let g:syntastic_error_symbol='E'
722 let g:syntastic_style_error_symbol='S'
723 let g:syntastic_warning_symbol='W'
724 let g:syntastic_style_warning_symbol='S'
725 let g:syntastic_always_populate_loc_list=1
726 nmap <silent> <leader>y :SyntasticCheck<cr>
728 let g:syntastic_cpp_clang_tidy_post_args = "-p build*"
731 let g:syntastic_check_on_open=1
735 map <F5> :TagbarToggle<cr>
736 let g:tagbar_sort = 0
737 let g:tagbar_compact = 1
738 let g:tagbar_autoshowtag = 1
739 let g:tagbar_width = 25
740 let g:tagbar_iconchars = ['+', '-']
743 let g:tcomment_textobject_inlinecomment = 'gic'
744 let g:tcomment#filetype#guess = 0
745 "let g:tcomment#options = {'whitespace' : 'no'}
748 let g:UltiSnipsEditSplit = 'vertical'
749 let g:UltiSnipsSnippetDirectories = [ expand("$XDG_CONFIG_HOME/vim/ultisnips") ]
751 let g:UltiSnipsSnippetDirectories = ["UltiSnips", "ultisnips"]
753 let g:UltiSnipsExpandTrigger = "<tab>"
754 let g:UltiSnipsJumpForwardTrigger = "<tab>"
755 let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
757 " UltiSnips completion function that tries to expand a snippet. If there's no
758 " snippet for expanding, it checks for completion window and if it's shown,
759 " selects first element. If there's no completion window it tries to jump to
760 " next placeholder. If there's no placeholder it just returns TAB key
761 " https://github.com/Valloric/YouCompleteMe/issues/36#issuecomment-15451411
762 function! g:UltiSnips_Complete()
763 call UltiSnips#ExpandSnippet()
764 if g:ulti_expand_res == 0
768 call UltiSnips#JumpForwards()
769 if g:ulti_jump_forwards_res == 0
776 au InsertEnter * exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=g:UltiSnips_Complete()<cr>"
777 let g:UltiSnipsListSnippets="<c-e>"
780 call unite#filters#matcher_default#use(['matcher_fuzzy'])
781 call unite#custom#profile('default', 'context', {
783 \ 'direction': 'botright'
786 nnoremap [unite] <Nop>
787 nmap <leader>u [unite]
788 nnoremap [unite]u :UniteResume<CR>
789 nnoremap <silent> [u :UnitePrevious<CR>
790 nnoremap <silent> ]u :UniteNext<CR>
793 " seems not respected
794 let g:unite_source_grep_max_candidates = 2000
796 " Use ag in unite grep source.
797 let g:unite_source_grep_command = 'ag'
798 let g:unite_source_grep_default_opts = '--smart-case --vimgrep --ignore ''.hg'' --ignore ''.svn'' --ignore ''.git'' --ignore ''.bzr'''
799 let g:unite_source_grep_recursive_opt = ''
801 nnoremap <silent> [unite]a :<C-u>Unite grep:.::
\12\17<CR>
802 nnoremap <silent> [unite]A :<C-u>Unite grep:.:-w:
\12\17<CR>
803 command! -nargs=+ Ag Unite grep:.::<args>
805 " unite-file_rec {{{3
807 " Use ag in unite rec source
808 let g:unite_source_rec_async_command = ['ag', '--follow', '--nocolor', '--nogroup', '-g', '']
810 nnoremap <silent> [unite]f :<C-u>Unite -start-insert file_rec/async<CR>
811 call unite#custom#source('file_rec/async', 'sorters', 'sorter_selecta')
814 call unite#custom#default_action('buffer', 'open')
815 nnoremap <silent> [unite]b :<C-u>Unite buffer:-<CR>
817 " unite-jumplist {{{3
818 nnoremap <silent> [unite]j :<C-u>Unite output:jumps:<CR>
821 let g:unite_source_menu_menus = {}
822 let g:unite_source_menu_menus.fugitive = { 'description' : 'fugitive menu'}
823 let g:unite_source_menu_menus.fugitive.command_candidates = {
824 \ 'Gstatus <Leader>gs' : 'Gstatus',
825 \ 'Gcommit -v <Leader>gc' : 'Gcommit -v',
829 nnoremap <silent> <leader>gg :<C-u>Unite menu:fugitive<CR>
831 let g:unite_source_history_yank_enable = 1
832 nnoremap <silent> [unite]p :<C-u>Unite history/yank<CR>
835 nnoremap <silent> <leader>p :YRShow<cr>
836 let g:yankring_history_dir = expand('$XDG_CACHE_HOME/vim')
837 let g:yankring_replace_n_pkey = ''
838 let g:yankring_replace_n_nkey = ''
840 " map Y to y$ for the yank ring
841 function! YRRunAfterMaps()
842 nnoremap Y :<C-U>YRYankCount 'y$'<CR>
846 let g:ycm_clangd_binary_path = 'clangd' " use clangd in path
847 let g:ycm_clangd_args = ['--clang-tidy']
848 let g:ycm_extra_conf_vim_data = ['getcwd()']
849 let g:ycm_add_preview_to_completeopt = 1
850 let g:ycm_complete_in_comments = 1
851 let g:ycm_complete_in_strings = 1
852 let g:ycm_autoclose_preview_window_after_insertion = 0
854 let g:ycm_language_server =
858 \ 'cmdline': [ 'haskell-language-server-wrapper', '--lsp' ],
859 \ 'filetypes': [ 'haskell', 'lhaskell' ]
863 " vim-easy-align {{{2
864 " start interactive EasyAlign in visual mode
865 vmap <Enter> <Esc>:echohl WarningMsg \| echo "EasyAlign mapped to
\16<leader>a now" \| echohl None<CR>
866 vmap <leader>a <Plug>(EasyAlign)
867 nmap <leader>a <Plug>(EasyAlign)
870 let g:gtest#highlight_failing_tests = 0
872 nnoremap <silent> <Leader>tt :GTestRun<CR>
873 nnoremap <Leader>tc :GTestCase<space>
874 nnoremap <Leader>tn :GTestName<space>
875 nnoremap <silent> <Leader>ta :GTestCase *<CR>:GTestName *<CR>:GTestRun<CR>
876 nnoremap <silent> <Leader>tu :GTestRunUnderCursor<CR>
879 let g:vim_json_syntax_conceal = 0
882 let g:sneak#streak = 1
883 let g:sneak#target_labels = "aoeuisnthdpylrcgfqjkxzmwvz" " dvorak
884 let g:sneak#use_ic_scs = 1 " follow 'ignorecase' and 'smartcase'
902 " Convenient command to see the difference between the current buffer and the
903 " file it was loaded from, thus the changes you made.
904 " Only define it when not defined already.
905 if !exists(":DiffOrig")
906 command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
907 \ | wincmd p | diffthis
911 function! SortLinesOpFunc(...)
914 nnoremap <silent> gs :<C-U>set operatorfunc=SortLinesOpFunc<CR>g@
915 vnoremap <silent> gs :sort<cr>
918 function! EditConfig(what, ext = '.vim')
919 let l:dir = split(&runtimepath,',')[0]
921 let l:file = expand($MYVIMRC)
922 elseif ! isdirectory(globpath(l:dir, a:what))
923 echoe a:what." is not valid!"
924 elseif empty(&filetype)
925 echoe 'filetype is empty!'
927 let l:file = l:dir.'/'.a:what.'/'.&filetype.a:ext
930 execute ':vsplit '.file
933 nmap <leader>ev :call EditConfig('vimrc')<CR>
934 nmap <leader>ef :call EditConfig('ftplugin')<CR>
935 nmap <leader>es :call EditConfig('syntax')<CR>
936 nmap <leader>ei :call EditConfig('indent')<CR>
937 nmap <leader>eu :call EditConfig('ultisnips', '.snippets')<CR>
940 " http://tex.stackexchange.com/a/52932
941 let g:myLangList=["en_gb","en_us","de","fr"]
943 function! ToggleSpell()
944 if !exists("b:myLang")
947 execute "setlocal spell!"
949 echo "setlocal spelllang=" g:myLangList[b:myLang]
953 function! SwitchSpell()
954 if !exists("b:myLang")
958 let b:myLang=b:myLang+1
959 if b:myLang>=len(g:myLangList) | let b:myLang=0 | endif
961 execute "setlocal spell spelllang=".get(g:myLangList, b:myLang)
962 echo "setlocal spelllang=" g:myLangList[b:myLang]
965 nnoremap <silent> coS :call SwitchSpell()<CR>
966 " fix spelling with first choice
967 nnoremap <Leader>f 1z=
969 " gitdir or home {{{2
971 " http://git.io/v3GAV
972 function! FindGitDirOrHome()
973 let filedir = expand('%:p:h')
974 if isdirectory(filedir)
975 let cmd = 'bash -c "(cd ' . filedir . '; git rev-parse --show-toplevel 2>/dev/null)"'
976 let gitdir = system(cmd)
977 if strlen(gitdir) == 0
987 command! Cdr execute('cd ' . FindGitDirOrHome())
989 command! LCdr execute('lcd ' . FindGitDirOrHome())
991 " vim:set et sw=2 ts=2 tw=78: