3 " Author: Samir Benmendil <samir.benmendil[at]gmail[dot]com>
7 set runtimepath ^=$XDG_CONFIG_HOME/vim
8 set runtimepath +=$XDG_CONFIG_HOME/vim/after
11 if has('python3') | endif
14 " remove all autocommands
17 call plug#begin('$XDG_DATA_HOME/vim')
18 " This does not update vim-plug, use PlugUpgrade instead
19 Plug 'junegunn/vim-plug'
21 Plug 'airblade/vim-gitgutter' " {{{
22 " prefer other signs such as ycm diags
23 let g:gitgutter_sign_priority = 1
24 " don't clobber other signs
25 let g:gitgutter_sign_allow_clobber = 0
27 Plug 'alepez/vim-gtest'
29 Plug 'andrewradev/switch.vim'
30 Plug 'bling/vim-airline'
31 Plug 'chrisbra/checkattach'
32 Plug 'derekwyatt/vim-fswitch'
34 Plug 'firef0x/pkgbuild.vim'
35 Plug 'junegunn/vim-easy-align'
36 Plug 'justinmk/vim-sneak'
37 Plug 'klen/python-mode'
38 Plug 'kshenoy/vim-signature'
39 Plug 'majutsushi/tagbar'
40 Plug 'octol/vim-cpp-enhanced-highlight'
41 Plug 'raimondi/delimitmate'
42 Plug 'sgeb/vim-diff-fold'
43 Plug 'shougo/unite.vim'
44 Plug 'shougo/vimproc.vim', {'do': 'make'}
46 Plug 'thinca/vim-qfreplace'
47 Plug 'tomtom/tcomment_vim'
48 Plug 'tpope/vim-abolish'
49 Plug 'tpope/vim-endwise'
50 Plug 'tpope/vim-eunuch'
51 Plug 'tpope/vim-fugitive'
52 Plug 'tpope/vim-repeat'
53 Plug 'tpope/vim-scriptease'
54 Plug 'tpope/vim-speeddating'
55 Plug 'tpope/vim-surround' "investigate vim-sandwich
56 Plug 'tpope/vim-unimpaired'
57 Plug 'tweekmonster/spellrotate.vim'
58 Plug 'valloric/youcompleteme', { 'do': './install.py --clangd-completer --clang-completer' }
59 Plug 'vim-scripts/mediawiki.vim'
60 Plug 'vim-scripts/replacewithregister'
61 Plug 'vim-scripts/yankring.vim'
65 Plug 'morhetz/gruvbox' " {{{2
66 let g:gruvbox_contrast_dark = 'hard'
67 let g:gruvbox_contrast_light = 'soft'
69 Plug 'arcticicestudio/nord-vim' " {{{2
72 let g:nord_italic_comments = 1
73 let g:nord_underline = 1
74 let g:nord_uniform_status_lines = 0
75 let g:nord_uniform_diff_background = 0
76 let g:nord_cursor_line_number_background = 0
77 let g:nord_bold_vertical_split_line = 0
82 Plug 'sirver/ultisnips'
83 Plug 'honza/vim-snippets'
86 Plug 'kana/vim-textobj-user'
87 Plug 'julian/vim-textobj-variable-segment'
88 Plug 'sgur/vim-textobj-parameter'
89 Plug 'kana/vim-operator-user'
92 " Check LucHermites plugins: https://github.com/LucHermitte/lh-cpp
93 Plug 'dense-analysis/ale' " {{{2
94 let g:ale_echo_msg_format = '[%linter%] %code: %%s'
96 Plug 'git@github.com:/ram-z/vim-orgmode', { 'branch': 'dev' } " {{{2
97 Plug 'vim-scripts/syntaxrange'
99 let g:org_agenda_files = ['~/org/*.org']
101 Plug 'neovimhaskell/haskell-vim' " {{{2
102 let g:haskell_enable_quantification = 1 " to enable highlighting of `forall`
103 let g:haskell_enable_recursivedo = 1 " to enable highlighting of `mdo` and `rec`
104 let g:haskell_enable_arrowsyntax = 1 " to enable highlighting of `proc`
105 let g:haskell_enable_pattern_synonyms = 1 " to enable highlighting of `pattern`
106 let g:haskell_enable_typeroles = 1 " to enable highlighting of type roles
107 let g:haskell_enable_static_pointers = 1 " to enable highlighting of `static`
108 let g:haskell_backpack = 1 " to enable highlighting of backpack keywords
111 Plug 'aklt/plantuml-syntax'
113 Plug 'mtth/scratch.vim' " {{{2
114 let g:scratch_no_mappings = 1
115 let g:scratch_autohide = 0
118 Plug 'vim-utils/vim-man' " {{{2
124 filetype plugin indent on
129 let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
130 let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
135 " moving around, searching and patterns {{{2
136 set incsearch " show match for partly typed search command
137 set ignorecase " ignore case when using a search pattern
138 set smartcase " override 'ignorecase' when pattern has upper case characters
139 set hlsearch " highlight all matches for the last used search pattern
141 set nostartofline " don't move the cursor to the first non-blank char of a line
144 set path+=../include/
145 set path+=/usr/include/c++/*
147 " displaying text {{{2
148 set nowrap " long lines wrap
149 set linebreak " wrap long lines at a character in 'breakat'
150 set showbreak=↪ " show these chars for wrapped lines
151 set breakindent " preserve indentation in wrapped text
153 set lazyredraw " don't redraw while executing macros
155 set list " show chars defined in 'listchars'
156 set listchars=tab:❭\ " list of strings used for list mode
157 set listchars+=extends:❯,precedes:❮
158 " Only shown when not in insert mode
159 set listchars+=trail:·
162 au InsertEnter * :set listchars-=trail:·
163 au InsertLeave * :set listchars+=trail:·
166 set scrolloff=5 " number of screen lines to show around the cursor
167 set sidescroll=1 " number of collumns to scroll
168 set sidescrolloff=1 " don't scroll over the listchars
170 set fillchars=diff:⣿,vert:│
172 set nonumber " show the line number for each line
173 set norelativenumber " show the relative line number for each line
175 " syntax, highlighting and spelling {{{2
176 set synmaxcol=800 " don't highlight long lines
178 set dictionary=spell " list of dictionary files for keyword completion
182 " multiple windows {{{2
183 set laststatus=2 " 0, 1 or 2; when to use a status line for the last window
185 set previewheight=20 " default height for the preview window
189 " set splitbelow " a new window is put below of the current one
190 set splitright " a new window is put right of the current one
195 " using the mouse {{{2
196 set mouse=rnv " list of flags for using the mouse
197 set ttymouse=xterm " type of mouse
199 " messages and info {{{2
200 set showcmd " Show (partial) command in status line.
201 set ruler " show the cursor position all the time
202 set confirm " Ask what to do when closing unsaved documents
203 set shortmess= " reset option
204 set shortmess+=a " all abbreviations
205 set shortmess+=o " overwrite file-written message
206 set shortmess+=O " file-read message overrides previous
207 set shortmess+=t " truncate file message at start
208 set shortmess+=T " truncate other messages in the middle
209 set shortmess+=W " don't give 'written' or '[w]' when writing a file
210 set shortmess+=A " ignore swapfile warning
211 set shortmess+=I " no splash screen
214 set backspace=indent,eol,start " allow backspacing over everything in insert mode
216 set showmatch " Show matching brackets.
218 set nojoinspaces " don't use two spaces after '.' when joining a line
219 set formatoptions+=j " Delete comment leader when joining lines
220 set formatoptions+=c " Autowrap comments using textwidth
221 set formatoptions+=r " Insert comment leader after hitting <Enter>
222 set formatoptions+=n " Recognize numbered lists
223 set formatoptions+=q " Allow formatting of comments with "gq".
224 set formatoptions+=l " do not wrap lines that have been longer when starting insert mode already
225 set formatoptions+=t " Auto-wrap text using textwidth
226 set formatoptions-=o " Do not insert comment leader after hitting o or O in normal mode
228 set nrformats=hex " number formats recognized for CTRL-A and CTRL-X commands
230 set complete=. " scan the current buffer ( 'wrapscan' is ignored)
231 set complete+=w " scan buffers from other windows
232 set complete+=b " scan other loaded buffers that are in the buffer list
233 set complete+=u " scan the unloaded buffers that are in the buffer list
234 set complete+=t " scan tags
235 set complete+=i " scan current and included files
236 set complete+=kspell " use the currently active spell checking |spell|
238 " whether to use a popup menu for Insert mode completion
239 set completeopt=longest,menuone,preview
241 " tabs and indent {{{2
242 set shiftwidth=4 " number of spaces used for each step of (auto)indent
243 set smarttab " a <Tab> in an indent inserts 'shiftwidth' spaces
244 set softtabstop=4 " if non-zero, number of spaces to insert for a <Tab>
245 set shiftround " round to 'shiftwidth' for "<<" and ">>"
246 set expandtab " expand <Tab> to spaces in Insert mode
249 set pastetoggle=<F11> " key sequence to toggle paste mode
252 set foldmethod=marker " folding type
253 set foldlevelstart=0 " value for 'foldlevel' when starting to edit a file
255 " open folds when jumping to line
258 set viewoptions=cursor " save cursor position
259 set viewoptions+=folds " save folds
262 set diffopt+=filler " show filler lines
263 set diffopt+=vertical " always vertical split
264 set diffopt+=context:10 " 10 lines context between changes
266 " reading and writing files {{{2
267 set modeline " read modelines
268 set modelines=2 " only check first/last 2 lines
270 set writebackup " write a backup file before overwriting a file
271 set backup " keep a backup after owerwriting a file
272 set backupdir=$XDG_CACHE_HOME/vim/backup//
274 set backupskip+=.netrc " skip netrc
275 set backupskip+=/dev/shm/pass* " skip passwordstore files
277 set undofile " persistent undo history
278 set undodir=$XDG_CACHE_HOME/vim/undo//
282 au BufWritePre .netrc setlocal noundofile
283 au BufWritePre /dev/shm/pass* setlocal noundofile
284 au BufWritePre /tmp/* setlocal noundofile
287 set autowrite " automatically write a file when leaving a modified buffer
288 set autoread " automatically read a file that has been modified
292 set directory=$XDG_CACHE_HOME/vim/swap//
294 " command line editing {{{2
295 set history=5000 " how many command lines are remembered
296 set wildmenu " command-line completion shows a list of matches
297 set wildmode=longest:full,full " specifies how command line completion works
298 set wildignorecase " ignore case when completing file names
300 set wildignore+=.hg,.git,.svn " Version control
301 set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
302 set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
303 set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
304 set wildignore+=*.spl " compiled spelling word lists
305 set wildignore+=*.sw? " Vim swap files
306 set wildignore+=*.luac " Lua byte code
307 set wildignore+=*.pyc " Python byte code
308 set wildignore+=*.orig " Merge resolution files
310 " running make and jumping to errors {{{2
311 set makeprg=make\ -w " print changing directories
313 set grepprg=ag\ --vimgrep\ $*
315 " language specific {{{2
316 set isfname-== " don't treat `=` as being part of filenames
319 set virtualedit+=block " let cursor move past last char in <C-V> mode
320 set virtualedit+=onemore " allow the cursor to move just past the end of the line
321 set viminfo='100,<50,s10,h,n$XDG_CACHE_HOME/vim/viminfo " viminfo defaults but save file in .cache
323 set viewdir=$XDG_CACHE_HOME/vim/view//
325 set sessionoptions+=unix,slash " damn windows and it's silly ways
328 " Resize splits when the window is resized {{{2
331 autocmd VimResized * :wincmd =
334 " Only show cursorline in the current window and in normal mode {{{2
337 au WinLeave,InsertEnter * set nocursorline
338 au WinEnter,InsertLeave * set cursorline
341 " Treat buffers from stdin (e.g.: echo foo | vim -) as scratch {{{2
344 au StdinReadPost * :set buftype=nofile
347 " Jump to last known cursor position {{{2
350 " blacklist certain filetype
351 let blacklist = ['gitcommit']
352 autocmd BufReadPost *
353 \ if index(blacklist, &ft) < 0 && line("'\"") > 1 && line("'\"") <= line("$") |
354 \ exe "normal! g`\"" |
358 " Check for file modifications automatically {{{2
359 " (current buffer only)
360 " Use :NoAutoChecktime to disable it (uses b:autochecktime)
361 fun! MyAutoCheckTime()
362 " only check timestamp for normal files
363 if &buftype != '' | return | endif
364 if ! exists('b:autochecktime') || b:autochecktime
366 let b:autochecktime = 1
369 augroup MyAutoChecktime
371 au FocusGained,BufEnter,CursorHold,InsertEnter * call MyAutoCheckTime()
373 command! NoAutoChecktime let b:autochecktime=0
374 command! ToggleAutoChecktime let b:autochecktime=!get(b:, 'autochecktime', 0) | echom "b:autochecktime:" b:autochecktime
378 au TerminalOpen * if &buftype == 'terminal' | setlocal bufhidden=hide | endif
383 " allow both <space> and \ to be <leader>
389 if exists("b:make_dir")
390 let l:make_dir = "-C ".b:make_dir
391 elseif exists("g:make_dir")
392 let l:make_dir = "-C ".g:make_dir
395 let l:make_targets = ""
396 if exists("g:make_targets")
397 let l:make_targets = g:make_targets
399 execute "make! ".l:make_dir." ".l:make_targets
401 nnoremap <leader>r :call Make()<cr>
404 nnoremap <silent> <Leader>/ :silent nohl<CR>
407 nnoremap <leader>[ :tabprev<cr>
408 nnoremap <leader>] :tabnext<cr>
410 " paste from selection
411 nnoremap <leader>p* :silent! set paste<CR>"*p:set nopaste<CR>
412 " paste from clipboard
413 nnoremap <leader>p+ :silent! set paste<CR>"+p:set nopaste<CR>
415 " strip trailing whitespace
416 function! StripWhitespace(line1, line2, ...) " {{{2
417 let s_report = &report
419 let pattern = a:0 ? a:1 : '\s\+$'
420 let oldview = winsaveview()
421 exe 'keepjumps keeppatterns '.a:line1.','.a:line2.'substitute/'.pattern.'//e'
422 if oldview != winsaveview()
425 call winrestview(oldview)
426 let &report = s_report
428 command! -range=% -nargs=0 -bar Untrail keepjumps call StripWhitespace(<line1>,<line2>)
429 nnoremap <silent> <leader>ww :Untrail<CR>
432 vnoremap <leader>S y:execute @@<cr>:echo 'Sourced selection.'<cr>
433 nnoremap <leader>S ^vg_y:execute @@<cr>:echo 'Sourced line.'<cr>
435 " jump to last cursor position
438 " Select (charwise) the contents of the current line, excluding indentation.
443 \ :syntax sync fromstart<cr>
444 \ :AirlineRefresh<cr>
445 \ :call popup_clear(1)<cr>
449 " nnoremap <leader>r :silent !ranger %:h<cr>:redraw!<cr>
450 " nnoremap <leader>R :silent !ranger<cr>:redraw!<cr>
457 " display the number of matches for the last search
458 nmap <Leader># :%s:<C-R>/::gn<CR>
460 " center cursor after search and open folds
464 " same when jumping around
467 nnoremap <c-o> <c-o>zzzv
468 nnoremap <c-i> <c-i>zzzv
470 " Not using the default mappings of 'To line from top/bottom'
476 " Heresy, emacs insert bindings
477 inoremap <C-A> <Esc>I
478 inoremap <C-E> <Esc>A
479 cnoremap <C-A> <Home>
482 " proper movement when lines are wrapped
483 noremap <silent><expr> j (v:count == 0 ? 'gj' : 'j')
484 noremap <silent><expr> k (v:count == 0 ? 'gk' : 'k')
490 noremap <Right> <NOP>
492 inoremap <Down> <NOP>
493 inoremap <Left> <NOP>
494 inoremap <Right> <NOP>
496 cnoremap <Down> <NOP>
497 cnoremap <Left> <NOP>
498 cnoremap <Right> <NOP>
500 cnoremap <C-J> <Down>
501 cnoremap <C-H> <Left>
502 cnoremap <C-L> <Right>
504 " close all folds open fold in cursor
507 map <F1> :ls<CR>:b<space>
509 " move between windows (skip previewwindow)
510 nnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
511 nnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
512 tnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
513 tnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
515 "xterm mouse with middleclick paste
516 nnoremap <MiddleMouse> i<MiddleMouse>
517 vnoremap <MiddleMouse> s<MiddleMouse>
519 " fix legacy vi inconsistency
524 " allow repeat operator on visual
525 vnoremap . :normal .<CR>
527 " add line without changing position or leaving mode
528 noremap <silent> <Leader>o :set paste<CR>m`o<ESC>``:set nopaste<CR>
529 noremap <silent> <Leader>O :set paste<CR>m`O<ESC>``:set nopaste<CR>
531 " Don't use Ex mode, use Q for formatting
534 " break undo sequence before removing word
535 inoremap <C-W> <C-G>u<C-W>
537 nnoremap coe :set <C-R>=&expandtab ? 'noexpandtab' : 'expandtab'<CR><CR>
538 nnoremap [oe :set expandtab<CR>
539 nnoremap ]oe :set noexpandtab<CR>
541 for idt in range(1,8)
542 exe 'nnoremap co'.idt.' :setlocal tabstop='.idt.' shiftwidth='.idt.' softtabstop='.idt.'<CR>'
545 " toggle auto format of text
546 nnoremap coa :set <C-R>=&formatoptions =~ "a" ? 'formatoptions-=a' : 'formatoptions+=a'<CR><CR>
547 nnoremap [oa :set formatoptions+=a<CR>
548 nnoremap ]oa :set formatoptions-=a<CR>
550 " space will toggle current fold in normal mode
551 nnoremap <leader><Space> za
552 " create folds around visual selection
553 vnoremap <leader><Space> zf
556 cabbrev w!! SudoWrite
558 " uppercase previous word
559 inoremap <C-C> <Esc>gUiwgi
561 " http://git.io/v3ZeU
562 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>
564 " plugins options {{{1
566 let g:airline#extensions#whitespace#enabled = 1
567 let g:airline#extensions#tabline#enabled = 1
568 let g:airline_powerline_fonts = 1
571 let g:checkattach_filebrowser = 'ranger'
572 let g:checkattach_once = 'y'
575 let delimitMate_expand_cr = 2
576 let g:delimitMate_expand_space = 1
579 nnoremap <silent> <Leader>ff :FSHere<CR>
580 nnoremap <silent> <Leader>fl :FSRight<CR>
581 nnoremap <silent> <Leader>fh :FSLeft<CR>
582 nnoremap <silent> <Leader>fj :FSBelow<CR>
583 nnoremap <silent> <Leader>fk :FSAbove<CR>
584 nnoremap <silent> <Leader>fL :FSSplitRight<CR>
585 nnoremap <silent> <Leader>fH :FSSplitLeft<CR>
586 nnoremap <silent> <Leader>fJ :FSSplitBelow<CR>
587 nnoremap <silent> <Leader>fK :FSSplitAbove<CR>
590 nmap <silent> <leader>dd :tab split \| Gdiff \| wincmd h<CR>
591 " delete fugitive buffers when closed
592 autocmd BufReadPost fugitive://* set bufhidden=delete
594 nnoremap <silent> <leader>gs :Git<CR>
595 nnoremap <silent> <leader>gd :Gdiffsplit<CR>
596 nnoremap <silent> <leader>gc :echohl WarningMsg \| echo "use \<leader>gcc instead" \| echohl None<CR>
597 nnoremap <silent> <leader>gcc :tab G commit -v<CR>
598 nnoremap <silent> <leader>gca :tab G commit -v --amend<CR>
599 nnoremap <leader>gcf :tab G commit -v --fixup=
600 nnoremap <silent> <leader>gp :echohl WarningMsg \| echo "use \<leader>gpp instead" \| echohl None<CR>
601 nnoremap <silent> <leader>gpp :G push<CR>
602 nnoremap <silent> <leader>gpf :G push --force-with-lease<CR>
603 nnoremap <silent> <leader>ga :Gwrite<cr>
604 nnoremap <silent> <leader>gb :G blame<cr>
606 augroup fugitive_gstatus
608 autocmd BufWinEnter */.git/index resize 16
612 nnoremap <F7> :GundoToggle<CR>
615 let g:indent_guides_default_mapping = 0
616 let g:indent_guides_guide_size = 1
617 nmap <silent> cog <Plug>IndentGuidesToggle
618 nmap <silent> [og <Plug>IndentGuidesEnable
619 nmap <silent> ]og <Plug>IndentGuidesDisable
621 " close-another-window {{{2
622 nnoremap <silent> <C-W>c <NOP>
623 nnoremap <silent> <C-W>cc <C-W>c
624 nnoremap <silent> <C-W>ch :CloseLeftWindow<CR>
625 nnoremap <silent> <C-W>cl :CloseRightWindow<CR>
626 nnoremap <silent> <C-W>cj :CloseBelowWindow<CR>
627 nnoremap <silent> <C-W>ck :CloseAboveWindow<CR>
631 let g:pymode_rope_completion = 0
632 let g:pymode_rope = 0
634 let g:pymode_folding = 1
635 let g:pymode_lint_ignore = "E221,E266,E501"
636 let g:pymode_lint_cwindow = 0 " don't open cwindow when linting
637 let g:pymode_syntax_space_errors = 0 " don't bother me when I'm typing
640 " disable '[ mappings
642 let g:SignatureMap = {
643 \ 'GotoNextLineAlpha' : "",
644 \ 'GotoPrevLineAlpha' : "",
645 \ 'GotoNextSpotAlpha' : "",
646 \ 'GotoPrevSpotAlpha' : "",
650 let g:switch_mapping = "<Leader>s"
653 nmap <silent> z] <Plug>(SpellRotateForward)
654 nmap <silent> z[ <Plug>(SpellRotateBackward)
655 vmap <silent> z] <Plug>(SpellRotateForwardV)
656 vmap <silent> z[ <Plug>(SpellRotateBackwardV)
659 let g:syntastic_enable_highlighting = 0
660 let g:syntastic_error_symbol='E'
661 let g:syntastic_style_error_symbol='S'
662 let g:syntastic_warning_symbol='W'
663 let g:syntastic_style_warning_symbol='S'
664 let g:syntastic_always_populate_loc_list=1
665 nmap <silent> <leader>y :SyntasticCheck<cr>
667 let g:syntastic_cpp_clang_tidy_post_args = "-p build*"
670 let g:syntastic_check_on_open=1
674 map <F5> :TagbarToggle<cr>
675 let g:tagbar_sort = 0
676 let g:tagbar_compact = 1
677 let g:tagbar_autoshowtag = 1
678 let g:tagbar_width = 25
679 let g:tagbar_iconchars = ['+', '-']
682 let g:tcomment_textobject_inlinecomment = 'gic'
683 let g:tcomment#filetype#guess = 0
686 let g:UltiSnipsEditSplit = 'vertical'
687 let g:UltiSnipsSnippetDirectories = [ expand("$XDG_CONFIG_HOME/vim/ultisnips") ]
689 let g:UltiSnipsSnippetDirectories = ["UltiSnips", "ultisnips"]
691 let g:UltiSnipsExpandTrigger = "<tab>"
692 let g:UltiSnipsJumpForwardTrigger = "<tab>"
693 let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
695 " UltiSnips completion function that tries to expand a snippet. If there's no
696 " snippet for expanding, it checks for completion window and if it's shown,
697 " selects first element. If there's no completion window it tries to jump to
698 " next placeholder. If there's no placeholder it just returns TAB key
699 " https://github.com/Valloric/YouCompleteMe/issues/36#issuecomment-15451411
700 function! g:UltiSnips_Complete()
701 call UltiSnips#ExpandSnippet()
702 if g:ulti_expand_res == 0
706 call UltiSnips#JumpForwards()
707 if g:ulti_jump_forwards_res == 0
714 au InsertEnter * exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=g:UltiSnips_Complete()<cr>"
715 let g:UltiSnipsListSnippets="<c-e>"
718 call unite#filters#matcher_default#use(['matcher_fuzzy'])
719 call unite#custom#profile('default', 'context', {
721 \ 'direction': 'botright'
724 nnoremap [unite] <Nop>
725 nmap <leader>u [unite]
726 nnoremap [unite]u :UniteResume<CR>
727 nnoremap <silent> [u :UnitePrevious<CR>
728 nnoremap <silent> ]u :UniteNext<CR>
731 " seems not respected
732 let g:unite_source_grep_max_candidates = 2000
734 " Use ag in unite grep source.
735 let g:unite_source_grep_command = 'ag'
736 let g:unite_source_grep_default_opts = '--smart-case --vimgrep --ignore ''.hg'' --ignore ''.svn'' --ignore ''.git'' --ignore ''.bzr'''
737 let g:unite_source_grep_recursive_opt = ''
739 nnoremap <silent> [unite]a :<C-u>Unite grep:.::
\12\17<CR>
740 nnoremap <silent> [unite]A :<C-u>Unite grep:.:-w:
\12\17<CR>
741 command! -nargs=+ Ag Unite -input=<args> grep:.:
743 " unite-file_rec {{{3
745 " Use ag in unite rec source
746 let g:unite_source_rec_async_command = ['ag', '--follow', '--nocolor', '--nogroup', '-g', '']
748 nnoremap <silent> [unite]f :<C-u>Unite -start-insert file_rec/async<CR>
749 call unite#custom#source('file_rec/async', 'sorters', 'sorter_selecta')
752 call unite#custom#default_action('buffer', 'open')
753 nnoremap <silent> [unite]b :<C-u>Unite buffer:-<CR>
755 " unite-jumplist {{{3
756 nnoremap <silent> [unite]j :<C-u>Unite output:jumps:<CR>
759 let g:unite_source_menu_menus = {}
760 let g:unite_source_menu_menus.fugitive = { 'description' : 'fugitive menu'}
761 let g:unite_source_menu_menus.fugitive.command_candidates = {
762 \ 'Gstatus <Leader>gs' : 'Gstatus',
763 \ 'Gcommit -v <Leader>gc' : 'Gcommit -v',
767 nnoremap <silent> <leader>gg :<C-u>Unite menu:fugitive<CR>
769 let g:unite_source_history_yank_enable = 1
770 nnoremap <silent> [unite]p :<C-u>Unite history/yank<CR>
773 nnoremap <silent> <leader>p :YRShow<cr>
774 let g:yankring_history_dir = expand('$XDG_CACHE_HOME/vim')
775 let g:yankring_replace_n_pkey = ''
776 let g:yankring_replace_n_nkey = ''
778 " map Y to y$ for the yank ring
779 function! YRRunAfterMaps()
780 nnoremap Y :<C-U>YRYankCount 'y$'<CR>
784 let g:ycm_clangd_binary_path = 'clangd' " use clangd in path
785 let g:ycm_clangd_args = ['--clang-tidy']
786 let g:ycm_extra_conf_vim_data = ['getcwd()']
787 let g:ycm_add_preview_to_completeopt = 1
788 let g:ycm_complete_in_comments = 1
789 let g:ycm_complete_in_strings = 1
790 let g:ycm_autoclose_preview_window_after_insertion = 0
792 " vim-easy-align {{{2
793 " start interactive EasyAlign in visual mode
794 vmap <Enter> <Plug>(EasyAlign)
795 nmap ga <Plug>(EasyAlign)
798 let g:gtest#highlight_failing_tests = 0
800 nnoremap <silent> <Leader>tt :GTestRun<CR>
801 nnoremap <Leader>tc :GTestCase<space>
802 nnoremap <Leader>tn :GTestName<space>
803 nnoremap <silent> <Leader>ta :GTestCase *<CR>:GTestName *<CR>:GTestRun<CR>
804 nnoremap <silent> <Leader>tu :GTestRunUnderCursor<CR>
807 let g:vim_json_syntax_conceal = 0
810 let g:sneak#streak = 1
811 let g:sneak#target_labels = "aoeuisnthdpylrcgfqjkxzmwvz" " dvorak
812 let g:sneak#use_ic_scs = 1 " follow 'ignorecase' and 'smartcase'
830 " Convenient command to see the difference between the current buffer and the
831 " file it was loaded from, thus the changes you made.
832 " Only define it when not defined already.
833 if !exists(":DiffOrig")
834 command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
835 \ | wincmd p | diffthis
839 function! SortLinesOpFunc(...)
842 nnoremap <silent> gs :<C-U>set operatorfunc=SortLinesOpFunc<CR>g@
843 vnoremap <silent> gs :sort<cr>
846 function! EditConfig(what, ext = '.vim')
847 let l:dir = split(&runtimepath,',')[0]
849 let l:file = expand($MYVIMRC)
850 elseif ! isdirectory(globpath(l:dir, a:what))
851 echoe a:what." is not valid!"
852 elseif empty(&filetype)
853 echoe 'filetype is empty!'
855 let l:file = l:dir.'/'.a:what.'/'.&filetype.a:ext
858 execute ':vsplit '.file
861 nmap <leader>ev :call EditConfig('vimrc')<CR>
862 nmap <leader>ef :call EditConfig('ftplugin')<CR>
863 nmap <leader>es :call EditConfig('syntax')<CR>
864 nmap <leader>ei :call EditConfig('indent')<CR>
865 nmap <leader>eu :call EditConfig('ultisnips', '.snippets')<CR>
868 " http://tex.stackexchange.com/a/52932
869 let g:myLangList=["en_gb","en_us","de","fr"]
871 function! ToggleSpell()
872 if !exists("b:myLang")
875 execute "setlocal spell!"
877 echo "setlocal spelllang=" g:myLangList[b:myLang]
881 function! SwitchSpell()
882 if !exists("b:myLang")
886 let b:myLang=b:myLang+1
887 if b:myLang>=len(g:myLangList) | let b:myLang=0 | endif
889 execute "setlocal spell spelllang=".get(g:myLangList, b:myLang)
890 echo "setlocal spelllang=" g:myLangList[b:myLang]
893 nnoremap <silent> coS :call SwitchSpell()<CR>
894 " fix spelling with first choice
895 nnoremap <Leader>f 1z=
897 " gitdir or home {{{2
899 " http://git.io/v3GAV
900 function! FindGitDirOrHome()
901 let filedir = expand('%:p:h')
902 if isdirectory(filedir)
903 let cmd = 'bash -c "(cd ' . filedir . '; git rev-parse --show-toplevel 2>/dev/null)"'
904 let gitdir = system(cmd)
905 if strlen(gitdir) == 0
915 command! Cdr execute('cd ' . FindGitDirOrHome())
917 command! LCdr execute('lcd ' . FindGitDirOrHome())
919 " vim:set et sw=2 ts=2 tw=78: