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'
29 Plug 'bling/vim-airline'
30 Plug 'chrisbra/checkattach'
31 Plug 'derekwyatt/vim-fswitch'
33 Plug 'firef0x/pkgbuild.vim'
34 Plug 'junegunn/vim-easy-align'
35 Plug 'justinmk/vim-sneak'
36 Plug 'klen/python-mode'
37 Plug 'kshenoy/vim-signature'
38 Plug 'majutsushi/tagbar'
39 Plug 'octol/vim-cpp-enhanced-highlight'
40 Plug 'raimondi/delimitmate'
41 Plug 'sgeb/vim-diff-fold'
42 Plug 'skywind3000/asyncrun.vim' " {{{2
43 command! -bang -nargs=* -complete=file Make AsyncRun -save=2 -program=make @ <args>
44 let g:asyncrun_open = 10
46 Plug 'shougo/unite.vim'
47 Plug 'shougo/vimproc.vim', {'do': 'make'}
49 Plug 'thinca/vim-qfreplace'
50 Plug 'tomtom/tcomment_vim'
51 Plug 'tpope/vim-abolish'
52 Plug 'tpope/vim-endwise'
53 Plug 'tpope/vim-eunuch'
54 Plug 'tpope/vim-fugitive'
55 Plug 'tpope/vim-repeat'
56 Plug 'tpope/vim-scriptease'
57 Plug 'tpope/vim-speeddating'
58 Plug 'tpope/vim-surround' "investigate vim-sandwich
59 Plug 'tpope/vim-unimpaired'
60 Plug 'tweekmonster/spellrotate.vim'
61 Plug 'valloric/youcompleteme', { 'do': './install.py --clangd-completer --clang-completer' }
62 Plug 'vim-scripts/mediawiki.vim'
63 Plug 'vim-scripts/replacewithregister'
64 Plug 'vim-scripts/yankring.vim'
68 Plug 'morhetz/gruvbox' " {{{2
69 let g:gruvbox_contrast_dark = 'hard'
70 let g:gruvbox_contrast_light = 'soft'
72 Plug 'arcticicestudio/nord-vim' " {{{2
75 let g:nord_italic_comments = 1
76 let g:nord_underline = 1
77 let g:nord_uniform_status_lines = 0
78 let g:nord_uniform_diff_background = 0
79 let g:nord_cursor_line_number_background = 0
80 let g:nord_bold_vertical_split_line = 0
85 Plug 'sirver/ultisnips'
86 Plug 'honza/vim-snippets'
89 Plug 'kana/vim-textobj-user'
90 Plug 'julian/vim-textobj-variable-segment'
91 Plug 'sgur/vim-textobj-parameter'
92 Plug 'kana/vim-operator-user'
95 " Check LucHermites plugins: https://github.com/LucHermitte/lh-cpp
97 Plug 'git@github.com:/ram-z/vim-orgmode', { 'branch': 'dev' } " {{{2
98 Plug 'vim-scripts/syntaxrange'
100 let g:org_agenda_files = ['~/org/*.org']
102 Plug 'neovimhaskell/haskell-vim' " {{{2
103 let g:haskell_enable_quantification = 1 " to enable highlighting of `forall`
104 let g:haskell_enable_recursivedo = 1 " to enable highlighting of `mdo` and `rec`
105 let g:haskell_enable_arrowsyntax = 1 " to enable highlighting of `proc`
106 let g:haskell_enable_pattern_synonyms = 1 " to enable highlighting of `pattern`
107 let g:haskell_enable_typeroles = 1 " to enable highlighting of type roles
108 let g:haskell_enable_static_pointers = 1 " to enable highlighting of `static`
109 let g:haskell_backpack = 1 " to enable highlighting of backpack keywords
111 let g:haskell_indent_before_where = 2
114 Plug 'aklt/plantuml-syntax'
116 Plug 'mtth/scratch.vim' " {{{2
117 let g:scratch_no_mappings = 1
118 let g:scratch_autohide = 0
121 Plug 'vim-utils/vim-man' " {{{2
127 filetype plugin indent on
132 let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
133 let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
136 "TODO see how I can integrate this into a theme that customises upstream Nord
137 hi debugPC term=reverse ctermbg=8
140 " moving around, searching and patterns {{{2
141 set incsearch " show match for partly typed search command
142 set ignorecase " ignore case when using a search pattern
143 set smartcase " override 'ignorecase' when pattern has upper case characters
144 set hlsearch " highlight all matches for the last used search pattern
146 set nostartofline " don't move the cursor to the first non-blank char of a line
149 set path+=../include/
150 set path+=/usr/include/c++/*
152 " displaying text {{{2
153 set nowrap " long lines wrap
154 set linebreak " wrap long lines at a character in 'breakat'
155 set showbreak=↪ " show these chars for wrapped lines
156 set breakindent " preserve indentation in wrapped text
158 set lazyredraw " don't redraw while executing macros
160 set list " show chars defined in 'listchars'
161 set listchars=tab:❭\ " list of strings used for list mode
162 set listchars+=extends:❯,precedes:❮
163 " Only shown when not in insert mode
164 set listchars+=trail:·
167 au FileType qf setlocal listchars-=trail:·
168 au InsertEnter * set listchars-=trail:·
169 au InsertLeave * set listchars+=trail:·
172 set scrolloff=5 " number of screen lines to show around the cursor
173 set sidescroll=1 " number of collumns to scroll
174 set sidescrolloff=1 " don't scroll over the listchars
176 set fillchars=diff:⣿,vert:│
178 set nonumber " show the line number for each line
179 set norelativenumber " show the relative line number for each line
181 " syntax, highlighting and spelling {{{2
182 set synmaxcol=800 " don't highlight long lines
184 set dictionary=spell " list of dictionary files for keyword completion
188 " multiple windows {{{2
189 set laststatus=2 " 0, 1 or 2; when to use a status line for the last window
191 set previewheight=20 " default height for the preview window
195 " set splitbelow " a new window is put below of the current one
196 set splitright " a new window is put right of the current one
201 " using the mouse {{{2
202 set mouse=rnv " list of flags for using the mouse
203 set ttymouse=xterm " type of mouse
205 " messages and info {{{2
206 set showcmd " Show (partial) command in status line.
207 set ruler " show the cursor position all the time
208 set confirm " Ask what to do when closing unsaved documents
209 set shortmess= " reset option
210 set shortmess+=a " all abbreviations
211 set shortmess+=o " overwrite file-written message
212 set shortmess+=O " file-read message overrides previous
213 set shortmess+=t " truncate file message at start
214 set shortmess+=T " truncate other messages in the middle
215 set shortmess+=W " don't give 'written' or '[w]' when writing a file
216 set shortmess+=A " ignore swapfile warning
217 set shortmess+=I " no splash screen
220 set backspace=indent,eol,start " allow backspacing over everything in insert mode
222 set showmatch " Show matching brackets.
224 set nojoinspaces " don't use two spaces after '.' when joining a line
225 set formatoptions+=j " Delete comment leader when joining lines
226 set formatoptions+=c " Autowrap comments using textwidth
227 set formatoptions+=r " Insert comment leader after hitting <Enter>
228 set formatoptions+=n " Recognize numbered lists
229 set formatoptions+=q " Allow formatting of comments with "gq".
230 set formatoptions+=l " do not wrap lines that have been longer when starting insert mode already
231 set formatoptions+=t " Auto-wrap text using textwidth
232 set formatoptions-=o " Do not insert comment leader after hitting o or O in normal mode
234 set nrformats=hex " number formats recognized for CTRL-A and CTRL-X commands
236 set complete=. " scan the current buffer ( 'wrapscan' is ignored)
237 set complete+=w " scan buffers from other windows
238 set complete+=b " scan other loaded buffers that are in the buffer list
239 set complete+=u " scan the unloaded buffers that are in the buffer list
240 set complete+=t " scan tags
241 set complete+=i " scan current and included files
242 set complete+=kspell " use the currently active spell checking |spell|
244 " whether to use a popup menu for Insert mode completion
245 set completeopt=longest,menuone,preview
247 " tabs and indent {{{2
248 set shiftwidth=4 " number of spaces used for each step of (auto)indent
249 set smarttab " a <Tab> in an indent inserts 'shiftwidth' spaces
250 set softtabstop=4 " if non-zero, number of spaces to insert for a <Tab>
251 set shiftround " round to 'shiftwidth' for "<<" and ">>"
252 set expandtab " expand <Tab> to spaces in Insert mode
255 set pastetoggle=<F11> " key sequence to toggle paste mode
258 set foldmethod=marker " folding type
259 set foldlevelstart=0 " value for 'foldlevel' when starting to edit a file
261 " open folds when jumping to line
264 set viewoptions=cursor " save cursor position
265 set viewoptions+=folds " save folds
268 set diffopt+=filler " show filler lines
269 set diffopt+=vertical " always vertical split
270 set diffopt+=context:10 " 10 lines context between changes
271 set diffopt+=internal
272 set diffopt+=algorithm:patience
274 " reading and writing files {{{2
275 set modeline " read modelines
276 set modelines=2 " only check first/last 2 lines
278 set writebackup " write a backup file before overwriting a file
279 set backup " keep a backup after owerwriting a file
280 set backupdir=$XDG_CACHE_HOME/vim/backup//
282 set backupskip+=.netrc " skip netrc
283 set backupskip+=/dev/shm/pass* " skip passwordstore files
285 set undofile " persistent undo history
286 set undodir=$XDG_CACHE_HOME/vim/undo//
290 au BufWritePre .netrc setlocal noundofile
291 au BufWritePre /dev/shm/pass* setlocal noundofile
292 au BufWritePre /tmp/* setlocal noundofile
295 set autowrite " automatically write a file when leaving a modified buffer
296 set autoread " automatically read a file that has been modified
300 set directory=$XDG_CACHE_HOME/vim/swap//
302 " command line editing {{{2
303 set history=5000 " how many command lines are remembered
304 set wildmenu " command-line completion shows a list of matches
305 set wildmode=longest:full,full " specifies how command line completion works
306 set wildignorecase " ignore case when completing file names
308 set wildignore+=.hg,.git,.svn " Version control
309 set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
310 set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
311 set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
312 set wildignore+=*.spl " compiled spelling word lists
313 set wildignore+=*.sw? " Vim swap files
314 set wildignore+=*.luac " Lua byte code
315 set wildignore+=*.pyc " Python byte code
316 set wildignore+=*.orig " Merge resolution files
318 " running make and jumping to errors {{{2
319 set makeprg=make\ -w " print changing directories
321 set grepprg=ag\ --vimgrep\ $*
323 " language specific {{{2
324 set isfname-== " don't treat `=` as being part of filenames
327 set virtualedit+=block " let cursor move past last char in <C-V> mode
328 set virtualedit+=onemore " allow the cursor to move just past the end of the line
329 set viminfo='100,<50,s10,h,n$XDG_CACHE_HOME/vim/viminfo " viminfo defaults but save file in .cache
331 set viewdir=$XDG_CACHE_HOME/vim/view//
333 set sessionoptions+=unix,slash " damn windows and it's silly ways
336 " Resize splits when the window is resized {{{2
339 autocmd VimResized * :wincmd =
342 " Only show cursorline in the current window and in normal mode {{{2
345 au WinLeave,InsertEnter * set nocursorline
346 au WinEnter,InsertLeave * set cursorline
349 " Treat buffers from stdin (e.g.: echo foo | vim -) as scratch {{{2
352 au StdinReadPost * :set buftype=nofile
355 " Jump to last known cursor position {{{2
358 " blacklist certain filetype
359 let blacklist = ['gitcommit']
360 autocmd BufReadPost *
361 \ if index(blacklist, &ft) < 0 && line("'\"") > 1 && line("'\"") <= line("$") |
362 \ exe "normal! g`\"" |
366 " Check for file modifications automatically {{{2
367 " (current buffer only)
368 " Use :NoAutoChecktime to disable it (uses b:autochecktime)
369 fun! MyAutoCheckTime()
370 " only check timestamp for normal files
371 if &buftype != '' | return | endif
372 if ! exists('b:autochecktime') || b:autochecktime
374 let b:autochecktime = 1
377 augroup MyAutoChecktime
379 au FocusGained,BufEnter,CursorHold,InsertEnter * call MyAutoCheckTime()
381 command! NoAutoChecktime let b:autochecktime=0
382 command! ToggleAutoChecktime let b:autochecktime=!get(b:, 'autochecktime', 0) | echom "b:autochecktime:" b:autochecktime
386 au TerminalOpen * if &buftype == 'terminal' | setlocal bufhidden=hide | endif
391 " allow both <space> and \ to be <leader>
395 function! MakeWithOpt()
396 " TODO only do this if makeprg matches make
397 " if &makeprg =~ "make"
399 if exists("b:make_dir")
400 let l:make_dir = "-C ".b:make_dir
401 elseif exists("t:make_dir")
402 let l:make_dir = "-C ".t:make_dir
403 elseif exists("g:make_dir")
404 let l:make_dir = "-C ".g:make_dir
407 let l:make_targets = ""
408 if exists("g:make_targets")
409 let l:make_targets = g:make_targets
411 execute "Make ".l:make_dir." ".l:make_targets
413 nnoremap <silent> <leader>r :call MakeWithOpt()<cr>
416 nnoremap <silent> <Leader>/ :silent nohl<CR>
419 nnoremap <leader>[ :tabprev<cr>
420 nnoremap <leader>] :tabnext<cr>
422 " paste from selection
423 nnoremap <leader>p* :silent! set paste<CR>"*p:set nopaste<CR>
424 " paste from clipboard
425 nnoremap <leader>p+ :silent! set paste<CR>"+p:set nopaste<CR>
427 " strip trailing whitespace
428 function! StripWhitespace(line1, line2, ...) " {{{2
429 let s_report = &report
431 let pattern = a:0 ? a:1 : '\s\+$'
432 let oldview = winsaveview()
433 exe 'keepjumps keeppatterns '.a:line1.','.a:line2.'substitute/'.pattern.'//e'
434 if oldview != winsaveview()
437 call winrestview(oldview)
438 let &report = s_report
440 command! -range=% -nargs=0 -bar Untrail keepjumps call StripWhitespace(<line1>,<line2>)
441 nnoremap <silent> <leader>ww :Untrail<CR>
444 vnoremap <leader>S y:execute @@<cr>:echo 'Sourced selection.'<cr>
445 nnoremap <leader>S ^vg_y:execute @@<cr>:echo 'Sourced line.'<cr>
447 " jump to last cursor position
450 " Select (charwise) the contents of the current line, excluding indentation.
455 \ :syntax sync fromstart<cr>
456 \ :AirlineRefresh<cr>
457 \ :call popup_clear(1)<cr>
461 " nnoremap <leader>r :silent !ranger %:h<cr>:redraw!<cr>
462 " nnoremap <leader>R :silent !ranger<cr>:redraw!<cr>
469 " display the number of matches for the last search
470 nmap <Leader># :%s:<C-R>/::gn<CR>
472 " center cursor after search and open folds
476 " same when jumping around
479 nnoremap <c-o> <c-o>zzzv
480 nnoremap <c-i> <c-i>zzzv
482 " Not using the default mappings of 'To line from top/bottom'
488 " Heresy, emacs insert bindings
489 inoremap <C-A> <Esc>I
490 inoremap <C-E> <Esc>A
491 cnoremap <C-A> <Home>
494 " proper movement when lines are wrapped
495 noremap <silent><expr> j (v:count == 0 ? 'gj' : 'j')
496 noremap <silent><expr> k (v:count == 0 ? 'gk' : 'k')
502 noremap <Right> <NOP>
504 inoremap <Down> <NOP>
505 inoremap <Left> <NOP>
506 inoremap <Right> <NOP>
508 cnoremap <Down> <NOP>
509 cnoremap <Left> <NOP>
510 cnoremap <Right> <NOP>
512 cnoremap <C-J> <Down>
513 cnoremap <C-H> <Left>
514 cnoremap <C-L> <Right>
516 " close all folds open fold in cursor
519 map <F1> :ls<CR>:b<space>
521 " move between windows (skip previewwindow)
522 nnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
523 nnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
524 tnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
525 tnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
527 "xterm mouse with middleclick paste
528 nnoremap <MiddleMouse> i<MiddleMouse>
529 vnoremap <MiddleMouse> s<MiddleMouse>
531 " fix legacy vi inconsistency
536 " allow repeat operator on visual
537 vnoremap . :normal .<CR>
539 " add line without changing position or leaving mode
540 noremap <silent> <Leader>o :set paste<CR>m`o<ESC>``:set nopaste<CR>
541 noremap <silent> <Leader>O :set paste<CR>m`O<ESC>``:set nopaste<CR>
543 " Don't use Ex mode, use Q for formatting
546 " break undo sequence before removing word
547 inoremap <C-W> <C-G>u<C-W>
549 nnoremap coe :set <C-R>=&expandtab ? 'noexpandtab' : 'expandtab'<CR><CR>
550 nnoremap [oe :set expandtab<CR>
551 nnoremap ]oe :set noexpandtab<CR>
553 for idt in range(1,8)
554 exe 'nnoremap co'.idt.' :setlocal tabstop='.idt.' shiftwidth='.idt.' softtabstop='.idt.'<CR>'
557 " toggle auto format of text
558 nnoremap coa :set <C-R>=&formatoptions =~ "a" ? 'formatoptions-=a' : 'formatoptions+=a'<CR><CR>
559 nnoremap [oa :set formatoptions+=a<CR>
560 nnoremap ]oa :set formatoptions-=a<CR>
562 " space will toggle current fold in normal mode
563 nnoremap <leader><Space> za
564 " create folds around visual selection
565 vnoremap <leader><Space> zf
568 cabbrev w!! SudoWrite
570 " uppercase previous word
571 inoremap <C-C> <Esc>gUiwgi
573 " http://git.io/v3ZeU
574 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>
576 " plugins options {{{1
578 let g:airline#extensions#whitespace#enabled = 1
579 let g:airline#extensions#tabline#enabled = 1
580 let g:airline#extensions#searchcount#enabled = 0
581 let g:airline_powerline_fonts = 1
583 let g:asyncrun_status = "stopped"
584 let g:airline_section_error = airline#section#create_right(['%{g:asyncrun_status}'])
587 let g:checkattach_filebrowser = 'ranger'
588 let g:checkattach_once = 'y'
591 let delimitMate_expand_cr = 2
592 let g:delimitMate_expand_space = 1
595 nnoremap <silent> <Leader>ff :FSHere<CR>
596 nnoremap <silent> <Leader>fl :FSRight<CR>
597 nnoremap <silent> <Leader>fh :FSLeft<CR>
598 nnoremap <silent> <Leader>fj :FSBelow<CR>
599 nnoremap <silent> <Leader>fk :FSAbove<CR>
600 nnoremap <silent> <Leader>fL :FSSplitRight<CR>
601 nnoremap <silent> <Leader>fH :FSSplitLeft<CR>
602 nnoremap <silent> <Leader>fJ :FSSplitBelow<CR>
603 nnoremap <silent> <Leader>fK :FSSplitAbove<CR>
606 nmap <silent> <leader>dd :tab split \| Gdiff \| wincmd h<CR>
607 " delete fugitive buffers when closed
608 autocmd BufReadPost fugitive://* set bufhidden=delete
610 function! GitToggle()
611 if buflisted(bufname('.git/index'))
618 command! GitToggle :call GitToggle()
619 command! GToggle GitToggle
620 nnoremap <silent> <leader>gs :GitToggle<CR>
622 nnoremap <silent> <leader>gd :Gdiffsplit<CR>
623 nnoremap <silent> <leader>gc :echohl WarningMsg \| echo "use \<leader>gcc instead" \| echohl None<CR>
624 nnoremap <silent> <leader>gcc :tab G commit -v<CR>
625 nnoremap <silent> <leader>gca :tab G commit -v --amend<CR>
626 nnoremap <leader>gcf :tab G commit -v --fixup=
627 nnoremap <silent> <leader>gp :echohl WarningMsg \| echo "use \<leader>gpp instead" \| echohl None<CR>
628 nnoremap <silent> <leader>gpp :Git push \| copen<CR>
629 nnoremap <silent> <leader>gpf :Git push --force-with-lease \| copen<CR>
630 nnoremap <silent> <leader>gll :Git pull<CR>
631 nnoremap <silent> <leader>gru :Git rebase --interactive @{upstream}<CR>
632 nnoremap <silent> <leader>grp :Git rebase --interactive @{push}<CR>
633 nnoremap <silent> <leader>ga :Gwrite<cr>
634 nnoremap <silent> <leader>gb :G blame<cr>
636 augroup fugitive_gstatus
638 autocmd User FugitiveIndex setlocal winfixheight
639 autocmd User FugitiveIndex nmap <buffer> <leader><space> =
643 nnoremap <F7> :GundoToggle<CR>
644 let g:gundo_prefer_python3 = 1
647 let g:indent_guides_default_mapping = 0
648 let g:indent_guides_guide_size = 1
649 nmap <silent> cog <Plug>IndentGuidesToggle
650 nmap <silent> [og <Plug>IndentGuidesEnable
651 nmap <silent> ]og <Plug>IndentGuidesDisable
653 " close-another-window {{{2
654 nnoremap <silent> <C-W>c <NOP>
655 nnoremap <silent> <C-W>cc <C-W>c
656 nnoremap <silent> <C-W>ch :CloseLeftWindow<CR>
657 nnoremap <silent> <C-W>cl :CloseRightWindow<CR>
658 nnoremap <silent> <C-W>cj :CloseBelowWindow<CR>
659 nnoremap <silent> <C-W>ck :CloseAboveWindow<CR>
663 let g:pymode_rope_completion = 0
664 let g:pymode_rope = 0
666 let g:pymode_folding = 1
667 let g:pymode_lint_ignore = "E221,E266,E501"
668 let g:pymode_lint_cwindow = 0 " don't open cwindow when linting
669 let g:pymode_syntax_space_errors = 0 " don't bother me when I'm typing
672 " disable '[ mappings
674 let g:SignatureMap = {
675 \ 'GotoNextLineAlpha' : "",
676 \ 'GotoPrevLineAlpha' : "",
677 \ 'GotoNextSpotAlpha' : "",
678 \ 'GotoPrevSpotAlpha' : "",
682 let g:switch_mapping = "<Leader>s"
683 let g:switch_custom_definitions = [
688 nmap <silent> z] <Plug>(SpellRotateForward)
689 nmap <silent> z[ <Plug>(SpellRotateBackward)
690 vmap <silent> z] <Plug>(SpellRotateForwardV)
691 vmap <silent> z[ <Plug>(SpellRotateBackwardV)
694 let g:syntastic_enable_highlighting = 0
695 let g:syntastic_error_symbol='E'
696 let g:syntastic_style_error_symbol='S'
697 let g:syntastic_warning_symbol='W'
698 let g:syntastic_style_warning_symbol='S'
699 let g:syntastic_always_populate_loc_list=1
700 nmap <silent> <leader>y :SyntasticCheck<cr>
702 let g:syntastic_cpp_clang_tidy_post_args = "-p build*"
705 let g:syntastic_check_on_open=1
709 map <F5> :TagbarToggle<cr>
710 let g:tagbar_sort = 0
711 let g:tagbar_compact = 1
712 let g:tagbar_autoshowtag = 1
713 let g:tagbar_width = 25
714 let g:tagbar_iconchars = ['+', '-']
717 let g:tcomment_textobject_inlinecomment = 'gic'
718 let g:tcomment#filetype#guess = 0
719 "let g:tcomment#options = {'whitespace' : 'no'}
722 let g:UltiSnipsEditSplit = 'vertical'
723 let g:UltiSnipsSnippetDirectories = [ expand("$XDG_CONFIG_HOME/vim/ultisnips") ]
725 let g:UltiSnipsSnippetDirectories = ["UltiSnips", "ultisnips"]
727 let g:UltiSnipsExpandTrigger = "<tab>"
728 let g:UltiSnipsJumpForwardTrigger = "<tab>"
729 let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
731 " UltiSnips completion function that tries to expand a snippet. If there's no
732 " snippet for expanding, it checks for completion window and if it's shown,
733 " selects first element. If there's no completion window it tries to jump to
734 " next placeholder. If there's no placeholder it just returns TAB key
735 " https://github.com/Valloric/YouCompleteMe/issues/36#issuecomment-15451411
736 function! g:UltiSnips_Complete()
737 call UltiSnips#ExpandSnippet()
738 if g:ulti_expand_res == 0
742 call UltiSnips#JumpForwards()
743 if g:ulti_jump_forwards_res == 0
750 au InsertEnter * exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=g:UltiSnips_Complete()<cr>"
751 let g:UltiSnipsListSnippets="<c-e>"
754 call unite#filters#matcher_default#use(['matcher_fuzzy'])
755 call unite#custom#profile('default', 'context', {
757 \ 'direction': 'botright'
760 nnoremap [unite] <Nop>
761 nmap <leader>u [unite]
762 nnoremap [unite]u :UniteResume<CR>
763 nnoremap <silent> [u :UnitePrevious<CR>
764 nnoremap <silent> ]u :UniteNext<CR>
767 " seems not respected
768 let g:unite_source_grep_max_candidates = 2000
770 " Use ag in unite grep source.
771 let g:unite_source_grep_command = 'ag'
772 let g:unite_source_grep_default_opts = '--smart-case --vimgrep --ignore ''.hg'' --ignore ''.svn'' --ignore ''.git'' --ignore ''.bzr'''
773 let g:unite_source_grep_recursive_opt = ''
775 nnoremap <silent> [unite]a :<C-u>Unite grep:.::
\12\17<CR>
776 nnoremap <silent> [unite]A :<C-u>Unite grep:.:-w:
\12\17<CR>
777 command! -nargs=+ Ag Unite grep:.::<args>
779 " unite-file_rec {{{3
781 " Use ag in unite rec source
782 let g:unite_source_rec_async_command = ['ag', '--follow', '--nocolor', '--nogroup', '-g', '']
784 nnoremap <silent> [unite]f :<C-u>Unite -start-insert file_rec/async<CR>
785 call unite#custom#source('file_rec/async', 'sorters', 'sorter_selecta')
788 call unite#custom#default_action('buffer', 'open')
789 nnoremap <silent> [unite]b :<C-u>Unite buffer:-<CR>
791 " unite-jumplist {{{3
792 nnoremap <silent> [unite]j :<C-u>Unite output:jumps:<CR>
795 let g:unite_source_menu_menus = {}
796 let g:unite_source_menu_menus.fugitive = { 'description' : 'fugitive menu'}
797 let g:unite_source_menu_menus.fugitive.command_candidates = {
798 \ 'Gstatus <Leader>gs' : 'Gstatus',
799 \ 'Gcommit -v <Leader>gc' : 'Gcommit -v',
803 nnoremap <silent> <leader>gg :<C-u>Unite menu:fugitive<CR>
805 let g:unite_source_history_yank_enable = 1
806 nnoremap <silent> [unite]p :<C-u>Unite history/yank<CR>
809 nnoremap <silent> <leader>p :YRShow<cr>
810 let g:yankring_history_dir = expand('$XDG_CACHE_HOME/vim')
811 let g:yankring_replace_n_pkey = ''
812 let g:yankring_replace_n_nkey = ''
814 " map Y to y$ for the yank ring
815 function! YRRunAfterMaps()
816 nnoremap Y :<C-U>YRYankCount 'y$'<CR>
820 let g:ycm_clangd_binary_path = 'clangd' " use clangd in path
821 let g:ycm_clangd_args = ['--clang-tidy']
822 let g:ycm_extra_conf_vim_data = ['getcwd()']
823 let g:ycm_add_preview_to_completeopt = 1
824 let g:ycm_complete_in_comments = 1
825 let g:ycm_complete_in_strings = 1
826 let g:ycm_autoclose_preview_window_after_insertion = 0
828 let g:ycm_language_server =
832 \ 'cmdline': [ 'haskell-language-server-wrapper', '--lsp' ],
833 \ 'filetypes': [ 'haskell', 'lhaskell' ]
837 " vim-easy-align {{{2
838 " start interactive EasyAlign in visual mode
839 vmap <Enter> <Plug>(EasyAlign)
840 nmap ga <Plug>(EasyAlign)
843 let g:gtest#highlight_failing_tests = 0
845 nnoremap <silent> <Leader>tt :GTestRun<CR>
846 nnoremap <Leader>tc :GTestCase<space>
847 nnoremap <Leader>tn :GTestName<space>
848 nnoremap <silent> <Leader>ta :GTestCase *<CR>:GTestName *<CR>:GTestRun<CR>
849 nnoremap <silent> <Leader>tu :GTestRunUnderCursor<CR>
852 let g:vim_json_syntax_conceal = 0
855 let g:sneak#streak = 1
856 let g:sneak#target_labels = "aoeuisnthdpylrcgfqjkxzmwvz" " dvorak
857 let g:sneak#use_ic_scs = 1 " follow 'ignorecase' and 'smartcase'
875 " Convenient command to see the difference between the current buffer and the
876 " file it was loaded from, thus the changes you made.
877 " Only define it when not defined already.
878 if !exists(":DiffOrig")
879 command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
880 \ | wincmd p | diffthis
884 function! SortLinesOpFunc(...)
887 nnoremap <silent> gs :<C-U>set operatorfunc=SortLinesOpFunc<CR>g@
888 vnoremap <silent> gs :sort<cr>
891 function! EditConfig(what, ext = '.vim')
892 let l:dir = split(&runtimepath,',')[0]
894 let l:file = expand($MYVIMRC)
895 elseif ! isdirectory(globpath(l:dir, a:what))
896 echoe a:what." is not valid!"
897 elseif empty(&filetype)
898 echoe 'filetype is empty!'
900 let l:file = l:dir.'/'.a:what.'/'.&filetype.a:ext
903 execute ':vsplit '.file
906 nmap <leader>ev :call EditConfig('vimrc')<CR>
907 nmap <leader>ef :call EditConfig('ftplugin')<CR>
908 nmap <leader>es :call EditConfig('syntax')<CR>
909 nmap <leader>ei :call EditConfig('indent')<CR>
910 nmap <leader>eu :call EditConfig('ultisnips', '.snippets')<CR>
913 " http://tex.stackexchange.com/a/52932
914 let g:myLangList=["en_gb","en_us","de","fr"]
916 function! ToggleSpell()
917 if !exists("b:myLang")
920 execute "setlocal spell!"
922 echo "setlocal spelllang=" g:myLangList[b:myLang]
926 function! SwitchSpell()
927 if !exists("b:myLang")
931 let b:myLang=b:myLang+1
932 if b:myLang>=len(g:myLangList) | let b:myLang=0 | endif
934 execute "setlocal spell spelllang=".get(g:myLangList, b:myLang)
935 echo "setlocal spelllang=" g:myLangList[b:myLang]
938 nnoremap <silent> coS :call SwitchSpell()<CR>
939 " fix spelling with first choice
940 nnoremap <Leader>f 1z=
942 " gitdir or home {{{2
944 " http://git.io/v3GAV
945 function! FindGitDirOrHome()
946 let filedir = expand('%:p:h')
947 if isdirectory(filedir)
948 let cmd = 'bash -c "(cd ' . filedir . '; git rev-parse --show-toplevel 2>/dev/null)"'
949 let gitdir = system(cmd)
950 if strlen(gitdir) == 0
960 command! Cdr execute('cd ' . FindGitDirOrHome())
962 command! LCdr execute('lcd ' . FindGitDirOrHome())
964 " vim:set et sw=2 ts=2 tw=78: