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
119 filetype plugin indent on
127 " moving around, searching and patterns {{{2
128 set incsearch " show match for partly typed search command
129 set ignorecase " ignore case when using a search pattern
130 set smartcase " override 'ignorecase' when pattern has upper case characters
131 set hlsearch " highlight all matches for the last used search pattern
133 set nostartofline " don't move the cursor to the first non-blank char of a line
136 set path+=../include/
137 set path+=/usr/include/c++/*
139 " displaying text {{{2
140 set nowrap " long lines wrap
141 set linebreak " wrap long lines at a character in 'breakat'
142 set showbreak=↪ " show these chars for wrapped lines
143 set breakindent " preserve indentation in wrapped text
145 set lazyredraw " don't redraw while executing macros
147 set list " show chars defined in 'listchars'
148 set listchars=tab:❭\ " list of strings used for list mode
149 set listchars+=extends:❯,precedes:❮
150 " Only shown when not in insert mode
151 set listchars+=trail:·
154 au InsertEnter * :set listchars-=trail:·
155 au InsertLeave * :set listchars+=trail:·
158 set scrolloff=5 " number of screen lines to show around the cursor
159 set sidescroll=1 " number of collumns to scroll
160 set sidescrolloff=1 " don't scroll over the listchars
162 set fillchars=diff:⣿,vert:│
164 set nonumber " show the line number for each line
165 set norelativenumber " show the relative line number for each line
167 " syntax, highlighting and spelling {{{2
168 set synmaxcol=800 " don't highlight long lines
170 set dictionary=spell " list of dictionary files for keyword completion
174 " multiple windows {{{2
175 set laststatus=2 " 0, 1 or 2; when to use a status line for the last window
177 set previewheight=20 " default height for the preview window
181 " set splitbelow " a new window is put below of the current one
182 set splitright " a new window is put right of the current one
187 " using the mouse {{{2
188 set mouse=rnv " list of flags for using the mouse
189 set ttymouse=xterm " type of mouse
191 " messages and info {{{2
192 set showcmd " Show (partial) command in status line.
193 set ruler " show the cursor position all the time
194 set confirm " Ask what to do when closing unsaved documents
195 set shortmess= " reset option
196 set shortmess+=a " all abbreviations
197 set shortmess+=o " overwrite file-written message
198 set shortmess+=O " file-read message overrides previous
199 set shortmess+=t " truncate file message at start
200 set shortmess+=T " truncate other messages in the middle
201 set shortmess+=W " don't give 'written' or '[w]' when writing a file
202 set shortmess+=A " ignore swapfile warning
203 set shortmess+=I " no splash screen
206 set backspace=indent,eol,start " allow backspacing over everything in insert mode
208 set showmatch " Show matching brackets.
210 set nojoinspaces " don't use two spaces after '.' when joining a line
211 set formatoptions+=j " Delete comment leader when joining lines
212 set formatoptions+=c " Autowrap comments using textwidth
213 set formatoptions+=r " Insert comment leader after hitting <Enter>
214 set formatoptions+=n " Recognize numbered lists
215 set formatoptions+=q " Allow formatting of comments with "gq".
216 set formatoptions+=l " do not wrap lines that have been longer when starting insert mode already
217 set formatoptions+=t " Auto-wrap text using textwidth
218 set formatoptions-=o " Do not insert comment leader after hitting o or O in normal mode
220 set nrformats=hex " number formats recognized for CTRL-A and CTRL-X commands
222 set complete=. " scan the current buffer ( 'wrapscan' is ignored)
223 set complete+=w " scan buffers from other windows
224 set complete+=b " scan other loaded buffers that are in the buffer list
225 set complete+=u " scan the unloaded buffers that are in the buffer list
226 set complete+=t " scan tags
227 set complete+=i " scan current and included files
228 set complete+=kspell " use the currently active spell checking |spell|
230 " whether to use a popup menu for Insert mode completion
231 set completeopt=longest,menuone,preview
233 " tabs and indent {{{2
234 set shiftwidth=4 " number of spaces used for each step of (auto)indent
235 set smarttab " a <Tab> in an indent inserts 'shiftwidth' spaces
236 set softtabstop=4 " if non-zero, number of spaces to insert for a <Tab>
237 set shiftround " round to 'shiftwidth' for "<<" and ">>"
238 set expandtab " expand <Tab> to spaces in Insert mode
241 set pastetoggle=<F11> " key sequence to toggle paste mode
244 set foldmethod=marker " folding type
245 set foldlevelstart=0 " value for 'foldlevel' when starting to edit a file
247 " open folds when jumping to line
250 set viewoptions=cursor " save cursor position
251 set viewoptions+=folds " save folds
254 set diffopt+=filler " show filler lines
255 set diffopt+=vertical " always vertical split
256 set diffopt+=context:10 " 10 lines context between changes
258 " reading and writing files {{{2
259 set modeline " read modelines
260 set modelines=2 " only check first/last 2 lines
262 set writebackup " write a backup file before overwriting a file
263 set backup " keep a backup after owerwriting a file
264 set backupdir=$XDG_CACHE_HOME/vim/backup//
266 set backupskip+=.netrc " skip netrc
267 set backupskip+=/dev/shm/pass* " skip passwordstore files
269 set undofile " persistent undo history
270 set undodir=$XDG_CACHE_HOME/vim/undo//
274 au BufWritePre .netrc setlocal noundofile
275 au BufWritePre /dev/shm/pass* setlocal noundofile
276 au BufWritePre /tmp/* setlocal noundofile
279 set autowrite " automatically write a file when leaving a modified buffer
280 set autoread " automatically read a file that has been modified
284 set directory=$XDG_CACHE_HOME/vim/swap//
286 " command line editing {{{2
287 set history=5000 " how many command lines are remembered
288 set wildmenu " command-line completion shows a list of matches
289 set wildmode=longest:full,full " specifies how command line completion works
290 set wildignorecase " ignore case when completing file names
292 set wildignore+=.hg,.git,.svn " Version control
293 set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
294 set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
295 set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
296 set wildignore+=*.spl " compiled spelling word lists
297 set wildignore+=*.sw? " Vim swap files
298 set wildignore+=*.luac " Lua byte code
299 set wildignore+=*.pyc " Python byte code
300 set wildignore+=*.orig " Merge resolution files
302 " running make and jumping to errors {{{2
303 set makeprg=make\ -w " print changing directories
305 set grepprg=ag\ --vimgrep\ $*
307 " language specific {{{2
308 set isfname-== " don't treat `=` as being part of filenames
311 set virtualedit+=block " let cursor move past last char in <C-V> mode
312 set virtualedit+=onemore " allow the cursor to move just past the end of the line
313 set viminfo='100,<50,s10,h,n$XDG_CACHE_HOME/vim/viminfo " viminfo defaults but save file in .cache
315 set viewdir=$XDG_CACHE_HOME/vim/view//
317 set sessionoptions+=unix,slash " damn windows and it's silly ways
320 " Resize splits when the window is resized {{{2
323 autocmd VimResized * :wincmd =
326 " Only show cursorline in the current window and in normal mode {{{2
329 au WinLeave,InsertEnter * set nocursorline
330 au WinEnter,InsertLeave * set cursorline
333 " Treat buffers from stdin (e.g.: echo foo | vim -) as scratch {{{2
336 au StdinReadPost * :set buftype=nofile
339 " Jump to last known cursor position {{{2
342 " blacklist certain filetype
343 let blacklist = ['gitcommit']
344 autocmd BufReadPost *
345 \ if index(blacklist, &ft) < 0 && line("'\"") > 1 && line("'\"") <= line("$") |
346 \ exe "normal! g`\"" |
350 " Check for file modifications automatically {{{2
351 " (current buffer only)
352 " Use :NoAutoChecktime to disable it (uses b:autochecktime)
353 fun! MyAutoCheckTime()
354 " only check timestamp for normal files
355 if &buftype != '' | return | endif
356 if ! exists('b:autochecktime') || b:autochecktime
358 let b:autochecktime = 1
361 augroup MyAutoChecktime
363 au FocusGained,BufEnter,CursorHold,InsertEnter * call MyAutoCheckTime()
365 command! NoAutoChecktime let b:autochecktime=0
366 command! ToggleAutoChecktime let b:autochecktime=!get(b:, 'autochecktime', 0) | echom "b:autochecktime:" b:autochecktime
370 au TerminalOpen * if &buftype == 'terminal' | setlocal bufhidden=hide | endif
375 " allow both <space> and \ to be <leader>
381 if exists("b:make_dir")
382 let l:make_dir = "-C ".b:make_dir
383 elseif exists("g:make_dir")
384 let l:make_dir = "-C ".g:make_dir
387 let l:make_targets = ""
388 if exists("g:make_targets")
389 let l:make_targets = g:make_targets
391 execute "make! ".l:make_dir." ".l:make_targets
393 nnoremap <leader>r :call Make()<cr>
396 nnoremap <silent> <Leader>/ :silent nohl<CR>
399 nnoremap <leader>[ :tabprev<cr>
400 nnoremap <leader>] :tabnext<cr>
402 " paste from selection
403 nnoremap <leader>p* :silent! set paste<CR>"*p:set nopaste<CR>
404 " paste from clipboard
405 nnoremap <leader>p+ :silent! set paste<CR>"+p:set nopaste<CR>
407 " strip trailing whitespace
408 function! StripWhitespace(line1, line2, ...) " {{{2
409 let s_report = &report
411 let pattern = a:0 ? a:1 : '\s\+$'
412 let oldview = winsaveview()
413 exe 'keepjumps keeppatterns '.a:line1.','.a:line2.'substitute/'.pattern.'//e'
414 if oldview != winsaveview()
417 call winrestview(oldview)
418 let &report = s_report
420 command! -range=% -nargs=0 -bar Untrail keepjumps call StripWhitespace(<line1>,<line2>)
421 nnoremap <silent> <leader>ww :Untrail<CR>
424 vnoremap <leader>S y:execute @@<cr>:echo 'Sourced selection.'<cr>
425 nnoremap <leader>S ^vg_y:execute @@<cr>:echo 'Sourced line.'<cr>
427 " jump to last cursor position
430 " Select (charwise) the contents of the current line, excluding indentation.
434 nnoremap U :syntax sync fromstart<cr>:AirlineRefresh<cr>:redraw!<cr>
437 " nnoremap <leader>r :silent !ranger %:h<cr>:redraw!<cr>
438 " nnoremap <leader>R :silent !ranger<cr>:redraw!<cr>
445 " display the number of matches for the last search
446 nmap <Leader># :%s:<C-R>/::gn<CR>
448 " center cursor after search and open folds
452 " same when jumping around
455 nnoremap <c-o> <c-o>zzzv
456 nnoremap <c-i> <c-i>zzzv
458 " Not using the default mappings of 'To line from top/bottom'
464 " Heresy, emacs insert bindings
465 inoremap <C-A> <Esc>I
466 inoremap <C-E> <Esc>A
467 cnoremap <C-A> <Home>
470 " proper movement when lines are wrapped
471 noremap <silent><expr> j (v:count == 0 ? 'gj' : 'j')
472 noremap <silent><expr> k (v:count == 0 ? 'gk' : 'k')
478 noremap <Right> <NOP>
480 inoremap <Down> <NOP>
481 inoremap <Left> <NOP>
482 inoremap <Right> <NOP>
484 cnoremap <Down> <NOP>
485 cnoremap <Left> <NOP>
486 cnoremap <Right> <NOP>
488 cnoremap <C-J> <Down>
489 cnoremap <C-H> <Left>
490 cnoremap <C-L> <Right>
492 " close all folds open fold in cursor
495 map <F1> :ls<CR>:b<space>
497 " move between windows (skip previewwindow)
498 nnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
499 nnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
500 tnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
501 tnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
503 "xterm mouse with middleclick paste
504 nnoremap <MiddleMouse> i<MiddleMouse>
505 vnoremap <MiddleMouse> s<MiddleMouse>
507 " fix legacy vi inconsistency
512 " allow repeat operator on visual
513 vnoremap . :normal .<CR>
515 " add line without changing position or leaving mode
516 noremap <silent> <Leader>o :set paste<CR>m`o<ESC>``:set nopaste<CR>
517 noremap <silent> <Leader>O :set paste<CR>m`O<ESC>``:set nopaste<CR>
519 " Don't use Ex mode, use Q for formatting
522 " break undo sequence before removing word
523 inoremap <C-W> <C-G>u<C-W>
525 nnoremap coe :set <C-R>=&expandtab ? 'noexpandtab' : 'expandtab'<CR><CR>
526 nnoremap [oe :set expandtab<CR>
527 nnoremap ]oe :set noexpandtab<CR>
529 for idt in range(1,8)
530 exe 'nnoremap co'.idt.' :setlocal tabstop='.idt.' shiftwidth='.idt.' softtabstop='.idt.'<CR>'
533 " toggle auto format of text
534 nnoremap coa :set <C-R>=&formatoptions =~ "a" ? 'formatoptions-=a' : 'formatoptions+=a'<CR><CR>
535 nnoremap [oa :set formatoptions+=a<CR>
536 nnoremap ]oa :set formatoptions-=a<CR>
538 " space will toggle current fold in normal mode
539 nnoremap <leader><Space> za
540 " create folds around visual selection
541 vnoremap <leader><Space> zf
544 cabbrev w!! SudoWrite
546 " uppercase previous word
547 inoremap <C-C> <Esc>gUiwgi
549 " http://git.io/v3ZeU
550 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>
552 " plugins options {{{1
554 let g:airline#extensions#whitespace#enabled = 1
555 let g:airline#extensions#tabline#enabled = 1
556 let g:airline_powerline_fonts = 1
559 let g:checkattach_filebrowser = 'ranger'
560 let g:checkattach_once = 'y'
563 let delimitMate_expand_cr = 2
564 let g:delimitMate_expand_space = 1
567 nnoremap <silent> <Leader>ff :FSHere<CR>
568 nnoremap <silent> <Leader>fl :FSRight<CR>
569 nnoremap <silent> <Leader>fh :FSLeft<CR>
570 nnoremap <silent> <Leader>fj :FSBelow<CR>
571 nnoremap <silent> <Leader>fk :FSAbove<CR>
572 nnoremap <silent> <Leader>fL :FSSplitRight<CR>
573 nnoremap <silent> <Leader>fH :FSSplitLeft<CR>
574 nnoremap <silent> <Leader>fJ :FSSplitBelow<CR>
575 nnoremap <silent> <Leader>fK :FSSplitAbove<CR>
578 nmap <silent> <leader>dd :tab split \| Gdiff \| wincmd h<CR>
579 " delete fugitive buffers when closed
580 autocmd BufReadPost fugitive://* set bufhidden=delete
582 nnoremap <silent> <leader>gs :Git<CR>
583 nnoremap <silent> <leader>gd :Gdiffsplit<CR>
584 nnoremap <silent> <leader>gc :echohl WarningMsg \| echo "use \<leader>gcc instead" \| echohl None<CR>
585 nnoremap <silent> <leader>gcc :tab G commit -v<CR>
586 nnoremap <silent> <leader>gca :tab G commit -v --amend<CR>
587 nnoremap <leader>gcf :tab G commit -v --fixup=
588 nnoremap <silent> <leader>gp :echohl WarningMsg \| echo "use \<leader>gpp instead" \| echohl None<CR>
589 nnoremap <silent> <leader>gpp :G push<CR>
590 nnoremap <silent> <leader>gpf :G push --force-with-lease<CR>
591 nnoremap <silent> <leader>ga :Gwrite<cr>
592 nnoremap <silent> <leader>gb :G blame<cr>
594 augroup fugitive_gstatus
596 autocmd BufWinEnter */.git/index resize 16
600 nnoremap <F7> :GundoToggle<CR>
603 let g:indent_guides_default_mapping = 0
604 let g:indent_guides_guide_size = 1
605 nmap <silent> cog <Plug>IndentGuidesToggle
606 nmap <silent> [og <Plug>IndentGuidesEnable
607 nmap <silent> ]og <Plug>IndentGuidesDisable
609 " close-another-window {{{2
610 nnoremap <silent> <C-W>c <NOP>
611 nnoremap <silent> <C-W>cc <C-W>c
612 nnoremap <silent> <C-W>ch :CloseLeftWindow<CR>
613 nnoremap <silent> <C-W>cl :CloseRightWindow<CR>
614 nnoremap <silent> <C-W>cj :CloseBelowWindow<CR>
615 nnoremap <silent> <C-W>ck :CloseAboveWindow<CR>
619 let g:pymode_rope_completion = 0
620 let g:pymode_rope = 0
622 let g:pymode_folding = 1
623 let g:pymode_lint_ignore = "E221,E266,E501"
624 let g:pymode_lint_cwindow = 0 " don't open cwindow when linting
625 let g:pymode_syntax_space_errors = 0 " don't bother me when I'm typing
628 " disable '[ mappings
630 let g:SignatureMap = {
631 \ 'GotoNextLineAlpha' : "",
632 \ 'GotoPrevLineAlpha' : "",
633 \ 'GotoNextSpotAlpha' : "",
634 \ 'GotoPrevSpotAlpha' : "",
638 let g:switch_mapping = "<Leader>s"
641 nmap <silent> z] <Plug>(SpellRotateForward)
642 nmap <silent> z[ <Plug>(SpellRotateBackward)
643 vmap <silent> z] <Plug>(SpellRotateForwardV)
644 vmap <silent> z[ <Plug>(SpellRotateBackwardV)
647 let g:syntastic_enable_highlighting = 0
648 let g:syntastic_error_symbol='E'
649 let g:syntastic_style_error_symbol='S'
650 let g:syntastic_warning_symbol='W'
651 let g:syntastic_style_warning_symbol='S'
652 let g:syntastic_always_populate_loc_list=1
653 nmap <silent> <leader>y :SyntasticCheck<cr>
655 let g:syntastic_cpp_clang_tidy_post_args = "-p build*"
658 let g:syntastic_check_on_open=1
662 map <F5> :TagbarToggle<cr>
663 let g:tagbar_sort = 0
664 let g:tagbar_compact = 1
665 let g:tagbar_autoshowtag = 1
666 let g:tagbar_width = 25
667 let g:tagbar_iconchars = ['+', '-']
670 let g:tcomment_textobject_inlinecomment = 'gic'
671 let g:tcomment#filetype#guess = 0
674 let g:UltiSnipsEditSplit = 'vertical'
675 let g:UltiSnipsSnippetDirectories = [ expand("$XDG_CONFIG_HOME/vim/ultisnips") ]
677 let g:UltiSnipsSnippetDirectories = ["UltiSnips", "ultisnips"]
679 let g:UltiSnipsExpandTrigger = "<tab>"
680 let g:UltiSnipsJumpForwardTrigger = "<tab>"
681 let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
683 " UltiSnips completion function that tries to expand a snippet. If there's no
684 " snippet for expanding, it checks for completion window and if it's shown,
685 " selects first element. If there's no completion window it tries to jump to
686 " next placeholder. If there's no placeholder it just returns TAB key
687 " https://github.com/Valloric/YouCompleteMe/issues/36#issuecomment-15451411
688 function! g:UltiSnips_Complete()
689 call UltiSnips#ExpandSnippet()
690 if g:ulti_expand_res == 0
694 call UltiSnips#JumpForwards()
695 if g:ulti_jump_forwards_res == 0
702 au InsertEnter * exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=g:UltiSnips_Complete()<cr>"
703 let g:UltiSnipsListSnippets="<c-e>"
706 call unite#filters#matcher_default#use(['matcher_fuzzy'])
707 call unite#custom#profile('default', 'context', {
709 \ 'direction': 'botright'
712 nnoremap [unite] <Nop>
713 nmap <leader>u [unite]
714 nnoremap [unite]u :UniteResume<CR>
715 nnoremap <silent> [u :UnitePrevious<CR>
716 nnoremap <silent> ]u :UniteNext<CR>
719 " seems not respected
720 let g:unite_source_grep_max_candidates = 2000
722 " Use ag in unite grep source.
723 let g:unite_source_grep_command = 'ag'
724 let g:unite_source_grep_default_opts = '--smart-case --vimgrep --ignore ''.hg'' --ignore ''.svn'' --ignore ''.git'' --ignore ''.bzr'''
725 let g:unite_source_grep_recursive_opt = ''
727 nnoremap <silent> [unite]a :<C-u>Unite grep:.::
\12\17<CR>
728 nnoremap <silent> [unite]A :<C-u>Unite grep:.:-w:
\12\17<CR>
729 command! -nargs=+ Ag Unite -input=<args> grep:.:
731 " unite-file_rec {{{3
733 " Use ag in unite rec source
734 let g:unite_source_rec_async_command = ['ag', '--follow', '--nocolor', '--nogroup', '-g', '']
736 nnoremap <silent> [unite]f :<C-u>Unite -start-insert file_rec/async<CR>
737 call unite#custom#source('file_rec/async', 'sorters', 'sorter_selecta')
740 call unite#custom#default_action('buffer', 'open')
741 nnoremap <silent> [unite]b :<C-u>Unite buffer:-<CR>
743 " unite-jumplist {{{3
744 nnoremap <silent> [unite]j :<C-u>Unite output:jumps:<CR>
747 let g:unite_source_menu_menus = {}
748 let g:unite_source_menu_menus.fugitive = { 'description' : 'fugitive menu'}
749 let g:unite_source_menu_menus.fugitive.command_candidates = {
750 \ 'Gstatus <Leader>gs' : 'Gstatus',
751 \ 'Gcommit -v <Leader>gc' : 'Gcommit -v',
755 nnoremap <silent> <leader>gg :<C-u>Unite menu:fugitive<CR>
757 let g:unite_source_history_yank_enable = 1
758 nnoremap <silent> [unite]p :<C-u>Unite history/yank<CR>
761 nnoremap <silent> <leader>p :YRShow<cr>
762 let g:yankring_history_dir = expand('$XDG_CACHE_HOME/vim')
763 let g:yankring_replace_n_pkey = ''
764 let g:yankring_replace_n_nkey = ''
766 " map Y to y$ for the yank ring
767 function! YRRunAfterMaps()
768 nnoremap Y :<C-U>YRYankCount 'y$'<CR>
772 let g:ycm_clangd_binary_path = 'clangd' " use clangd in path
773 let g:ycm_clangd_args = ['--clang-tidy']
774 let g:ycm_extra_conf_vim_data = ['getcwd()']
775 let g:ycm_add_preview_to_completeopt = 1
776 let g:ycm_complete_in_comments = 1
777 let g:ycm_complete_in_strings = 1
778 let g:ycm_autoclose_preview_window_after_insertion = 0
780 " vim-easy-align {{{2
781 " start interactive EasyAlign in visual mode
782 vmap <Enter> <Plug>(EasyAlign)
783 nmap ga <Plug>(EasyAlign)
786 let g:gtest#highlight_failing_tests = 0
788 nnoremap <silent> <Leader>tt :GTestRun<CR>
789 nnoremap <Leader>tc :GTestCase<space>
790 nnoremap <Leader>tn :GTestName<space>
791 nnoremap <silent> <Leader>ta :GTestCase *<CR>:GTestName *<CR>:GTestRun<CR>
792 nnoremap <silent> <Leader>tu :GTestRunUnderCursor<CR>
795 let g:vim_json_syntax_conceal = 0
798 let g:sneak#streak = 1
799 let g:sneak#target_labels = "aoeuisnthdpylrcgfqjkxzmwvz" " dvorak
800 let g:sneak#use_ic_scs = 1 " follow 'ignorecase' and 'smartcase'
818 " Convenient command to see the difference between the current buffer and the
819 " file it was loaded from, thus the changes you made.
820 " Only define it when not defined already.
821 if !exists(":DiffOrig")
822 command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
823 \ | wincmd p | diffthis
827 function! SortLinesOpFunc(...)
830 nnoremap <silent> gs :<C-U>set operatorfunc=SortLinesOpFunc<CR>g@
831 vnoremap <silent> gs :sort<cr>
834 function! EditConfig(what, ext = '.vim')
835 let l:dir = split(&runtimepath,',')[0]
837 let l:file = expand($MYVIMRC)
838 elseif ! isdirectory(globpath(l:dir, a:what))
839 echoe a:what." is not valid!"
840 elseif empty(&filetype)
841 echoe 'filetype is empty!'
843 let l:file = l:dir.'/'.a:what.'/'.&filetype.a:ext
846 execute ':vsplit '.file
849 nmap <leader>ev :call EditConfig('vimrc')<CR>
850 nmap <leader>ef :call EditConfig('ftplugin')<CR>
851 nmap <leader>es :call EditConfig('syntax')<CR>
852 nmap <leader>ei :call EditConfig('indent')<CR>
853 nmap <leader>eu :call EditConfig('ultisnips', '.snippets')<CR>
856 " http://tex.stackexchange.com/a/52932
857 let g:myLangList=["en_gb","en_us","de","fr"]
859 function! ToggleSpell()
860 if !exists("b:myLang")
863 execute "setlocal spell!"
865 echo "setlocal spelllang=" g:myLangList[b:myLang]
869 function! SwitchSpell()
870 if !exists("b:myLang")
874 let b:myLang=b:myLang+1
875 if b:myLang>=len(g:myLangList) | let b:myLang=0 | endif
877 execute "setlocal spell spelllang=".get(g:myLangList, b:myLang)
878 echo "setlocal spelllang=" g:myLangList[b:myLang]
881 nnoremap <silent> coS :call SwitchSpell()<CR>
882 " fix spelling with first choice
883 nnoremap <Leader>f 1z=
885 " gitdir or home {{{2
887 " http://git.io/v3GAV
888 function! FindGitDirOrHome()
889 let filedir = expand('%:p:h')
890 if isdirectory(filedir)
891 let cmd = 'bash -c "(cd ' . filedir . '; git rev-parse --show-toplevel 2>/dev/null)"'
892 let gitdir = system(cmd)
893 if strlen(gitdir) == 0
903 command! Cdr execute('cd ' . FindGitDirOrHome())
905 command! LCdr execute('lcd ' . FindGitDirOrHome())
907 " vim:set et sw=2 ts=2 tw=78: