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
117 Plug 'vim-utils/vim-man' " {{{2
123 filetype plugin indent on
131 " moving around, searching and patterns {{{2
132 set incsearch " show match for partly typed search command
133 set ignorecase " ignore case when using a search pattern
134 set smartcase " override 'ignorecase' when pattern has upper case characters
135 set hlsearch " highlight all matches for the last used search pattern
137 set nostartofline " don't move the cursor to the first non-blank char of a line
140 set path+=../include/
141 set path+=/usr/include/c++/*
143 " displaying text {{{2
144 set nowrap " long lines wrap
145 set linebreak " wrap long lines at a character in 'breakat'
146 set showbreak=↪ " show these chars for wrapped lines
147 set breakindent " preserve indentation in wrapped text
149 set lazyredraw " don't redraw while executing macros
151 set list " show chars defined in 'listchars'
152 set listchars=tab:❭\ " list of strings used for list mode
153 set listchars+=extends:❯,precedes:❮
154 " Only shown when not in insert mode
155 set listchars+=trail:·
158 au InsertEnter * :set listchars-=trail:·
159 au InsertLeave * :set listchars+=trail:·
162 set scrolloff=5 " number of screen lines to show around the cursor
163 set sidescroll=1 " number of collumns to scroll
164 set sidescrolloff=1 " don't scroll over the listchars
166 set fillchars=diff:⣿,vert:│
168 set nonumber " show the line number for each line
169 set norelativenumber " show the relative line number for each line
171 " syntax, highlighting and spelling {{{2
172 set synmaxcol=800 " don't highlight long lines
174 set dictionary=spell " list of dictionary files for keyword completion
178 " multiple windows {{{2
179 set laststatus=2 " 0, 1 or 2; when to use a status line for the last window
181 set previewheight=20 " default height for the preview window
185 " set splitbelow " a new window is put below of the current one
186 set splitright " a new window is put right of the current one
191 " using the mouse {{{2
192 set mouse=rnv " list of flags for using the mouse
193 set ttymouse=xterm " type of mouse
195 " messages and info {{{2
196 set showcmd " Show (partial) command in status line.
197 set ruler " show the cursor position all the time
198 set confirm " Ask what to do when closing unsaved documents
199 set shortmess= " reset option
200 set shortmess+=a " all abbreviations
201 set shortmess+=o " overwrite file-written message
202 set shortmess+=O " file-read message overrides previous
203 set shortmess+=t " truncate file message at start
204 set shortmess+=T " truncate other messages in the middle
205 set shortmess+=W " don't give 'written' or '[w]' when writing a file
206 set shortmess+=A " ignore swapfile warning
207 set shortmess+=I " no splash screen
210 set backspace=indent,eol,start " allow backspacing over everything in insert mode
212 set showmatch " Show matching brackets.
214 set nojoinspaces " don't use two spaces after '.' when joining a line
215 set formatoptions+=j " Delete comment leader when joining lines
216 set formatoptions+=c " Autowrap comments using textwidth
217 set formatoptions+=r " Insert comment leader after hitting <Enter>
218 set formatoptions+=n " Recognize numbered lists
219 set formatoptions+=q " Allow formatting of comments with "gq".
220 set formatoptions+=l " do not wrap lines that have been longer when starting insert mode already
221 set formatoptions+=t " Auto-wrap text using textwidth
222 set formatoptions-=o " Do not insert comment leader after hitting o or O in normal mode
224 set nrformats=hex " number formats recognized for CTRL-A and CTRL-X commands
226 set complete=. " scan the current buffer ( 'wrapscan' is ignored)
227 set complete+=w " scan buffers from other windows
228 set complete+=b " scan other loaded buffers that are in the buffer list
229 set complete+=u " scan the unloaded buffers that are in the buffer list
230 set complete+=t " scan tags
231 set complete+=i " scan current and included files
232 set complete+=kspell " use the currently active spell checking |spell|
234 " whether to use a popup menu for Insert mode completion
235 set completeopt=longest,menuone,preview
237 " tabs and indent {{{2
238 set shiftwidth=4 " number of spaces used for each step of (auto)indent
239 set smarttab " a <Tab> in an indent inserts 'shiftwidth' spaces
240 set softtabstop=4 " if non-zero, number of spaces to insert for a <Tab>
241 set shiftround " round to 'shiftwidth' for "<<" and ">>"
242 set expandtab " expand <Tab> to spaces in Insert mode
245 set pastetoggle=<F11> " key sequence to toggle paste mode
248 set foldmethod=marker " folding type
249 set foldlevelstart=0 " value for 'foldlevel' when starting to edit a file
251 " open folds when jumping to line
254 set viewoptions=cursor " save cursor position
255 set viewoptions+=folds " save folds
258 set diffopt+=filler " show filler lines
259 set diffopt+=vertical " always vertical split
260 set diffopt+=context:10 " 10 lines context between changes
262 " reading and writing files {{{2
263 set modeline " read modelines
264 set modelines=2 " only check first/last 2 lines
266 set writebackup " write a backup file before overwriting a file
267 set backup " keep a backup after owerwriting a file
268 set backupdir=$XDG_CACHE_HOME/vim/backup//
270 set backupskip+=.netrc " skip netrc
271 set backupskip+=/dev/shm/pass* " skip passwordstore files
273 set undofile " persistent undo history
274 set undodir=$XDG_CACHE_HOME/vim/undo//
278 au BufWritePre .netrc setlocal noundofile
279 au BufWritePre /dev/shm/pass* setlocal noundofile
280 au BufWritePre /tmp/* setlocal noundofile
283 set autowrite " automatically write a file when leaving a modified buffer
284 set autoread " automatically read a file that has been modified
288 set directory=$XDG_CACHE_HOME/vim/swap//
290 " command line editing {{{2
291 set history=5000 " how many command lines are remembered
292 set wildmenu " command-line completion shows a list of matches
293 set wildmode=longest:full,full " specifies how command line completion works
294 set wildignorecase " ignore case when completing file names
296 set wildignore+=.hg,.git,.svn " Version control
297 set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
298 set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
299 set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
300 set wildignore+=*.spl " compiled spelling word lists
301 set wildignore+=*.sw? " Vim swap files
302 set wildignore+=*.luac " Lua byte code
303 set wildignore+=*.pyc " Python byte code
304 set wildignore+=*.orig " Merge resolution files
306 " running make and jumping to errors {{{2
307 set makeprg=make\ -w " print changing directories
309 set grepprg=ag\ --vimgrep\ $*
311 " language specific {{{2
312 set isfname-== " don't treat `=` as being part of filenames
315 set virtualedit+=block " let cursor move past last char in <C-V> mode
316 set virtualedit+=onemore " allow the cursor to move just past the end of the line
317 set viminfo='100,<50,s10,h,n$XDG_CACHE_HOME/vim/viminfo " viminfo defaults but save file in .cache
319 set viewdir=$XDG_CACHE_HOME/vim/view//
321 set sessionoptions+=unix,slash " damn windows and it's silly ways
324 " Resize splits when the window is resized {{{2
327 autocmd VimResized * :wincmd =
330 " Only show cursorline in the current window and in normal mode {{{2
333 au WinLeave,InsertEnter * set nocursorline
334 au WinEnter,InsertLeave * set cursorline
337 " Treat buffers from stdin (e.g.: echo foo | vim -) as scratch {{{2
340 au StdinReadPost * :set buftype=nofile
343 " Jump to last known cursor position {{{2
346 " blacklist certain filetype
347 let blacklist = ['gitcommit']
348 autocmd BufReadPost *
349 \ if index(blacklist, &ft) < 0 && line("'\"") > 1 && line("'\"") <= line("$") |
350 \ exe "normal! g`\"" |
354 " Check for file modifications automatically {{{2
355 " (current buffer only)
356 " Use :NoAutoChecktime to disable it (uses b:autochecktime)
357 fun! MyAutoCheckTime()
358 " only check timestamp for normal files
359 if &buftype != '' | return | endif
360 if ! exists('b:autochecktime') || b:autochecktime
362 let b:autochecktime = 1
365 augroup MyAutoChecktime
367 au FocusGained,BufEnter,CursorHold,InsertEnter * call MyAutoCheckTime()
369 command! NoAutoChecktime let b:autochecktime=0
370 command! ToggleAutoChecktime let b:autochecktime=!get(b:, 'autochecktime', 0) | echom "b:autochecktime:" b:autochecktime
374 au TerminalOpen * if &buftype == 'terminal' | setlocal bufhidden=hide | endif
379 " allow both <space> and \ to be <leader>
385 if exists("b:make_dir")
386 let l:make_dir = "-C ".b:make_dir
387 elseif exists("g:make_dir")
388 let l:make_dir = "-C ".g:make_dir
391 let l:make_targets = ""
392 if exists("g:make_targets")
393 let l:make_targets = g:make_targets
395 execute "make! ".l:make_dir." ".l:make_targets
397 nnoremap <leader>r :call Make()<cr>
400 nnoremap <silent> <Leader>/ :silent nohl<CR>
403 nnoremap <leader>[ :tabprev<cr>
404 nnoremap <leader>] :tabnext<cr>
406 " paste from selection
407 nnoremap <leader>p* :silent! set paste<CR>"*p:set nopaste<CR>
408 " paste from clipboard
409 nnoremap <leader>p+ :silent! set paste<CR>"+p:set nopaste<CR>
411 " strip trailing whitespace
412 function! StripWhitespace(line1, line2, ...) " {{{2
413 let s_report = &report
415 let pattern = a:0 ? a:1 : '\s\+$'
416 let oldview = winsaveview()
417 exe 'keepjumps keeppatterns '.a:line1.','.a:line2.'substitute/'.pattern.'//e'
418 if oldview != winsaveview()
421 call winrestview(oldview)
422 let &report = s_report
424 command! -range=% -nargs=0 -bar Untrail keepjumps call StripWhitespace(<line1>,<line2>)
425 nnoremap <silent> <leader>ww :Untrail<CR>
428 vnoremap <leader>S y:execute @@<cr>:echo 'Sourced selection.'<cr>
429 nnoremap <leader>S ^vg_y:execute @@<cr>:echo 'Sourced line.'<cr>
431 " jump to last cursor position
434 " Select (charwise) the contents of the current line, excluding indentation.
439 \ :syntax sync fromstart<cr>
440 \ :AirlineRefresh<cr>
441 \ :call popup_clear(1)<cr>
445 " nnoremap <leader>r :silent !ranger %:h<cr>:redraw!<cr>
446 " nnoremap <leader>R :silent !ranger<cr>:redraw!<cr>
453 " display the number of matches for the last search
454 nmap <Leader># :%s:<C-R>/::gn<CR>
456 " center cursor after search and open folds
460 " same when jumping around
463 nnoremap <c-o> <c-o>zzzv
464 nnoremap <c-i> <c-i>zzzv
466 " Not using the default mappings of 'To line from top/bottom'
472 " Heresy, emacs insert bindings
473 inoremap <C-A> <Esc>I
474 inoremap <C-E> <Esc>A
475 cnoremap <C-A> <Home>
478 " proper movement when lines are wrapped
479 noremap <silent><expr> j (v:count == 0 ? 'gj' : 'j')
480 noremap <silent><expr> k (v:count == 0 ? 'gk' : 'k')
486 noremap <Right> <NOP>
488 inoremap <Down> <NOP>
489 inoremap <Left> <NOP>
490 inoremap <Right> <NOP>
492 cnoremap <Down> <NOP>
493 cnoremap <Left> <NOP>
494 cnoremap <Right> <NOP>
496 cnoremap <C-J> <Down>
497 cnoremap <C-H> <Left>
498 cnoremap <C-L> <Right>
500 " close all folds open fold in cursor
503 map <F1> :ls<CR>:b<space>
505 " move between windows (skip previewwindow)
506 nnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
507 nnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
508 tnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
509 tnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
511 "xterm mouse with middleclick paste
512 nnoremap <MiddleMouse> i<MiddleMouse>
513 vnoremap <MiddleMouse> s<MiddleMouse>
515 " fix legacy vi inconsistency
520 " allow repeat operator on visual
521 vnoremap . :normal .<CR>
523 " add line without changing position or leaving mode
524 noremap <silent> <Leader>o :set paste<CR>m`o<ESC>``:set nopaste<CR>
525 noremap <silent> <Leader>O :set paste<CR>m`O<ESC>``:set nopaste<CR>
527 " Don't use Ex mode, use Q for formatting
530 " break undo sequence before removing word
531 inoremap <C-W> <C-G>u<C-W>
533 nnoremap coe :set <C-R>=&expandtab ? 'noexpandtab' : 'expandtab'<CR><CR>
534 nnoremap [oe :set expandtab<CR>
535 nnoremap ]oe :set noexpandtab<CR>
537 for idt in range(1,8)
538 exe 'nnoremap co'.idt.' :setlocal tabstop='.idt.' shiftwidth='.idt.' softtabstop='.idt.'<CR>'
541 " toggle auto format of text
542 nnoremap coa :set <C-R>=&formatoptions =~ "a" ? 'formatoptions-=a' : 'formatoptions+=a'<CR><CR>
543 nnoremap [oa :set formatoptions+=a<CR>
544 nnoremap ]oa :set formatoptions-=a<CR>
546 " space will toggle current fold in normal mode
547 nnoremap <leader><Space> za
548 " create folds around visual selection
549 vnoremap <leader><Space> zf
552 cabbrev w!! SudoWrite
554 " uppercase previous word
555 inoremap <C-C> <Esc>gUiwgi
557 " http://git.io/v3ZeU
558 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>
560 " plugins options {{{1
562 let g:airline#extensions#whitespace#enabled = 1
563 let g:airline#extensions#tabline#enabled = 1
564 let g:airline_powerline_fonts = 1
567 let g:checkattach_filebrowser = 'ranger'
568 let g:checkattach_once = 'y'
571 let delimitMate_expand_cr = 2
572 let g:delimitMate_expand_space = 1
575 nnoremap <silent> <Leader>ff :FSHere<CR>
576 nnoremap <silent> <Leader>fl :FSRight<CR>
577 nnoremap <silent> <Leader>fh :FSLeft<CR>
578 nnoremap <silent> <Leader>fj :FSBelow<CR>
579 nnoremap <silent> <Leader>fk :FSAbove<CR>
580 nnoremap <silent> <Leader>fL :FSSplitRight<CR>
581 nnoremap <silent> <Leader>fH :FSSplitLeft<CR>
582 nnoremap <silent> <Leader>fJ :FSSplitBelow<CR>
583 nnoremap <silent> <Leader>fK :FSSplitAbove<CR>
586 nmap <silent> <leader>dd :tab split \| Gdiff \| wincmd h<CR>
587 " delete fugitive buffers when closed
588 autocmd BufReadPost fugitive://* set bufhidden=delete
590 nnoremap <silent> <leader>gs :Git<CR>
591 nnoremap <silent> <leader>gd :Gdiffsplit<CR>
592 nnoremap <silent> <leader>gc :echohl WarningMsg \| echo "use \<leader>gcc instead" \| echohl None<CR>
593 nnoremap <silent> <leader>gcc :tab G commit -v<CR>
594 nnoremap <silent> <leader>gca :tab G commit -v --amend<CR>
595 nnoremap <leader>gcf :tab G commit -v --fixup=
596 nnoremap <silent> <leader>gp :echohl WarningMsg \| echo "use \<leader>gpp instead" \| echohl None<CR>
597 nnoremap <silent> <leader>gpp :G push<CR>
598 nnoremap <silent> <leader>gpf :G push --force-with-lease<CR>
599 nnoremap <silent> <leader>ga :Gwrite<cr>
600 nnoremap <silent> <leader>gb :G blame<cr>
602 augroup fugitive_gstatus
604 autocmd BufWinEnter */.git/index resize 16
608 nnoremap <F7> :GundoToggle<CR>
611 let g:indent_guides_default_mapping = 0
612 let g:indent_guides_guide_size = 1
613 nmap <silent> cog <Plug>IndentGuidesToggle
614 nmap <silent> [og <Plug>IndentGuidesEnable
615 nmap <silent> ]og <Plug>IndentGuidesDisable
617 " close-another-window {{{2
618 nnoremap <silent> <C-W>c <NOP>
619 nnoremap <silent> <C-W>cc <C-W>c
620 nnoremap <silent> <C-W>ch :CloseLeftWindow<CR>
621 nnoremap <silent> <C-W>cl :CloseRightWindow<CR>
622 nnoremap <silent> <C-W>cj :CloseBelowWindow<CR>
623 nnoremap <silent> <C-W>ck :CloseAboveWindow<CR>
627 let g:pymode_rope_completion = 0
628 let g:pymode_rope = 0
630 let g:pymode_folding = 1
631 let g:pymode_lint_ignore = "E221,E266,E501"
632 let g:pymode_lint_cwindow = 0 " don't open cwindow when linting
633 let g:pymode_syntax_space_errors = 0 " don't bother me when I'm typing
636 " disable '[ mappings
638 let g:SignatureMap = {
639 \ 'GotoNextLineAlpha' : "",
640 \ 'GotoPrevLineAlpha' : "",
641 \ 'GotoNextSpotAlpha' : "",
642 \ 'GotoPrevSpotAlpha' : "",
646 let g:switch_mapping = "<Leader>s"
649 nmap <silent> z] <Plug>(SpellRotateForward)
650 nmap <silent> z[ <Plug>(SpellRotateBackward)
651 vmap <silent> z] <Plug>(SpellRotateForwardV)
652 vmap <silent> z[ <Plug>(SpellRotateBackwardV)
655 let g:syntastic_enable_highlighting = 0
656 let g:syntastic_error_symbol='E'
657 let g:syntastic_style_error_symbol='S'
658 let g:syntastic_warning_symbol='W'
659 let g:syntastic_style_warning_symbol='S'
660 let g:syntastic_always_populate_loc_list=1
661 nmap <silent> <leader>y :SyntasticCheck<cr>
663 let g:syntastic_cpp_clang_tidy_post_args = "-p build*"
666 let g:syntastic_check_on_open=1
670 map <F5> :TagbarToggle<cr>
671 let g:tagbar_sort = 0
672 let g:tagbar_compact = 1
673 let g:tagbar_autoshowtag = 1
674 let g:tagbar_width = 25
675 let g:tagbar_iconchars = ['+', '-']
678 let g:tcomment_textobject_inlinecomment = 'gic'
679 let g:tcomment#filetype#guess = 0
682 let g:UltiSnipsEditSplit = 'vertical'
683 let g:UltiSnipsSnippetDirectories = [ expand("$XDG_CONFIG_HOME/vim/ultisnips") ]
685 let g:UltiSnipsSnippetDirectories = ["UltiSnips", "ultisnips"]
687 let g:UltiSnipsExpandTrigger = "<tab>"
688 let g:UltiSnipsJumpForwardTrigger = "<tab>"
689 let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
691 " UltiSnips completion function that tries to expand a snippet. If there's no
692 " snippet for expanding, it checks for completion window and if it's shown,
693 " selects first element. If there's no completion window it tries to jump to
694 " next placeholder. If there's no placeholder it just returns TAB key
695 " https://github.com/Valloric/YouCompleteMe/issues/36#issuecomment-15451411
696 function! g:UltiSnips_Complete()
697 call UltiSnips#ExpandSnippet()
698 if g:ulti_expand_res == 0
702 call UltiSnips#JumpForwards()
703 if g:ulti_jump_forwards_res == 0
710 au InsertEnter * exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=g:UltiSnips_Complete()<cr>"
711 let g:UltiSnipsListSnippets="<c-e>"
714 call unite#filters#matcher_default#use(['matcher_fuzzy'])
715 call unite#custom#profile('default', 'context', {
717 \ 'direction': 'botright'
720 nnoremap [unite] <Nop>
721 nmap <leader>u [unite]
722 nnoremap [unite]u :UniteResume<CR>
723 nnoremap <silent> [u :UnitePrevious<CR>
724 nnoremap <silent> ]u :UniteNext<CR>
727 " seems not respected
728 let g:unite_source_grep_max_candidates = 2000
730 " Use ag in unite grep source.
731 let g:unite_source_grep_command = 'ag'
732 let g:unite_source_grep_default_opts = '--smart-case --vimgrep --ignore ''.hg'' --ignore ''.svn'' --ignore ''.git'' --ignore ''.bzr'''
733 let g:unite_source_grep_recursive_opt = ''
735 nnoremap <silent> [unite]a :<C-u>Unite grep:.::
\12\17<CR>
736 nnoremap <silent> [unite]A :<C-u>Unite grep:.:-w:
\12\17<CR>
737 command! -nargs=+ Ag Unite -input=<args> grep:.:
739 " unite-file_rec {{{3
741 " Use ag in unite rec source
742 let g:unite_source_rec_async_command = ['ag', '--follow', '--nocolor', '--nogroup', '-g', '']
744 nnoremap <silent> [unite]f :<C-u>Unite -start-insert file_rec/async<CR>
745 call unite#custom#source('file_rec/async', 'sorters', 'sorter_selecta')
748 call unite#custom#default_action('buffer', 'open')
749 nnoremap <silent> [unite]b :<C-u>Unite buffer:-<CR>
751 " unite-jumplist {{{3
752 nnoremap <silent> [unite]j :<C-u>Unite output:jumps:<CR>
755 let g:unite_source_menu_menus = {}
756 let g:unite_source_menu_menus.fugitive = { 'description' : 'fugitive menu'}
757 let g:unite_source_menu_menus.fugitive.command_candidates = {
758 \ 'Gstatus <Leader>gs' : 'Gstatus',
759 \ 'Gcommit -v <Leader>gc' : 'Gcommit -v',
763 nnoremap <silent> <leader>gg :<C-u>Unite menu:fugitive<CR>
765 let g:unite_source_history_yank_enable = 1
766 nnoremap <silent> [unite]p :<C-u>Unite history/yank<CR>
769 nnoremap <silent> <leader>p :YRShow<cr>
770 let g:yankring_history_dir = expand('$XDG_CACHE_HOME/vim')
771 let g:yankring_replace_n_pkey = ''
772 let g:yankring_replace_n_nkey = ''
774 " map Y to y$ for the yank ring
775 function! YRRunAfterMaps()
776 nnoremap Y :<C-U>YRYankCount 'y$'<CR>
780 let g:ycm_clangd_binary_path = 'clangd' " use clangd in path
781 let g:ycm_clangd_args = ['--clang-tidy']
782 let g:ycm_extra_conf_vim_data = ['getcwd()']
783 let g:ycm_add_preview_to_completeopt = 1
784 let g:ycm_complete_in_comments = 1
785 let g:ycm_complete_in_strings = 1
786 let g:ycm_autoclose_preview_window_after_insertion = 0
788 " vim-easy-align {{{2
789 " start interactive EasyAlign in visual mode
790 vmap <Enter> <Plug>(EasyAlign)
791 nmap ga <Plug>(EasyAlign)
794 let g:gtest#highlight_failing_tests = 0
796 nnoremap <silent> <Leader>tt :GTestRun<CR>
797 nnoremap <Leader>tc :GTestCase<space>
798 nnoremap <Leader>tn :GTestName<space>
799 nnoremap <silent> <Leader>ta :GTestCase *<CR>:GTestName *<CR>:GTestRun<CR>
800 nnoremap <silent> <Leader>tu :GTestRunUnderCursor<CR>
803 let g:vim_json_syntax_conceal = 0
806 let g:sneak#streak = 1
807 let g:sneak#target_labels = "aoeuisnthdpylrcgfqjkxzmwvz" " dvorak
808 let g:sneak#use_ic_scs = 1 " follow 'ignorecase' and 'smartcase'
826 " Convenient command to see the difference between the current buffer and the
827 " file it was loaded from, thus the changes you made.
828 " Only define it when not defined already.
829 if !exists(":DiffOrig")
830 command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
831 \ | wincmd p | diffthis
835 function! SortLinesOpFunc(...)
838 nnoremap <silent> gs :<C-U>set operatorfunc=SortLinesOpFunc<CR>g@
839 vnoremap <silent> gs :sort<cr>
842 function! EditConfig(what, ext = '.vim')
843 let l:dir = split(&runtimepath,',')[0]
845 let l:file = expand($MYVIMRC)
846 elseif ! isdirectory(globpath(l:dir, a:what))
847 echoe a:what." is not valid!"
848 elseif empty(&filetype)
849 echoe 'filetype is empty!'
851 let l:file = l:dir.'/'.a:what.'/'.&filetype.a:ext
854 execute ':vsplit '.file
857 nmap <leader>ev :call EditConfig('vimrc')<CR>
858 nmap <leader>ef :call EditConfig('ftplugin')<CR>
859 nmap <leader>es :call EditConfig('syntax')<CR>
860 nmap <leader>ei :call EditConfig('indent')<CR>
861 nmap <leader>eu :call EditConfig('ultisnips', '.snippets')<CR>
864 " http://tex.stackexchange.com/a/52932
865 let g:myLangList=["en_gb","en_us","de","fr"]
867 function! ToggleSpell()
868 if !exists("b:myLang")
871 execute "setlocal spell!"
873 echo "setlocal spelllang=" g:myLangList[b:myLang]
877 function! SwitchSpell()
878 if !exists("b:myLang")
882 let b:myLang=b:myLang+1
883 if b:myLang>=len(g:myLangList) | let b:myLang=0 | endif
885 execute "setlocal spell spelllang=".get(g:myLangList, b:myLang)
886 echo "setlocal spelllang=" g:myLangList[b:myLang]
889 nnoremap <silent> coS :call SwitchSpell()<CR>
890 " fix spelling with first choice
891 nnoremap <Leader>f 1z=
893 " gitdir or home {{{2
895 " http://git.io/v3GAV
896 function! FindGitDirOrHome()
897 let filedir = expand('%:p:h')
898 if isdirectory(filedir)
899 let cmd = 'bash -c "(cd ' . filedir . '; git rev-parse --show-toplevel 2>/dev/null)"'
900 let gitdir = system(cmd)
901 if strlen(gitdir) == 0
911 command! Cdr execute('cd ' . FindGitDirOrHome())
913 command! LCdr execute('lcd ' . FindGitDirOrHome())
915 " vim:set et sw=2 ts=2 tw=78: