2 set runtimepath ^=$XDG_CONFIG_HOME/vim
3 set runtimepath +=$XDG_CONFIG_HOME/vim/after
6 if has('python3') | endif
9 " remove all autocommands
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'
73 Plug 'valloric/youcompleteme', { 'do': './install.py --clangd-completer --clang-completer' }
74 Plug 'vim-scripts/mediawiki.vim'
75 Plug 'vim-scripts/replacewithregister'
76 Plug 'vim-scripts/yankring.vim'
80 Plug 'morhetz/gruvbox' " {{{2
81 let g:gruvbox_contrast_dark = 'hard'
82 let g:gruvbox_contrast_light = 'soft'
85 Plug 'arcticicestudio/nord-vim' " {{{2
88 let g:nord_italic_comments = 1
89 let g:nord_underline = 1
90 let g:nord_uniform_status_lines = 0
91 let g:nord_uniform_diff_background = 0
92 let g:nord_cursor_line_number_background = 0
93 let g:nord_bold_vertical_split_line = 0
99 Plug 'sirver/ultisnips'
100 Plug 'honza/vim-snippets'
103 Plug 'kana/vim-textobj-user'
104 Plug 'julian/vim-textobj-variable-segment'
105 Plug 'sgur/vim-textobj-parameter'
106 Plug 'kana/vim-operator-user'
109 " Check LucHermites plugins: https://github.com/LucHermitte/lh-cpp
111 Plug 'git@github.com:/ram-z/vim-orgmode', { 'branch': 'dev' } " {{{2
112 Plug 'vim-scripts/syntaxrange'
114 let g:org_agenda_files = ['~/org/*.org']
116 Plug 'neovimhaskell/haskell-vim' " {{{2
117 let g:haskell_enable_quantification = 1 " to enable highlighting of `forall`
118 let g:haskell_enable_recursivedo = 1 " to enable highlighting of `mdo` and `rec`
119 let g:haskell_enable_arrowsyntax = 1 " to enable highlighting of `proc`
120 let g:haskell_enable_pattern_synonyms = 1 " to enable highlighting of `pattern`
121 let g:haskell_enable_typeroles = 1 " to enable highlighting of type roles
122 let g:haskell_enable_static_pointers = 1 " to enable highlighting of `static`
123 let g:haskell_backpack = 1 " to enable highlighting of backpack keywords
125 let g:haskell_indent_before_where = 2
128 Plug 'aklt/plantuml-syntax'
130 Plug 'mtth/scratch.vim' " {{{2
131 let g:scratch_no_mappings = 1
132 let g:scratch_autohide = 0
135 let g:man_hardwrap = 80
137 Plug 'vim-utils/vim-man' " {{{2
142 Plug 'jenterkin/vim-autosource' " {{{2
143 let g:autosource_hashdir = $XDG_CACHE_HOME . '/vim/vim-autosource'
144 let g:autosource_conf_names = ['.vimrc', '.vimrc.lua']
148 filetype plugin indent on
153 let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
154 let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
159 "TODO see how I can integrate this into a theme that customises upstream Nord
160 hi debugPC term=reverse ctermbg=8
163 " moving around, searching and patterns {{{2
164 set incsearch " show match for partly typed search command
165 set ignorecase " ignore case when using a search pattern
166 set smartcase " override 'ignorecase' when pattern has upper case characters
167 set hlsearch " highlight all matches for the last used search pattern
169 set nostartofline " don't move the cursor to the first non-blank char of a line
172 set path+=../include/
173 set path+=/usr/include/c++/*
175 " displaying text {{{2
176 set nowrap " long lines wrap
177 set linebreak " wrap long lines at a character in 'breakat'
178 set showbreak=↪ " show these chars for wrapped lines
179 set breakindent " preserve indentation in wrapped text
181 set lazyredraw " don't redraw while executing macros
183 set list " show chars defined in 'listchars'
184 set listchars=tab:❭\ " list of strings used for list mode
185 set listchars+=extends:❯,precedes:❮
186 set listchars+=nbsp:␣
187 " Only shown when not in insert mode
188 set listchars+=trail:·
191 au FileType qf setlocal listchars-=trail:·
192 au InsertEnter * set listchars-=trail:·
193 au InsertLeave * set listchars+=trail:·
196 set scrolloff=5 " number of screen lines to show around the cursor
197 set sidescroll=1 " number of collumns to scroll
198 set sidescrolloff=1 " don't scroll over the listchars
199 set display+=lastline " display as much as possible of last line
201 set fillchars=diff:⣿,vert:│
203 set nonumber " show the line number for each line
204 set norelativenumber " show the relative line number for each line
206 " syntax, highlighting and spelling {{{2
207 set synmaxcol=800 " don't highlight long lines
209 set dictionary=spell " list of dictionary files for keyword completion
213 " multiple windows {{{2
214 set laststatus=2 " 0, 1 or 2; when to use a status line for the last window
216 set previewheight=20 " default height for the preview window
220 " set splitbelow " a new window is put below of the current one
221 set splitright " a new window is put right of the current one
226 " using the mouse {{{2
227 set mouse=rnv " list of flags for using the mouse
229 set ttymouse=xterm " type of mouse
232 " messages and info {{{2
233 set showcmd " Show (partial) command in status line.
234 set ruler " show the cursor position all the time
235 set confirm " Ask what to do when closing unsaved documents
236 set shortmess= " reset option
237 set shortmess+=a " all abbreviations
238 set shortmess+=o " overwrite file-written message
239 set shortmess+=O " file-read message overrides previous
240 set shortmess+=t " truncate file message at start
241 set shortmess+=T " truncate other messages in the middle
242 set shortmess+=W " don't give 'written' or '[w]' when writing a file
243 set shortmess+=A " ignore swapfile warning
244 set shortmess+=I " no splash screen
247 set backspace=indent,eol,start " allow backspacing over everything in insert mode
249 set showmatch " Show matching brackets.
251 set nojoinspaces " don't use two spaces after '.' when joining a line
252 set formatoptions+=j " Delete comment leader when joining lines
253 set formatoptions+=c " Autowrap comments using textwidth
254 set formatoptions+=r " Insert comment leader after hitting <Enter>
255 set formatoptions+=n " Recognize numbered lists
256 set formatoptions+=q " Allow formatting of comments with "gq".
257 set formatoptions+=l " do not wrap lines that have been longer when starting insert mode already
258 set formatoptions+=t " Auto-wrap text using textwidth
259 set formatoptions-=o " Do not insert comment leader after hitting o or O in normal mode
261 set nrformats-=octal " don't inc/dec octal numbers with ^[AX]
263 set complete=. " scan the current buffer ( 'wrapscan' is ignored)
264 set complete+=w " scan buffers from other windows
265 set complete+=b " scan other loaded buffers that are in the buffer list
266 set complete+=u " scan the unloaded buffers that are in the buffer list
267 set complete+=t " scan tags
268 set complete+=i " scan current and included files
269 set complete+=kspell " use the currently active spell checking |spell|
271 " whether to use a popup menu for Insert mode completion
272 set completeopt=longest,menuone,preview
274 " tabs and indent {{{2
275 set shiftwidth=4 " number of spaces used for each step of (auto)indent
276 set smarttab " a <Tab> in an indent inserts 'shiftwidth' spaces
277 set softtabstop=4 " if non-zero, number of spaces to insert for a <Tab>
278 set shiftround " round to 'shiftwidth' for "<<" and ">>"
279 set expandtab " expand <Tab> to spaces in Insert mode
282 set pastetoggle=<F11> " key sequence to toggle paste mode
285 set foldmethod=marker " folding type
286 set foldlevelstart=0 " value for 'foldlevel' when starting to edit a file
288 " open folds when jumping to line
291 set viewoptions=cursor " save cursor position
292 set viewoptions+=folds " save folds
295 set diffopt+=filler " show filler lines
296 set diffopt+=vertical " always vertical split
297 set diffopt+=context:10 " 10 lines context between changes
298 set diffopt+=internal
299 set diffopt+=algorithm:patience
301 " reading and writing files {{{2
302 set modeline " read modelines
303 set modelines=2 " only check first/last 2 lines
305 set writebackup " write a backup file before overwriting a file
306 set backup " keep a backup after owerwriting a file
307 set backupdir=$XDG_CACHE_HOME/vim/backup//
309 set backupskip+=.netrc " skip netrc
310 set backupskip+=/dev/shm/pass* " skip passwordstore files
312 set undofile " persistent undo history
314 set undodir=$XDG_CACHE_HOME/vim/undo//
319 au BufWritePre .netrc setlocal noundofile
320 au BufWritePre /dev/shm/pass* setlocal noundofile
321 au BufWritePre /tmp/* setlocal noundofile
324 set autowrite " automatically write a file when leaving a modified buffer
325 set autoread " automatically read a file that has been modified
329 set directory=$XDG_CACHE_HOME/vim/swap//
331 " command line editing {{{2
332 set history=5000 " how many command lines are remembered
333 set wildmenu " command-line completion shows a list of matches
334 set wildmode=longest:full,full " specifies how command line completion works
335 set wildignorecase " ignore case when completing file names
337 set wildignore+=.hg,.git,.svn " Version control
338 set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
339 set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
340 set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
341 set wildignore+=*.spl " compiled spelling word lists
342 set wildignore+=*.sw? " Vim swap files
343 set wildignore+=*.luac " Lua byte code
344 set wildignore+=*.pyc " Python byte code
345 set wildignore+=*.orig " Merge resolution files
347 " running make and jumping to errors {{{2
348 set makeprg=make\ -w " print changing directories
350 set grepprg=ag\ --vimgrep\ $*
352 " language specific {{{2
353 set isfname-== " don't treat `=` as being part of filenames
356 set virtualedit+=block " let cursor move past last char in <C-V> mode
357 set virtualedit+=onemore " allow the cursor to move just past the end of the line
359 " viminfo defaults but save file in .cache
360 set viminfo='100,<50,s10,h,n$XDG_CACHE_HOME/vim/viminfo
362 " shada is the replacement format for viminfo
363 " this setting is probably not needed as it's most likely the default
364 " the default path is in XDG_DATA_HOME, which is fine
365 set shada='100,<50,s10,h
368 set viewdir=$XDG_CACHE_HOME/vim/view//
370 set sessionoptions+=unix,slash " damn windows and it's silly ways
373 " Resize splits when the window is resized {{{2
376 autocmd VimResized * :wincmd =
379 " Only show cursorline in the current window and in normal mode {{{2
382 au WinLeave,InsertEnter * set nocursorline
383 au WinEnter,InsertLeave * set cursorline
386 " Treat buffers from stdin (e.g.: echo foo | vim -) as scratch {{{2
389 au StdinReadPost * :set buftype=nofile
392 " Jump to last known cursor position {{{2
395 " blacklist certain filetype
396 let blacklist = ['gitcommit']
397 autocmd BufReadPost *
398 \ if index(blacklist, &ft) < 0 && line("'\"") > 1 && line("'\"") <= line("$") |
399 \ exe "normal! g`\"" |
403 " Check for file modifications automatically {{{2
404 " (current buffer only)
405 " Use :NoAutoChecktime to disable it (uses b:autochecktime)
406 fun! MyAutoCheckTime()
407 " only check timestamp for normal files
408 if &buftype != '' | return | endif
409 if ! exists('b:autochecktime') || b:autochecktime
411 let b:autochecktime = 1
414 augroup MyAutoChecktime
416 au FocusGained,BufEnter,CursorHold,InsertEnter * call MyAutoCheckTime()
418 command! NoAutoChecktime let b:autochecktime=0
419 command! ToggleAutoChecktime let b:autochecktime=!get(b:, 'autochecktime', 0) | echom "b:autochecktime:" b:autochecktime
423 au TerminalOpen * if &buftype == 'terminal' | setlocal bufhidden=hide | endif
428 " allow both <space> and \ to be <leader>
432 function! MakeWithOpt()
433 " TODO only do this if makeprg matches make
434 " if &makeprg =~ "make"
436 if exists("b:make_dir")
437 let l:make_dir = "-C ".b:make_dir
438 elseif exists("t:make_dir")
439 let l:make_dir = "-C ".t:make_dir
440 elseif exists("g:make_dir")
441 let l:make_dir = "-C ".g:make_dir
444 let l:make_targets = ""
445 if exists("g:make_targets")
446 let l:make_targets = g:make_targets
448 execute "Make ".l:make_dir." ".l:make_targets
450 nnoremap <silent> <leader>r :call MakeWithOpt()<cr>
453 nnoremap <silent> <Leader>/ :silent nohl<CR>
456 nnoremap <leader>[ :tabprev<cr>
457 nnoremap <leader>] :tabnext<cr>
459 " paste from selection
460 nnoremap <leader>p* :silent! set paste<CR>"*p:set nopaste<CR>
461 " paste from clipboard
462 nnoremap <leader>p+ :silent! set paste<CR>"+p:set nopaste<CR>
464 " strip trailing whitespace
465 function! StripWhitespace(line1, line2, ...) " {{{2
466 let s_report = &report
468 let pattern = a:0 ? a:1 : '\s\+$'
469 let oldview = winsaveview()
470 exe 'keepjumps keeppatterns '.a:line1.','.a:line2.'substitute/'.pattern.'//e'
471 if oldview != winsaveview()
474 call winrestview(oldview)
475 let &report = s_report
477 command! -range=% -nargs=0 -bar Untrail keepjumps call StripWhitespace(<line1>,<line2>)
478 nnoremap <silent> <leader>ww :Untrail<CR>
481 vnoremap <leader>S y:execute @@<cr>:echo 'Sourced selection.'<cr>
482 nnoremap <leader>S ^vg_y:execute @@<cr>:echo 'Sourced line.'<cr>
484 " jump to last cursor position
487 " Select (charwise) the contents of the current line, excluding indentation.
492 \ :syntax sync fromstart<cr>
493 \ :AirlineRefresh<cr>
494 \ :call popup_clear(1)<cr>
498 " nnoremap <leader>r :silent !ranger %:h<cr>:redraw!<cr>
499 " nnoremap <leader>R :silent !ranger<cr>:redraw!<cr>
506 " display the number of matches for the last search
507 nmap <Leader># :%s:<C-R>/::gn<CR>
509 " center cursor after search and open folds
513 " same when jumping around
516 nnoremap <c-o> <c-o>zzzv
517 nnoremap <c-i> <c-i>zzzv
519 " Not using the default mappings of 'To line from top/bottom'
525 " Heresy, emacs insert bindings
526 inoremap <C-A> <Esc>I
527 inoremap <C-E> <Esc>A
528 cnoremap <C-A> <Home>
531 " proper movement when lines are wrapped
532 noremap <silent><expr> j (v:count == 0 ? 'gj' : 'j')
533 noremap <silent><expr> k (v:count == 0 ? 'gk' : 'k')
539 noremap <Right> <NOP>
541 inoremap <Down> <NOP>
542 inoremap <Left> <NOP>
543 inoremap <Right> <NOP>
545 cnoremap <Down> <NOP>
546 cnoremap <Left> <NOP>
547 cnoremap <Right> <NOP>
549 cnoremap <C-J> <Down>
550 cnoremap <C-H> <Left>
551 cnoremap <C-L> <Right>
553 " close all folds open fold in cursor
556 map <F1> :ls<CR>:b<space>
558 " move between windows (skip previewwindow)
559 nnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
560 nnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
561 tnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
562 tnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
564 "xterm mouse with middleclick paste
565 nnoremap <MiddleMouse> i<MiddleMouse>
566 vnoremap <MiddleMouse> s<MiddleMouse>
568 " fix legacy vi inconsistency
573 " allow repeat operator on visual
574 vnoremap . :normal .<CR>
576 " add line without changing position or leaving mode
577 noremap <silent> <Leader>o :set paste<CR>m`o<ESC>``:set nopaste<CR>
578 noremap <silent> <Leader>O :set paste<CR>m`O<ESC>``:set nopaste<CR>
580 " Don't use Ex mode, use Q for formatting
583 " break undo sequence before removing word
584 inoremap <C-W> <C-G>u<C-W>
586 nnoremap coe :set <C-R>=&expandtab ? 'noexpandtab' : 'expandtab'<CR><CR>
587 nnoremap [oe :set expandtab<CR>
588 nnoremap ]oe :set noexpandtab<CR>
590 for idt in range(1,8)
591 exe 'nnoremap co'.idt.' :setlocal tabstop='.idt.' shiftwidth='.idt.' softtabstop='.idt.'<CR>'
594 " toggle auto format of text
595 nnoremap coa :set <C-R>=&formatoptions =~ "a" ? 'formatoptions-=a' : 'formatoptions+=a'<CR><CR>
596 nnoremap [oa :set formatoptions+=a<CR>
597 nnoremap ]oa :set formatoptions-=a<CR>
599 " space will toggle current fold in normal mode
600 nnoremap <leader><Space> za
601 " create folds around visual selection
602 vnoremap <leader><Space> zf
605 cabbrev w!! SudoWrite
607 " uppercase previous word
608 inoremap <C-C> <Esc>gUiwgi
610 " http://git.io/v3ZeU
611 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>
613 " plugins options {{{1
615 let g:checkattach_filebrowser = 'ranger'
616 let g:checkattach_once = 'y'
619 let delimitMate_expand_cr = 2
620 let g:delimitMate_expand_space = 1
623 nnoremap <silent> <Leader>ff :FSHere<CR>
624 nnoremap <silent> <Leader>fl :FSRight<CR>
625 nnoremap <silent> <Leader>fh :FSLeft<CR>
626 nnoremap <silent> <Leader>fj :FSBelow<CR>
627 nnoremap <silent> <Leader>fk :FSAbove<CR>
628 nnoremap <silent> <Leader>fL :FSSplitRight<CR>
629 nnoremap <silent> <Leader>fH :FSSplitLeft<CR>
630 nnoremap <silent> <Leader>fJ :FSSplitBelow<CR>
631 nnoremap <silent> <Leader>fK :FSSplitAbove<CR>
634 nmap <silent> <leader>dd :tab split \| Gdiff \| wincmd h<CR>
635 " delete fugitive buffers when closed
636 autocmd BufReadPost fugitive://* set bufhidden=delete
638 function! GitToggle()
639 let l:status_buffer = bufname('^fugitive:///*/.git{/worktrees/*,}//$')
640 if buflisted(l:status_buffer)
641 execute 'bdelete '.l:status_buffer
647 command! GitToggle :call GitToggle()
648 command! GToggle GitToggle
649 nnoremap <silent> <leader>gs :GitToggle<CR>
651 nnoremap <silent> <leader>gd :Gdiffsplit<CR>
652 nnoremap <silent> <leader>gc :echohl WarningMsg \| echo "use \<leader>gcc instead" \| echohl None<CR>
653 nnoremap <silent> <leader>gcc :tab G commit -v<CR>
654 nnoremap <silent> <leader>gca :tab G commit -v --amend<CR>
655 nnoremap <leader>gcf :tab G commit -v --fixup=
656 nnoremap <silent> <leader>gp :echohl WarningMsg \| echo "use \<leader>gpp instead" \| echohl None<CR>
657 nnoremap <silent> <leader>gpp :Git push \| copen<CR>
658 nnoremap <silent> <leader>gpf :Git push --force-with-lease \| copen<CR>
659 nnoremap <silent> <leader>gll :Git pull<CR>
660 nnoremap <silent> <leader>gru :Git rebase --interactive @{upstream}<CR>
661 nnoremap <silent> <leader>grp :Git rebase --interactive @{push}<CR>
662 nnoremap <silent> <leader>ga :Gwrite<cr>
663 nnoremap <silent> <leader>gb :G blame<cr>
665 augroup fugitive_gstatus
667 autocmd User FugitiveIndex setlocal winfixheight
668 autocmd User FugitiveIndex nmap <buffer> <leader><space> =
672 nnoremap <F7> :GundoToggle<CR>
673 let g:gundo_prefer_python3 = 1
676 let g:indent_guides_default_mapping = 0
677 let g:indent_guides_guide_size = 1
678 nmap <silent> cog <Plug>IndentGuidesToggle
679 nmap <silent> [og <Plug>IndentGuidesEnable
680 nmap <silent> ]og <Plug>IndentGuidesDisable
682 " close-another-window {{{2
683 nnoremap <silent> <C-W>c <NOP>
684 nnoremap <silent> <C-W>cc <C-W>c
685 nnoremap <silent> <C-W>ch :CloseLeftWindow<CR>
686 nnoremap <silent> <C-W>cl :CloseRightWindow<CR>
687 nnoremap <silent> <C-W>cj :CloseBelowWindow<CR>
688 nnoremap <silent> <C-W>ck :CloseAboveWindow<CR>
692 let g:pymode_rope_completion = 0
693 let g:pymode_rope = 0
695 let g:pymode_folding = 1
696 let g:pymode_lint_ignore = "E221,E266,E501"
697 let g:pymode_lint_cwindow = 0 " don't open cwindow when linting
698 let g:pymode_syntax_space_errors = 0 " don't bother me when I'm typing
701 " disable '[ mappings
703 let g:SignatureMap = {
704 \ 'GotoNextLineAlpha' : "",
705 \ 'GotoPrevLineAlpha' : "",
706 \ 'GotoNextSpotAlpha' : "",
707 \ 'GotoPrevSpotAlpha' : "",
711 let g:switch_mapping = "<Leader>s"
712 let g:switch_custom_definitions = [
717 nmap <silent> z] <Plug>(SpellRotateForward)
718 nmap <silent> z[ <Plug>(SpellRotateBackward)
719 vmap <silent> z] <Plug>(SpellRotateForwardV)
720 vmap <silent> z[ <Plug>(SpellRotateBackwardV)
723 let g:syntastic_enable_highlighting = 0
724 let g:syntastic_error_symbol='E'
725 let g:syntastic_style_error_symbol='S'
726 let g:syntastic_warning_symbol='W'
727 let g:syntastic_style_warning_symbol='S'
728 let g:syntastic_always_populate_loc_list=1
729 nmap <silent> <leader>y :SyntasticCheck<cr>
731 let g:syntastic_cpp_clang_tidy_post_args = "-p build*"
734 let g:syntastic_check_on_open=1
738 map <F5> :TagbarToggle<cr>
739 let g:tagbar_sort = 0
740 let g:tagbar_compact = 1
741 let g:tagbar_autoshowtag = 1
742 let g:tagbar_width = 25
743 let g:tagbar_iconchars = ['+', '-']
746 let g:tcomment_textobject_inlinecomment = 'gic'
747 let g:tcomment#filetype#guess = 0
748 "let g:tcomment#options = {'whitespace' : 'no'}
751 let g:UltiSnipsEditSplit = 'vertical'
752 let g:UltiSnipsSnippetDirectories = [ expand("$XDG_CONFIG_HOME/vim/ultisnips") ]
754 let g:UltiSnipsSnippetDirectories = ["UltiSnips", "ultisnips"]
756 let g:UltiSnipsExpandTrigger = "<tab>"
757 let g:UltiSnipsJumpForwardTrigger = "<tab>"
758 let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
760 " UltiSnips completion function that tries to expand a snippet. If there's no
761 " snippet for expanding, it checks for completion window and if it's shown,
762 " selects first element. If there's no completion window it tries to jump to
763 " next placeholder. If there's no placeholder it just returns TAB key
764 " https://github.com/Valloric/YouCompleteMe/issues/36#issuecomment-15451411
765 function! g:UltiSnips_Complete()
766 call UltiSnips#ExpandSnippet()
767 if g:ulti_expand_res == 0
771 call UltiSnips#JumpForwards()
772 if g:ulti_jump_forwards_res == 0
779 au InsertEnter * exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=g:UltiSnips_Complete()<cr>"
780 let g:UltiSnipsListSnippets="<c-e>"
783 call unite#filters#matcher_default#use(['matcher_fuzzy'])
784 call unite#custom#profile('default', 'context', {
786 \ 'direction': 'botright'
789 nnoremap [unite] <Nop>
790 nmap <leader>u [unite]
791 nnoremap [unite]u :UniteResume<CR>
792 nnoremap <silent> [u :UnitePrevious<CR>
793 nnoremap <silent> ]u :UniteNext<CR>
796 " seems not respected
797 let g:unite_source_grep_max_candidates = 2000
799 " Use ag in unite grep source.
800 let g:unite_source_grep_command = 'ag'
801 let g:unite_source_grep_default_opts = '--smart-case --vimgrep --ignore ''.hg'' --ignore ''.svn'' --ignore ''.git'' --ignore ''.bzr'''
802 let g:unite_source_grep_recursive_opt = ''
804 nnoremap <silent> [unite]a :<C-u>Unite grep:.::
\12\17<CR>
805 nnoremap <silent> [unite]A :<C-u>Unite grep:.:-w:
\12\17<CR>
806 command! -nargs=+ Ag Unite grep:.::<args>
808 " unite-file_rec {{{3
810 " Use ag in unite rec source
811 let g:unite_source_rec_async_command = ['ag', '--follow', '--nocolor', '--nogroup', '-g', '']
813 nnoremap <silent> [unite]f :<C-u>Unite -start-insert file_rec/async<CR>
814 call unite#custom#source('file_rec/async', 'sorters', 'sorter_selecta')
817 call unite#custom#default_action('buffer', 'open')
818 nnoremap <silent> [unite]b :<C-u>Unite buffer:-<CR>
820 " unite-jumplist {{{3
821 nnoremap <silent> [unite]j :<C-u>Unite output:jumps:<CR>
824 let g:unite_source_menu_menus = {}
825 let g:unite_source_menu_menus.fugitive = { 'description' : 'fugitive menu'}
826 let g:unite_source_menu_menus.fugitive.command_candidates = {
827 \ 'Gstatus <Leader>gs' : 'Gstatus',
828 \ 'Gcommit -v <Leader>gc' : 'Gcommit -v',
832 nnoremap <silent> <leader>gg :<C-u>Unite menu:fugitive<CR>
834 let g:unite_source_history_yank_enable = 1
835 nnoremap <silent> [unite]p :<C-u>Unite history/yank<CR>
838 nnoremap <silent> <leader>p :YRShow<cr>
839 let g:yankring_history_dir = expand('$XDG_CACHE_HOME/vim')
840 let g:yankring_replace_n_pkey = ''
841 let g:yankring_replace_n_nkey = ''
843 " map Y to y$ for the yank ring
844 function! YRRunAfterMaps()
845 nnoremap Y :<C-U>YRYankCount 'y$'<CR>
849 let g:ycm_clangd_binary_path = 'clangd' " use clangd in path
850 let g:ycm_clangd_args = ['--clang-tidy']
851 let g:ycm_extra_conf_vim_data = ['getcwd()']
852 let g:ycm_add_preview_to_completeopt = 1
853 let g:ycm_complete_in_comments = 1
854 let g:ycm_complete_in_strings = 1
855 let g:ycm_autoclose_preview_window_after_insertion = 0
857 let g:ycm_language_server =
861 \ 'cmdline': [ 'haskell-language-server-wrapper', '--lsp' ],
862 \ 'filetypes': [ 'haskell', 'lhaskell' ]
866 " vim-easy-align {{{2
867 " start interactive EasyAlign in visual mode
868 vmap <Enter> <Esc>:echohl WarningMsg \| echo "EasyAlign mapped to
\16<leader>a now" \| echohl None<CR>
869 vmap <leader>a <Plug>(EasyAlign)
870 nmap <leader>a <Plug>(EasyAlign)
873 let g:gtest#highlight_failing_tests = 0
875 nnoremap <silent> <Leader>tt :GTestRun<CR>
876 nnoremap <Leader>tc :GTestCase<space>
877 nnoremap <Leader>tn :GTestName<space>
878 nnoremap <silent> <Leader>ta :GTestCase *<CR>:GTestName *<CR>:GTestRun<CR>
879 nnoremap <silent> <Leader>tu :GTestRunUnderCursor<CR>
882 let g:vim_json_syntax_conceal = 0
885 let g:sneak#streak = 1
886 let g:sneak#target_labels = "aoeuisnthdpylrcgfqjkxzmwvz" " dvorak
887 let g:sneak#use_ic_scs = 1 " follow 'ignorecase' and 'smartcase'
905 " Convenient command to see the difference between the current buffer and the
906 " file it was loaded from, thus the changes you made.
907 " Only define it when not defined already.
908 if !exists(":DiffOrig")
909 command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
910 \ | wincmd p | diffthis
914 function! SortLinesOpFunc(...)
917 nnoremap <silent> gs :<C-U>set operatorfunc=SortLinesOpFunc<CR>g@
918 vnoremap <silent> gs :sort<cr>
921 function! EditConfig(what, ext = '.vim')
922 let l:dir = split(&runtimepath,',')[0]
924 let l:file = expand($MYVIMRC)
925 elseif ! isdirectory(globpath(l:dir, a:what))
926 echoe a:what." is not valid!"
927 elseif empty(&filetype)
928 echoe 'filetype is empty!'
930 let l:file = l:dir.'/'.a:what.'/'.&filetype.a:ext
933 execute ':vsplit '.file
936 nmap <leader>ev :call EditConfig('vimrc')<CR>
937 nmap <leader>ef :call EditConfig('ftplugin')<CR>
938 nmap <leader>es :call EditConfig('syntax')<CR>
939 nmap <leader>ei :call EditConfig('indent')<CR>
940 nmap <leader>eu :call EditConfig('ultisnips', '.snippets')<CR>
943 " http://tex.stackexchange.com/a/52932
944 let g:myLangList=["en_gb","en_us","de","fr"]
946 function! ToggleSpell()
947 if !exists("b:myLang")
950 execute "setlocal spell!"
952 echo "setlocal spelllang=" g:myLangList[b:myLang]
956 function! SwitchSpell()
957 if !exists("b:myLang")
961 let b:myLang=b:myLang+1
962 if b:myLang>=len(g:myLangList) | let b:myLang=0 | endif
964 execute "setlocal spell spelllang=".get(g:myLangList, b:myLang)
965 echo "setlocal spelllang=" g:myLangList[b:myLang]
968 nnoremap <silent> coS :call SwitchSpell()<CR>
969 " fix spelling with first choice
970 nnoremap <Leader>f 1z=
972 " gitdir or home {{{2
974 " http://git.io/v3GAV
975 function! FindGitDirOrHome()
976 let filedir = expand('%:p:h')
977 if isdirectory(filedir)
978 let cmd = 'bash -c "(cd ' . filedir . '; git rev-parse --show-toplevel 2>/dev/null)"'
979 let gitdir = system(cmd)
980 if strlen(gitdir) == 0
990 command! Cdr execute('cd ' . FindGitDirOrHome())
992 command! LCdr execute('lcd ' . FindGitDirOrHome())
994 " vim:set et sw=2 ts=2 tw=78: