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-characterize'
53 Plug 'tpope/vim-endwise'
54 Plug 'tpope/vim-eunuch'
55 Plug 'tpope/vim-fugitive'
56 Plug 'tpope/vim-repeat'
57 Plug 'tpope/vim-scriptease'
58 Plug 'tpope/vim-speeddating'
59 Plug 'tpope/vim-surround' "investigate vim-sandwich
60 Plug 'tpope/vim-unimpaired'
61 Plug 'tweekmonster/spellrotate.vim'
62 Plug 'valloric/youcompleteme', { 'do': './install.py --clangd-completer --clang-completer' }
63 Plug 'vim-scripts/mediawiki.vim'
64 Plug 'vim-scripts/replacewithregister'
65 Plug 'vim-scripts/yankring.vim'
69 Plug 'morhetz/gruvbox' " {{{2
70 let g:gruvbox_contrast_dark = 'hard'
71 let g:gruvbox_contrast_light = 'soft'
73 Plug 'arcticicestudio/nord-vim' " {{{2
76 let g:nord_italic_comments = 1
77 let g:nord_underline = 1
78 let g:nord_uniform_status_lines = 0
79 let g:nord_uniform_diff_background = 0
80 let g:nord_cursor_line_number_background = 0
81 let g:nord_bold_vertical_split_line = 0
86 Plug 'sirver/ultisnips'
87 Plug 'honza/vim-snippets'
90 Plug 'kana/vim-textobj-user'
91 Plug 'julian/vim-textobj-variable-segment'
92 Plug 'sgur/vim-textobj-parameter'
93 Plug 'kana/vim-operator-user'
96 " Check LucHermites plugins: https://github.com/LucHermitte/lh-cpp
98 Plug 'git@github.com:/ram-z/vim-orgmode', { 'branch': 'dev' } " {{{2
99 Plug 'vim-scripts/syntaxrange'
101 let g:org_agenda_files = ['~/org/*.org']
103 Plug 'neovimhaskell/haskell-vim' " {{{2
104 let g:haskell_enable_quantification = 1 " to enable highlighting of `forall`
105 let g:haskell_enable_recursivedo = 1 " to enable highlighting of `mdo` and `rec`
106 let g:haskell_enable_arrowsyntax = 1 " to enable highlighting of `proc`
107 let g:haskell_enable_pattern_synonyms = 1 " to enable highlighting of `pattern`
108 let g:haskell_enable_typeroles = 1 " to enable highlighting of type roles
109 let g:haskell_enable_static_pointers = 1 " to enable highlighting of `static`
110 let g:haskell_backpack = 1 " to enable highlighting of backpack keywords
112 let g:haskell_indent_before_where = 2
115 Plug 'aklt/plantuml-syntax'
117 Plug 'mtth/scratch.vim' " {{{2
118 let g:scratch_no_mappings = 1
119 let g:scratch_autohide = 0
122 Plug 'vim-utils/vim-man' " {{{2
128 filetype plugin indent on
133 let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
134 let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
137 "TODO see how I can integrate this into a theme that customises upstream Nord
138 hi debugPC term=reverse ctermbg=8
141 " moving around, searching and patterns {{{2
142 set incsearch " show match for partly typed search command
143 set ignorecase " ignore case when using a search pattern
144 set smartcase " override 'ignorecase' when pattern has upper case characters
145 set hlsearch " highlight all matches for the last used search pattern
147 set nostartofline " don't move the cursor to the first non-blank char of a line
150 set path+=../include/
151 set path+=/usr/include/c++/*
153 " displaying text {{{2
154 set nowrap " long lines wrap
155 set linebreak " wrap long lines at a character in 'breakat'
156 set showbreak=↪ " show these chars for wrapped lines
157 set breakindent " preserve indentation in wrapped text
159 set lazyredraw " don't redraw while executing macros
161 set list " show chars defined in 'listchars'
162 set listchars=tab:❭\ " list of strings used for list mode
163 set listchars+=extends:❯,precedes:❮
164 " Only shown when not in insert mode
165 set listchars+=trail:·
168 au FileType qf setlocal listchars-=trail:·
169 au InsertEnter * set listchars-=trail:·
170 au InsertLeave * set listchars+=trail:·
173 set scrolloff=5 " number of screen lines to show around the cursor
174 set sidescroll=1 " number of collumns to scroll
175 set sidescrolloff=1 " don't scroll over the listchars
177 set fillchars=diff:⣿,vert:│
179 set nonumber " show the line number for each line
180 set norelativenumber " show the relative line number for each line
182 " syntax, highlighting and spelling {{{2
183 set synmaxcol=800 " don't highlight long lines
185 set dictionary=spell " list of dictionary files for keyword completion
189 " multiple windows {{{2
190 set laststatus=2 " 0, 1 or 2; when to use a status line for the last window
192 set previewheight=20 " default height for the preview window
196 " set splitbelow " a new window is put below of the current one
197 set splitright " a new window is put right of the current one
202 " using the mouse {{{2
203 set mouse=rnv " list of flags for using the mouse
204 set ttymouse=xterm " type of mouse
206 " messages and info {{{2
207 set showcmd " Show (partial) command in status line.
208 set ruler " show the cursor position all the time
209 set confirm " Ask what to do when closing unsaved documents
210 set shortmess= " reset option
211 set shortmess+=a " all abbreviations
212 set shortmess+=o " overwrite file-written message
213 set shortmess+=O " file-read message overrides previous
214 set shortmess+=t " truncate file message at start
215 set shortmess+=T " truncate other messages in the middle
216 set shortmess+=W " don't give 'written' or '[w]' when writing a file
217 set shortmess+=A " ignore swapfile warning
218 set shortmess+=I " no splash screen
221 set backspace=indent,eol,start " allow backspacing over everything in insert mode
223 set showmatch " Show matching brackets.
225 set nojoinspaces " don't use two spaces after '.' when joining a line
226 set formatoptions+=j " Delete comment leader when joining lines
227 set formatoptions+=c " Autowrap comments using textwidth
228 set formatoptions+=r " Insert comment leader after hitting <Enter>
229 set formatoptions+=n " Recognize numbered lists
230 set formatoptions+=q " Allow formatting of comments with "gq".
231 set formatoptions+=l " do not wrap lines that have been longer when starting insert mode already
232 set formatoptions+=t " Auto-wrap text using textwidth
233 set formatoptions-=o " Do not insert comment leader after hitting o or O in normal mode
235 set nrformats=hex " number formats recognized for CTRL-A and CTRL-X commands
237 set complete=. " scan the current buffer ( 'wrapscan' is ignored)
238 set complete+=w " scan buffers from other windows
239 set complete+=b " scan other loaded buffers that are in the buffer list
240 set complete+=u " scan the unloaded buffers that are in the buffer list
241 set complete+=t " scan tags
242 set complete+=i " scan current and included files
243 set complete+=kspell " use the currently active spell checking |spell|
245 " whether to use a popup menu for Insert mode completion
246 set completeopt=longest,menuone,preview
248 " tabs and indent {{{2
249 set shiftwidth=4 " number of spaces used for each step of (auto)indent
250 set smarttab " a <Tab> in an indent inserts 'shiftwidth' spaces
251 set softtabstop=4 " if non-zero, number of spaces to insert for a <Tab>
252 set shiftround " round to 'shiftwidth' for "<<" and ">>"
253 set expandtab " expand <Tab> to spaces in Insert mode
256 set pastetoggle=<F11> " key sequence to toggle paste mode
259 set foldmethod=marker " folding type
260 set foldlevelstart=0 " value for 'foldlevel' when starting to edit a file
262 " open folds when jumping to line
265 set viewoptions=cursor " save cursor position
266 set viewoptions+=folds " save folds
269 set diffopt+=filler " show filler lines
270 set diffopt+=vertical " always vertical split
271 set diffopt+=context:10 " 10 lines context between changes
272 set diffopt+=internal
273 set diffopt+=algorithm:patience
275 " reading and writing files {{{2
276 set modeline " read modelines
277 set modelines=2 " only check first/last 2 lines
279 set writebackup " write a backup file before overwriting a file
280 set backup " keep a backup after owerwriting a file
281 set backupdir=$XDG_CACHE_HOME/vim/backup//
283 set backupskip+=.netrc " skip netrc
284 set backupskip+=/dev/shm/pass* " skip passwordstore files
286 set undofile " persistent undo history
287 set undodir=$XDG_CACHE_HOME/vim/undo//
291 au BufWritePre .netrc setlocal noundofile
292 au BufWritePre /dev/shm/pass* setlocal noundofile
293 au BufWritePre /tmp/* setlocal noundofile
296 set autowrite " automatically write a file when leaving a modified buffer
297 set autoread " automatically read a file that has been modified
301 set directory=$XDG_CACHE_HOME/vim/swap//
303 " command line editing {{{2
304 set history=5000 " how many command lines are remembered
305 set wildmenu " command-line completion shows a list of matches
306 set wildmode=longest:full,full " specifies how command line completion works
307 set wildignorecase " ignore case when completing file names
309 set wildignore+=.hg,.git,.svn " Version control
310 set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
311 set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
312 set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
313 set wildignore+=*.spl " compiled spelling word lists
314 set wildignore+=*.sw? " Vim swap files
315 set wildignore+=*.luac " Lua byte code
316 set wildignore+=*.pyc " Python byte code
317 set wildignore+=*.orig " Merge resolution files
319 " running make and jumping to errors {{{2
320 set makeprg=make\ -w " print changing directories
322 set grepprg=ag\ --vimgrep\ $*
324 " language specific {{{2
325 set isfname-== " don't treat `=` as being part of filenames
328 set virtualedit+=block " let cursor move past last char in <C-V> mode
329 set virtualedit+=onemore " allow the cursor to move just past the end of the line
330 set viminfo='100,<50,s10,h,n$XDG_CACHE_HOME/vim/viminfo " viminfo defaults but save file in .cache
332 set viewdir=$XDG_CACHE_HOME/vim/view//
334 set sessionoptions+=unix,slash " damn windows and it's silly ways
337 " Resize splits when the window is resized {{{2
340 autocmd VimResized * :wincmd =
343 " Only show cursorline in the current window and in normal mode {{{2
346 au WinLeave,InsertEnter * set nocursorline
347 au WinEnter,InsertLeave * set cursorline
350 " Treat buffers from stdin (e.g.: echo foo | vim -) as scratch {{{2
353 au StdinReadPost * :set buftype=nofile
356 " Jump to last known cursor position {{{2
359 " blacklist certain filetype
360 let blacklist = ['gitcommit']
361 autocmd BufReadPost *
362 \ if index(blacklist, &ft) < 0 && line("'\"") > 1 && line("'\"") <= line("$") |
363 \ exe "normal! g`\"" |
367 " Check for file modifications automatically {{{2
368 " (current buffer only)
369 " Use :NoAutoChecktime to disable it (uses b:autochecktime)
370 fun! MyAutoCheckTime()
371 " only check timestamp for normal files
372 if &buftype != '' | return | endif
373 if ! exists('b:autochecktime') || b:autochecktime
375 let b:autochecktime = 1
378 augroup MyAutoChecktime
380 au FocusGained,BufEnter,CursorHold,InsertEnter * call MyAutoCheckTime()
382 command! NoAutoChecktime let b:autochecktime=0
383 command! ToggleAutoChecktime let b:autochecktime=!get(b:, 'autochecktime', 0) | echom "b:autochecktime:" b:autochecktime
387 au TerminalOpen * if &buftype == 'terminal' | setlocal bufhidden=hide | endif
392 " allow both <space> and \ to be <leader>
396 function! MakeWithOpt()
397 " TODO only do this if makeprg matches make
398 " if &makeprg =~ "make"
400 if exists("b:make_dir")
401 let l:make_dir = "-C ".b:make_dir
402 elseif exists("t:make_dir")
403 let l:make_dir = "-C ".t:make_dir
404 elseif exists("g:make_dir")
405 let l:make_dir = "-C ".g:make_dir
408 let l:make_targets = ""
409 if exists("g:make_targets")
410 let l:make_targets = g:make_targets
412 execute "Make ".l:make_dir." ".l:make_targets
414 nnoremap <silent> <leader>r :call MakeWithOpt()<cr>
417 nnoremap <silent> <Leader>/ :silent nohl<CR>
420 nnoremap <leader>[ :tabprev<cr>
421 nnoremap <leader>] :tabnext<cr>
423 " paste from selection
424 nnoremap <leader>p* :silent! set paste<CR>"*p:set nopaste<CR>
425 " paste from clipboard
426 nnoremap <leader>p+ :silent! set paste<CR>"+p:set nopaste<CR>
428 " strip trailing whitespace
429 function! StripWhitespace(line1, line2, ...) " {{{2
430 let s_report = &report
432 let pattern = a:0 ? a:1 : '\s\+$'
433 let oldview = winsaveview()
434 exe 'keepjumps keeppatterns '.a:line1.','.a:line2.'substitute/'.pattern.'//e'
435 if oldview != winsaveview()
438 call winrestview(oldview)
439 let &report = s_report
441 command! -range=% -nargs=0 -bar Untrail keepjumps call StripWhitespace(<line1>,<line2>)
442 nnoremap <silent> <leader>ww :Untrail<CR>
445 vnoremap <leader>S y:execute @@<cr>:echo 'Sourced selection.'<cr>
446 nnoremap <leader>S ^vg_y:execute @@<cr>:echo 'Sourced line.'<cr>
448 " jump to last cursor position
451 " Select (charwise) the contents of the current line, excluding indentation.
456 \ :syntax sync fromstart<cr>
457 \ :AirlineRefresh<cr>
458 \ :call popup_clear(1)<cr>
462 " nnoremap <leader>r :silent !ranger %:h<cr>:redraw!<cr>
463 " nnoremap <leader>R :silent !ranger<cr>:redraw!<cr>
470 " display the number of matches for the last search
471 nmap <Leader># :%s:<C-R>/::gn<CR>
473 " center cursor after search and open folds
477 " same when jumping around
480 nnoremap <c-o> <c-o>zzzv
481 nnoremap <c-i> <c-i>zzzv
483 " Not using the default mappings of 'To line from top/bottom'
489 " Heresy, emacs insert bindings
490 inoremap <C-A> <Esc>I
491 inoremap <C-E> <Esc>A
492 cnoremap <C-A> <Home>
495 " proper movement when lines are wrapped
496 noremap <silent><expr> j (v:count == 0 ? 'gj' : 'j')
497 noremap <silent><expr> k (v:count == 0 ? 'gk' : 'k')
503 noremap <Right> <NOP>
505 inoremap <Down> <NOP>
506 inoremap <Left> <NOP>
507 inoremap <Right> <NOP>
509 cnoremap <Down> <NOP>
510 cnoremap <Left> <NOP>
511 cnoremap <Right> <NOP>
513 cnoremap <C-J> <Down>
514 cnoremap <C-H> <Left>
515 cnoremap <C-L> <Right>
517 " close all folds open fold in cursor
520 map <F1> :ls<CR>:b<space>
522 " move between windows (skip previewwindow)
523 nnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
524 nnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
525 tnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
526 tnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
528 "xterm mouse with middleclick paste
529 nnoremap <MiddleMouse> i<MiddleMouse>
530 vnoremap <MiddleMouse> s<MiddleMouse>
532 " fix legacy vi inconsistency
537 " allow repeat operator on visual
538 vnoremap . :normal .<CR>
540 " add line without changing position or leaving mode
541 noremap <silent> <Leader>o :set paste<CR>m`o<ESC>``:set nopaste<CR>
542 noremap <silent> <Leader>O :set paste<CR>m`O<ESC>``:set nopaste<CR>
544 " Don't use Ex mode, use Q for formatting
547 " break undo sequence before removing word
548 inoremap <C-W> <C-G>u<C-W>
550 nnoremap coe :set <C-R>=&expandtab ? 'noexpandtab' : 'expandtab'<CR><CR>
551 nnoremap [oe :set expandtab<CR>
552 nnoremap ]oe :set noexpandtab<CR>
554 for idt in range(1,8)
555 exe 'nnoremap co'.idt.' :setlocal tabstop='.idt.' shiftwidth='.idt.' softtabstop='.idt.'<CR>'
558 " toggle auto format of text
559 nnoremap coa :set <C-R>=&formatoptions =~ "a" ? 'formatoptions-=a' : 'formatoptions+=a'<CR><CR>
560 nnoremap [oa :set formatoptions+=a<CR>
561 nnoremap ]oa :set formatoptions-=a<CR>
563 " space will toggle current fold in normal mode
564 nnoremap <leader><Space> za
565 " create folds around visual selection
566 vnoremap <leader><Space> zf
569 cabbrev w!! SudoWrite
571 " uppercase previous word
572 inoremap <C-C> <Esc>gUiwgi
574 " http://git.io/v3ZeU
575 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>
577 " plugins options {{{1
579 let g:airline#extensions#whitespace#enabled = 1
580 let g:airline#extensions#tabline#enabled = 1
581 let g:airline#extensions#searchcount#enabled = 0
582 let g:airline_powerline_fonts = 1
584 let g:asyncrun_status = "stopped"
585 let g:airline_section_error = airline#section#create_right(['%{g:asyncrun_status}'])
588 let g:checkattach_filebrowser = 'ranger'
589 let g:checkattach_once = 'y'
592 let delimitMate_expand_cr = 2
593 let g:delimitMate_expand_space = 1
596 nnoremap <silent> <Leader>ff :FSHere<CR>
597 nnoremap <silent> <Leader>fl :FSRight<CR>
598 nnoremap <silent> <Leader>fh :FSLeft<CR>
599 nnoremap <silent> <Leader>fj :FSBelow<CR>
600 nnoremap <silent> <Leader>fk :FSAbove<CR>
601 nnoremap <silent> <Leader>fL :FSSplitRight<CR>
602 nnoremap <silent> <Leader>fH :FSSplitLeft<CR>
603 nnoremap <silent> <Leader>fJ :FSSplitBelow<CR>
604 nnoremap <silent> <Leader>fK :FSSplitAbove<CR>
607 nmap <silent> <leader>dd :tab split \| Gdiff \| wincmd h<CR>
608 " delete fugitive buffers when closed
609 autocmd BufReadPost fugitive://* set bufhidden=delete
611 function! GitToggle()
612 if buflisted(bufname('.git/index'))
619 command! GitToggle :call GitToggle()
620 command! GToggle GitToggle
621 nnoremap <silent> <leader>gs :GitToggle<CR>
623 nnoremap <silent> <leader>gd :Gdiffsplit<CR>
624 nnoremap <silent> <leader>gc :echohl WarningMsg \| echo "use \<leader>gcc instead" \| echohl None<CR>
625 nnoremap <silent> <leader>gcc :tab G commit -v<CR>
626 nnoremap <silent> <leader>gca :tab G commit -v --amend<CR>
627 nnoremap <leader>gcf :tab G commit -v --fixup=
628 nnoremap <silent> <leader>gp :echohl WarningMsg \| echo "use \<leader>gpp instead" \| echohl None<CR>
629 nnoremap <silent> <leader>gpp :Git push \| copen<CR>
630 nnoremap <silent> <leader>gpf :Git push --force-with-lease \| copen<CR>
631 nnoremap <silent> <leader>gll :Git pull<CR>
632 nnoremap <silent> <leader>gru :Git rebase --interactive @{upstream}<CR>
633 nnoremap <silent> <leader>grp :Git rebase --interactive @{push}<CR>
634 nnoremap <silent> <leader>ga :Gwrite<cr>
635 nnoremap <silent> <leader>gb :G blame<cr>
637 augroup fugitive_gstatus
639 autocmd User FugitiveIndex setlocal winfixheight
640 autocmd User FugitiveIndex nmap <buffer> <leader><space> =
644 nnoremap <F7> :GundoToggle<CR>
645 let g:gundo_prefer_python3 = 1
648 let g:indent_guides_default_mapping = 0
649 let g:indent_guides_guide_size = 1
650 nmap <silent> cog <Plug>IndentGuidesToggle
651 nmap <silent> [og <Plug>IndentGuidesEnable
652 nmap <silent> ]og <Plug>IndentGuidesDisable
654 " close-another-window {{{2
655 nnoremap <silent> <C-W>c <NOP>
656 nnoremap <silent> <C-W>cc <C-W>c
657 nnoremap <silent> <C-W>ch :CloseLeftWindow<CR>
658 nnoremap <silent> <C-W>cl :CloseRightWindow<CR>
659 nnoremap <silent> <C-W>cj :CloseBelowWindow<CR>
660 nnoremap <silent> <C-W>ck :CloseAboveWindow<CR>
664 let g:pymode_rope_completion = 0
665 let g:pymode_rope = 0
667 let g:pymode_folding = 1
668 let g:pymode_lint_ignore = "E221,E266,E501"
669 let g:pymode_lint_cwindow = 0 " don't open cwindow when linting
670 let g:pymode_syntax_space_errors = 0 " don't bother me when I'm typing
673 " disable '[ mappings
675 let g:SignatureMap = {
676 \ 'GotoNextLineAlpha' : "",
677 \ 'GotoPrevLineAlpha' : "",
678 \ 'GotoNextSpotAlpha' : "",
679 \ 'GotoPrevSpotAlpha' : "",
683 let g:switch_mapping = "<Leader>s"
684 let g:switch_custom_definitions = [
689 nmap <silent> z] <Plug>(SpellRotateForward)
690 nmap <silent> z[ <Plug>(SpellRotateBackward)
691 vmap <silent> z] <Plug>(SpellRotateForwardV)
692 vmap <silent> z[ <Plug>(SpellRotateBackwardV)
695 let g:syntastic_enable_highlighting = 0
696 let g:syntastic_error_symbol='E'
697 let g:syntastic_style_error_symbol='S'
698 let g:syntastic_warning_symbol='W'
699 let g:syntastic_style_warning_symbol='S'
700 let g:syntastic_always_populate_loc_list=1
701 nmap <silent> <leader>y :SyntasticCheck<cr>
703 let g:syntastic_cpp_clang_tidy_post_args = "-p build*"
706 let g:syntastic_check_on_open=1
710 map <F5> :TagbarToggle<cr>
711 let g:tagbar_sort = 0
712 let g:tagbar_compact = 1
713 let g:tagbar_autoshowtag = 1
714 let g:tagbar_width = 25
715 let g:tagbar_iconchars = ['+', '-']
718 let g:tcomment_textobject_inlinecomment = 'gic'
719 let g:tcomment#filetype#guess = 0
720 "let g:tcomment#options = {'whitespace' : 'no'}
723 let g:UltiSnipsEditSplit = 'vertical'
724 let g:UltiSnipsSnippetDirectories = [ expand("$XDG_CONFIG_HOME/vim/ultisnips") ]
726 let g:UltiSnipsSnippetDirectories = ["UltiSnips", "ultisnips"]
728 let g:UltiSnipsExpandTrigger = "<tab>"
729 let g:UltiSnipsJumpForwardTrigger = "<tab>"
730 let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
732 " UltiSnips completion function that tries to expand a snippet. If there's no
733 " snippet for expanding, it checks for completion window and if it's shown,
734 " selects first element. If there's no completion window it tries to jump to
735 " next placeholder. If there's no placeholder it just returns TAB key
736 " https://github.com/Valloric/YouCompleteMe/issues/36#issuecomment-15451411
737 function! g:UltiSnips_Complete()
738 call UltiSnips#ExpandSnippet()
739 if g:ulti_expand_res == 0
743 call UltiSnips#JumpForwards()
744 if g:ulti_jump_forwards_res == 0
751 au InsertEnter * exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=g:UltiSnips_Complete()<cr>"
752 let g:UltiSnipsListSnippets="<c-e>"
755 call unite#filters#matcher_default#use(['matcher_fuzzy'])
756 call unite#custom#profile('default', 'context', {
758 \ 'direction': 'botright'
761 nnoremap [unite] <Nop>
762 nmap <leader>u [unite]
763 nnoremap [unite]u :UniteResume<CR>
764 nnoremap <silent> [u :UnitePrevious<CR>
765 nnoremap <silent> ]u :UniteNext<CR>
768 " seems not respected
769 let g:unite_source_grep_max_candidates = 2000
771 " Use ag in unite grep source.
772 let g:unite_source_grep_command = 'ag'
773 let g:unite_source_grep_default_opts = '--smart-case --vimgrep --ignore ''.hg'' --ignore ''.svn'' --ignore ''.git'' --ignore ''.bzr'''
774 let g:unite_source_grep_recursive_opt = ''
776 nnoremap <silent> [unite]a :<C-u>Unite grep:.::
\12\17<CR>
777 nnoremap <silent> [unite]A :<C-u>Unite grep:.:-w:
\12\17<CR>
778 command! -nargs=+ Ag Unite grep:.::<args>
780 " unite-file_rec {{{3
782 " Use ag in unite rec source
783 let g:unite_source_rec_async_command = ['ag', '--follow', '--nocolor', '--nogroup', '-g', '']
785 nnoremap <silent> [unite]f :<C-u>Unite -start-insert file_rec/async<CR>
786 call unite#custom#source('file_rec/async', 'sorters', 'sorter_selecta')
789 call unite#custom#default_action('buffer', 'open')
790 nnoremap <silent> [unite]b :<C-u>Unite buffer:-<CR>
792 " unite-jumplist {{{3
793 nnoremap <silent> [unite]j :<C-u>Unite output:jumps:<CR>
796 let g:unite_source_menu_menus = {}
797 let g:unite_source_menu_menus.fugitive = { 'description' : 'fugitive menu'}
798 let g:unite_source_menu_menus.fugitive.command_candidates = {
799 \ 'Gstatus <Leader>gs' : 'Gstatus',
800 \ 'Gcommit -v <Leader>gc' : 'Gcommit -v',
804 nnoremap <silent> <leader>gg :<C-u>Unite menu:fugitive<CR>
806 let g:unite_source_history_yank_enable = 1
807 nnoremap <silent> [unite]p :<C-u>Unite history/yank<CR>
810 nnoremap <silent> <leader>p :YRShow<cr>
811 let g:yankring_history_dir = expand('$XDG_CACHE_HOME/vim')
812 let g:yankring_replace_n_pkey = ''
813 let g:yankring_replace_n_nkey = ''
815 " map Y to y$ for the yank ring
816 function! YRRunAfterMaps()
817 nnoremap Y :<C-U>YRYankCount 'y$'<CR>
821 let g:ycm_clangd_binary_path = 'clangd' " use clangd in path
822 let g:ycm_clangd_args = ['--clang-tidy']
823 let g:ycm_extra_conf_vim_data = ['getcwd()']
824 let g:ycm_add_preview_to_completeopt = 1
825 let g:ycm_complete_in_comments = 1
826 let g:ycm_complete_in_strings = 1
827 let g:ycm_autoclose_preview_window_after_insertion = 0
829 let g:ycm_language_server =
833 \ 'cmdline': [ 'haskell-language-server-wrapper', '--lsp' ],
834 \ 'filetypes': [ 'haskell', 'lhaskell' ]
838 " vim-easy-align {{{2
839 " start interactive EasyAlign in visual mode
840 vmap <Enter> <Esc>:echohl WarningMsg \| echo "EasyAlign mapped to
\16<leader>a now" \| echohl None<CR>
841 vmap <leader>a <Plug>(EasyAlign)
842 nmap <leader>a <Plug>(EasyAlign)
845 let g:gtest#highlight_failing_tests = 0
847 nnoremap <silent> <Leader>tt :GTestRun<CR>
848 nnoremap <Leader>tc :GTestCase<space>
849 nnoremap <Leader>tn :GTestName<space>
850 nnoremap <silent> <Leader>ta :GTestCase *<CR>:GTestName *<CR>:GTestRun<CR>
851 nnoremap <silent> <Leader>tu :GTestRunUnderCursor<CR>
854 let g:vim_json_syntax_conceal = 0
857 let g:sneak#streak = 1
858 let g:sneak#target_labels = "aoeuisnthdpylrcgfqjkxzmwvz" " dvorak
859 let g:sneak#use_ic_scs = 1 " follow 'ignorecase' and 'smartcase'
877 " Convenient command to see the difference between the current buffer and the
878 " file it was loaded from, thus the changes you made.
879 " Only define it when not defined already.
880 if !exists(":DiffOrig")
881 command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
882 \ | wincmd p | diffthis
886 function! SortLinesOpFunc(...)
889 nnoremap <silent> gs :<C-U>set operatorfunc=SortLinesOpFunc<CR>g@
890 vnoremap <silent> gs :sort<cr>
893 function! EditConfig(what, ext = '.vim')
894 let l:dir = split(&runtimepath,',')[0]
896 let l:file = expand($MYVIMRC)
897 elseif ! isdirectory(globpath(l:dir, a:what))
898 echoe a:what." is not valid!"
899 elseif empty(&filetype)
900 echoe 'filetype is empty!'
902 let l:file = l:dir.'/'.a:what.'/'.&filetype.a:ext
905 execute ':vsplit '.file
908 nmap <leader>ev :call EditConfig('vimrc')<CR>
909 nmap <leader>ef :call EditConfig('ftplugin')<CR>
910 nmap <leader>es :call EditConfig('syntax')<CR>
911 nmap <leader>ei :call EditConfig('indent')<CR>
912 nmap <leader>eu :call EditConfig('ultisnips', '.snippets')<CR>
915 " http://tex.stackexchange.com/a/52932
916 let g:myLangList=["en_gb","en_us","de","fr"]
918 function! ToggleSpell()
919 if !exists("b:myLang")
922 execute "setlocal spell!"
924 echo "setlocal spelllang=" g:myLangList[b:myLang]
928 function! SwitchSpell()
929 if !exists("b:myLang")
933 let b:myLang=b:myLang+1
934 if b:myLang>=len(g:myLangList) | let b:myLang=0 | endif
936 execute "setlocal spell spelllang=".get(g:myLangList, b:myLang)
937 echo "setlocal spelllang=" g:myLangList[b:myLang]
940 nnoremap <silent> coS :call SwitchSpell()<CR>
941 " fix spelling with first choice
942 nnoremap <Leader>f 1z=
944 " gitdir or home {{{2
946 " http://git.io/v3GAV
947 function! FindGitDirOrHome()
948 let filedir = expand('%:p:h')
949 if isdirectory(filedir)
950 let cmd = 'bash -c "(cd ' . filedir . '; git rev-parse --show-toplevel 2>/dev/null)"'
951 let gitdir = system(cmd)
952 if strlen(gitdir) == 0
962 command! Cdr execute('cd ' . FindGitDirOrHome())
964 command! LCdr execute('lcd ' . FindGitDirOrHome())
966 " vim:set et sw=2 ts=2 tw=78: