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 " remove all autocommands
14 call plug#begin('$XDG_DATA_HOME/vim')
15 " This does not update vim-plug, use PlugUpgrade instead
16 Plug 'junegunn/vim-plug'
18 Plug 'airblade/vim-gitgutter'
19 Plug 'alepez/vim-gtest'
20 Plug 'andrewradev/switch.vim'
21 Plug 'bling/vim-airline'
22 Plug 'chrisbra/checkattach'
23 Plug 'derekwyatt/vim-fswitch'
25 Plug 'firef0x/pkgbuild.vim'
26 Plug 'junegunn/vim-easy-align'
27 Plug 'justinmk/vim-sneak'
28 Plug 'klen/python-mode'
29 Plug 'kshenoy/vim-signature'
30 Plug 'majutsushi/tagbar'
31 Plug 'octol/vim-cpp-enhanced-highlight'
32 Plug 'raimondi/delimitmate'
33 Plug 'ram-z/vim-clang-format', { 'branch': 'fix-undo' }
34 " fix some issue with vim-clang-format not finding .clang-format
35 let g:clang_format#detect_style_file = 1
36 Plug 'vimwiki/vimwiki', { 'branch': 'dev' }
37 " Plug 'scrooloose/syntastic'
38 Plug 'sgeb/vim-diff-fold'
39 Plug 'shougo/unite.vim'
40 Plug 'shougo/vimproc.vim', {'do': 'make'}
42 Plug 'thinca/vim-qfreplace'
43 Plug 'tomtom/tcomment_vim'
44 Plug 'tpope/vim-abolish'
45 Plug 'tpope/vim-endwise'
46 Plug 'tpope/vim-eunuch'
47 Plug 'tpope/vim-fugitive'
48 Plug 'tpope/vim-repeat'
49 Plug 'tpope/vim-scriptease'
50 Plug 'tpope/vim-speeddating'
51 Plug 'tpope/vim-surround' "investigate vim-sandwich
52 Plug 'tpope/vim-unimpaired'
53 Plug 'tweekmonster/spellrotate.vim'
54 Plug 'valloric/youcompleteme', { 'do': './install.py --clangd-completer --clang-completer' }
55 Plug 'vim-scripts/mediawiki.vim'
56 Plug 'vim-scripts/replacewithregister'
57 Plug 'vim-scripts/yankring.vim'
61 Plug 'morhetz/gruvbox'
64 Plug 'sirver/ultisnips'
65 Plug 'honza/vim-snippets'
68 Plug 'kana/vim-textobj-user'
69 Plug 'julian/vim-textobj-variable-segment'
70 Plug 'sgur/vim-textobj-parameter'
71 Plug 'kana/vim-operator-user'
74 " Check LucHermites plugins: https://github.com/LucHermitte/lh-cpp
75 Plug 'dense-analysis/ale' " {{{2
76 let g:ale_echo_msg_format = '[%linter%] %code: %%s'
77 let g:ale_c_parse_compile_commands = 1
78 let g:ale_cpp_parse_compile_commands = 1
79 " don't use loclist as it's being populated by ycm
80 " (might want to enable for other filetypes)
81 let g:ale_set_loclist = 0
82 let g:ale_cpp_gcc_options = ''
83 let g:ale_linters_ignore = { 'cpp': ['clangd', 'clangtidy', 'clang'] }
85 Plug 'git@github.com:/ram-z/vim-orgmode', { 'branch': 'dev' } " {{{2
86 Plug 'vim-scripts/syntaxrange'
88 let g:org_agenda_files = ['~/org/*.org']
92 filetype plugin indent on
97 let g:gruvbox_contrast_dark = 'hard'
98 let g:gruvbox_contrast_light = 'soft'
100 " override the background to be black
101 highligh Normal ctermbg=None
104 " moving around, searching and patterns {{{2
105 set incsearch " show match for partly typed search command
106 set ignorecase " ignore case when using a search pattern
107 set smartcase " override 'ignorecase' when pattern has upper case characters
108 set hlsearch " highlight all matches for the last used search pattern
110 set nostartofline " don't move the cursor to the first non-blank char of a line
113 set path+=../include/
114 set path+=/usr/include/c++/*
116 " displaying text {{{2
117 set nowrap " long lines wrap
118 set linebreak " wrap long lines at a character in 'breakat'
119 set showbreak=↪ " show these chars for wrapped lines
120 set breakindent " preserve indentation in wrapped text
122 set lazyredraw " don't redraw while executing macros
124 set list " show chars defined in 'listchars'
125 set listchars=tab:❭\ " list of strings used for list mode
126 set listchars+=extends:❯,precedes:❮
127 " Only shown when not in insert mode
128 set listchars+=trail:·
131 au InsertEnter * :set listchars-=trail:·
132 au InsertLeave * :set listchars+=trail:·
135 set scrolloff=5 " number of screen lines to show around the cursor
136 set sidescroll=1 " number of collumns to scroll
137 set sidescrolloff=1 " don't scroll over the listchars
139 set fillchars=diff:⣿,vert:│
141 set nonumber " show the line number for each line
142 set norelativenumber " show the relative line number for each line
144 " syntax, highlighting and spelling {{{2
145 set synmaxcol=800 " don't highlight long lines
147 set dictionary=spell " list of dictionary files for keyword completion
151 " multiple windows {{{2
152 set laststatus=2 " 0, 1 or 2; when to use a status line for the last window
154 set previewheight=20 " default height for the preview window
158 " set splitbelow " a new window is put below of the current one
159 set splitright " a new window is put right of the current one
164 " using the mouse {{{2
165 set mouse=rnv " list of flags for using the mouse
166 set ttymouse=xterm " type of mouse
168 " messages and info {{{2
169 set showcmd " Show (partial) command in status line.
170 set ruler " show the cursor position all the time
171 set confirm " Ask what to do when closing unsaved documents
172 set shortmess= " reset option
173 set shortmess+=a " all abbreviations
174 set shortmess+=o " overwrite file-written message
175 set shortmess+=O " file-read message overrides previous
176 set shortmess+=t " truncate file message at start
177 set shortmess+=T " truncate other messages in the middle
178 set shortmess+=W " don't give 'written' or '[w]' when writing a file
179 set shortmess+=A " ignore swapfile warning
180 set shortmess+=I " no splash screen
183 set backspace=indent,eol,start " allow backspacing over everything in insert mode
185 set showmatch " Show matching brackets.
187 set nojoinspaces " don't use two spaces after '.' when joining a line
188 set formatoptions+=j " Delete comment leader when joining lines
189 set formatoptions+=c " Autowrap comments using textwidth
190 set formatoptions+=r " Insert comment leader after hitting <Enter>
191 set formatoptions+=n " Recognize numbered lists
192 set formatoptions+=q " Allow formatting of comments with "gq".
193 set formatoptions+=l " do not wrap lines that have been longer when starting insert mode already
194 set formatoptions+=t " Auto-wrap text using textwidth
195 set formatoptions-=o " Do not insert comment leader after hitting o or O in normal mode
197 set nrformats=hex " number formats recognized for CTRL-A and CTRL-X commands
199 set complete=. " scan the current buffer ( 'wrapscan' is ignored)
200 set complete+=w " scan buffers from other windows
201 set complete+=b " scan other loaded buffers that are in the buffer list
202 set complete+=u " scan the unloaded buffers that are in the buffer list
203 set complete+=t " scan tags
204 set complete+=i " scan current and included files
205 set complete+=kspell " use the currently active spell checking |spell|
207 " whether to use a popup menu for Insert mode completion
208 set completeopt=longest,menuone,preview
210 " tabs and indent {{{2
211 set shiftwidth=4 " number of spaces used for each step of (auto)indent
212 set smarttab " a <Tab> in an indent inserts 'shiftwidth' spaces
213 set softtabstop=4 " if non-zero, number of spaces to insert for a <Tab>
214 set shiftround " round to 'shiftwidth' for "<<" and ">>"
215 set expandtab " expand <Tab> to spaces in Insert mode
218 set pastetoggle=<F11> " key sequence to toggle paste mode
221 set foldmethod=marker " folding type
222 set foldlevelstart=0 " value for 'foldlevel' when starting to edit a file
224 " open folds when jumping to line
227 set viewoptions=cursor " save cursor position
228 set viewoptions+=folds " save folds
231 set diffopt+=filler " show filler lines
232 set diffopt+=vertical " always vertical split
233 set diffopt+=context:10 " 10 lines context between changes
235 " reading and writing files {{{2
236 set modeline " read modelines
237 set modelines=2 " only check first/last 2 lines
239 set writebackup " write a backup file before overwriting a file
240 set backup " keep a backup after owerwriting a file
241 set backupdir=$XDG_CACHE_HOME/vim/backup//
243 set backupskip+=.netrc " skip netrc
244 set backupskip+=/dev/shm/pass* " skip passwordstore files
246 set undofile " persistent undo history
247 set undodir=$XDG_CACHE_HOME/vim/undo//
251 au BufWritePre .netrc setlocal noundofile
252 au BufWritePre /dev/shm/pass* setlocal noundofile
253 au BufWritePre /tmp/* setlocal noundofile
256 set autowrite " automatically write a file when leaving a modified buffer
257 set autoread " automatically read a file that has been modified
261 set directory=$XDG_CACHE_HOME/vim/swap//
263 " command line editing {{{2
264 set history=5000 " how many command lines are remembered
265 set wildmenu " command-line completion shows a list of matches
266 set wildmode=longest:full,full " specifies how command line completion works
267 set wildignorecase " ignore case when completing file names
269 set wildignore+=.hg,.git,.svn " Version control
270 set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
271 set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
272 set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
273 set wildignore+=*.spl " compiled spelling word lists
274 set wildignore+=*.sw? " Vim swap files
275 set wildignore+=*.luac " Lua byte code
276 set wildignore+=*.pyc " Python byte code
277 set wildignore+=*.orig " Merge resolution files
279 " running make and jumping to errors {{{2
280 set makeprg=make\ -w " print changing directories
282 set grepprg=ag\ --vimgrep\ $*
284 " language specific {{{2
285 set isfname-== " don't treat `=` as being part of filenames
288 set virtualedit+=block " let cursor move past last char in <C-V> mode
289 set virtualedit+=onemore " allow the cursor to move just past the end of the line
290 set viminfo='100,<50,s10,h,n$XDG_CACHE_HOME/vim/viminfo " viminfo defaults but save file in .cache
292 set viewdir=$XDG_CACHE_HOME/vim/view//
294 set sessionoptions+=unix,slash " damn windows and it's silly ways
297 " Resize splits when the window is resized {{{2
300 autocmd VimResized * :wincmd =
303 " Only show cursorline in the current window and in normal mode {{{2
306 au WinLeave,InsertEnter * set nocursorline
307 au WinEnter,InsertLeave * set cursorline
310 " Treat buffers from stdin (e.g.: echo foo | vim -) as scratch {{{2
313 au StdinReadPost * :set buftype=nofile
316 " Jump to last known cursor position {{{2
319 " blacklist certain filetype
320 let blacklist = ['gitcommit']
321 autocmd BufReadPost *
322 \ if index(blacklist, &ft) < 0 && line("'\"") > 1 && line("'\"") <= line("$") |
323 \ exe "normal! g`\"" |
327 " Check for file modifications automatically {{{2
328 " (current buffer only)
329 " Use :NoAutoChecktime to disable it (uses b:autochecktime)
330 fun! MyAutoCheckTime()
331 " only check timestamp for normal files
332 if &buftype != '' | return | endif
333 if ! exists('b:autochecktime') || b:autochecktime
335 let b:autochecktime = 1
338 augroup MyAutoChecktime
340 au FocusGained,BufEnter,CursorHold,InsertEnter * call MyAutoCheckTime()
342 command! NoAutoChecktime let b:autochecktime=0
343 command! ToggleAutoChecktime let b:autochecktime=!get(b:, 'autochecktime', 0) | echom "b:autochecktime:" b:autochecktime
347 au TerminalOpen * if &buftype == 'terminal' | setlocal bufhidden=hide | endif
352 " allow both <space> and \ to be <leader>
358 if exists("b:make_dir")
359 let l:make_dir = "-C ".b:make_dir
360 elseif exists("g:make_dir")
361 let l:make_dir = "-C ".g:make_dir
364 let l:make_targets = ""
365 if exists("g:make_targets")
366 let l:make_targets = g:make_targets
368 execute "make! ".l:make_dir." ".l:make_targets
370 nnoremap <leader>r :call Make()<cr>
373 nnoremap <silent> <Leader>/ :silent nohl<CR>
376 nnoremap <leader>[ :tabprev<cr>
377 nnoremap <leader>] :tabnext<cr>
379 " paste from selection
380 nnoremap <leader>p* :silent! set paste<CR>"*p:set nopaste<CR>
381 " paste from clipboard
382 nnoremap <leader>p+ :silent! set paste<CR>"+p:set nopaste<CR>
384 " strip trailing whitespace
385 function! StripWhitespace(line1, line2, ...) " {{{2
386 let s_report = &report
388 let pattern = a:0 ? a:1 : '\s\+$'
389 let oldview = winsaveview()
390 exe 'keepjumps keeppatterns '.a:line1.','.a:line2.'substitute/'.pattern.'//e'
391 if oldview != winsaveview()
394 call winrestview(oldview)
395 let &report = s_report
397 command! -range=% -nargs=0 -bar Untrail keepjumps call StripWhitespace(<line1>,<line2>)
398 nnoremap <silent> <leader>ww :Untrail<CR>
401 vnoremap <leader>S y:execute @@<cr>:echo 'Sourced selection.'<cr>
402 nnoremap <leader>S ^vg_y:execute @@<cr>:echo 'Sourced line.'<cr>
404 " jump to last cursor position
407 " Select (charwise) the contents of the current line, excluding indentation.
411 nnoremap U :syntax sync fromstart<cr>:AirlineRefresh<cr>:redraw!<cr>
414 " nnoremap <leader>r :silent !ranger %:h<cr>:redraw!<cr>
415 " nnoremap <leader>R :silent !ranger<cr>:redraw!<cr>
422 " display the number of matches for the last search
423 nmap <Leader># :%s:<C-R>/::gn<CR>
425 " center cursor after search and open folds
429 " same when jumping around
432 nnoremap <c-o> <c-o>zzzv
433 nnoremap <c-i> <c-i>zzzv
435 " Not using the default mappings of 'To line from top/bottom'
441 " Heresy, emacs insert bindings
442 inoremap <C-A> <Esc>I
443 inoremap <C-E> <Esc>A
444 cnoremap <C-A> <Home>
447 " proper movement when lines are wrapped
448 noremap <silent><expr> j (v:count == 0 ? 'gj' : 'j')
449 noremap <silent><expr> k (v:count == 0 ? 'gk' : 'k')
455 noremap <Right> <NOP>
457 inoremap <Down> <NOP>
458 inoremap <Left> <NOP>
459 inoremap <Right> <NOP>
461 cnoremap <Down> <NOP>
462 cnoremap <Left> <NOP>
463 cnoremap <Right> <NOP>
465 cnoremap <C-J> <Down>
466 cnoremap <C-H> <Left>
467 cnoremap <C-L> <Right>
469 " close all folds open fold in cursor
472 map <F1> :ls<CR>:b<space>
474 " move between windows (skip previewwindow)
475 nnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
476 nnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
477 tnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
478 tnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
480 "xterm mouse with middleclick paste
481 nnoremap <MiddleMouse> i<MiddleMouse>
482 vnoremap <MiddleMouse> s<MiddleMouse>
484 " fix legacy vi inconsistency
489 " allow repeat operator on visual
490 vnoremap . :normal .<CR>
492 " add line without changing position or leaving mode
493 noremap <silent> <Leader>o :set paste<CR>m`o<ESC>``:set nopaste<CR>
494 noremap <silent> <Leader>O :set paste<CR>m`O<ESC>``:set nopaste<CR>
496 " Don't use Ex mode, use Q for formatting
499 " break undo sequence before removing word
500 inoremap <C-W> <C-G>u<C-W>
502 nnoremap coe :set <C-R>=&expandtab ? 'noexpandtab' : 'expandtab'<CR><CR>
503 nnoremap [oe :set expandtab<CR>
504 nnoremap ]oe :set noexpandtab<CR>
506 for idt in range(1,8)
507 exe 'nnoremap co'.idt.' :setlocal tabstop='.idt.' shiftwidth='.idt.' softtabstop='.idt.'<CR>'
510 " toggle auto format of text
511 nnoremap coa :set <C-R>=&formatoptions =~ "a" ? 'formatoptions-=a' : 'formatoptions+=a'<CR><CR>
512 nnoremap [oa :set formatoptions+=a<CR>
513 nnoremap ]oa :set formatoptions-=a<CR>
515 " space will toggle current fold in normal mode
516 nnoremap <leader><Space> za
517 " create folds around visual selection
518 vnoremap <leader><Space> zf
521 cabbrev w!! SudoWrite
523 " uppercase previous word
524 inoremap <C-C> <Esc>gUiwgi
526 " http://git.io/v3ZeU
527 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>
529 " plugins options {{{1
531 let g:airline#extensions#whitespace#enabled = 1
532 let g:airline#extensions#tabline#enabled = 1
533 let g:airline_powerline_fonts = 1
536 let g:checkattach_filebrowser = 'ranger'
537 let g:checkattach_once = 'y'
540 let delimitMate_expand_cr = 2
541 let g:delimitMate_expand_space = 1
544 nnoremap <silent> <Leader>ff :FSHere<CR>
545 nnoremap <silent> <Leader>fl :FSRight<CR>
546 nnoremap <silent> <Leader>fh :FSLeft<CR>
547 nnoremap <silent> <Leader>fj :FSBelow<CR>
548 nnoremap <silent> <Leader>fk :FSAbove<CR>
549 nnoremap <silent> <Leader>fL :FSSplitRight<CR>
550 nnoremap <silent> <Leader>fH :FSSplitLeft<CR>
551 nnoremap <silent> <Leader>fJ :FSSplitBelow<CR>
552 nnoremap <silent> <Leader>fK :FSSplitAbove<CR>
555 nmap <silent> <leader>dd :tab split \| Gdiff \| wincmd h<CR>
556 " delete fugitive buffers when closed
557 autocmd BufReadPost fugitive://* set bufhidden=delete
559 nnoremap <silent> <leader>gs :Gstatus<CR>
560 nnoremap <silent> <leader>gd :Gdiff<CR>
561 nnoremap <silent> <leader>gc :Gcommit -v<CR>
562 nnoremap <silent> <leader>ga :Gwrite<cr>
563 nnoremap <silent> <leader>gb :Gblame<cr>
565 augroup fugitive_gstatus
567 autocmd BufWinEnter */.git/index resize 16
571 nnoremap <F7> :GundoToggle<CR>
574 let g:indent_guides_default_mapping = 0
575 let g:indent_guides_guide_size = 1
576 nmap <silent> cog <Plug>IndentGuidesToggle
577 nmap <silent> [og <Plug>IndentGuidesEnable
578 nmap <silent> ]og <Plug>IndentGuidesDisable
580 " close-another-window {{{2
581 nnoremap <silent> <C-W>c <NOP>
582 nnoremap <silent> <C-W>cc <C-W>c
583 nnoremap <silent> <C-W>ch :CloseLeftWindow<CR>
584 nnoremap <silent> <C-W>cl :CloseRightWindow<CR>
585 nnoremap <silent> <C-W>cj :CloseBelowWindow<CR>
586 nnoremap <silent> <C-W>ck :CloseAboveWindow<CR>
590 let g:pymode_rope_completion = 0
591 let g:pymode_rope = 0
593 let g:pymode_folding = 1
594 let g:pymode_lint_ignore = "E221,E266,E501"
595 let g:pymode_lint_cwindow = 0 " don't open cwindow when linting
596 let g:pymode_syntax_space_errors = 0 " don't bother me when I'm typing
599 " disable '[ mappings
601 let g:SignatureMap = {
602 \ 'GotoNextLineAlpha' : "",
603 \ 'GotoPrevLineAlpha' : "",
604 \ 'GotoNextSpotAlpha' : "",
605 \ 'GotoPrevSpotAlpha' : "",
609 let g:switch_mapping = "<Leader>s"
612 nmap <silent> z] <Plug>(SpellRotateForward)
613 nmap <silent> z[ <Plug>(SpellRotateBackward)
614 vmap <silent> z] <Plug>(SpellRotateForwardV)
615 vmap <silent> z[ <Plug>(SpellRotateBackwardV)
618 let g:syntastic_enable_highlighting = 0
619 let g:syntastic_error_symbol='E'
620 let g:syntastic_style_error_symbol='S'
621 let g:syntastic_warning_symbol='W'
622 let g:syntastic_style_warning_symbol='S'
623 let g:syntastic_always_populate_loc_list=1
624 nmap <silent> <leader>y :SyntasticCheck<cr>
626 let g:syntastic_cpp_clang_tidy_post_args = "-p build*"
629 let g:syntastic_check_on_open=1
633 map <F5> :TagbarToggle<cr>
634 let g:tagbar_sort = 0
635 let g:tagbar_compact = 1
636 let g:tagbar_autoshowtag = 1
637 let g:tagbar_width = 25
638 let g:tagbar_iconchars = ['+', '-']
641 let g:tcomment_textobject_inlinecomment = 'gic'
642 let g:tcomment#filetype#guess = 0
645 let g:UltiSnipsEditSplit = 'vertical'
646 let g:UltiSnipsSnippetsDir = expand("$XDG_CONFIG_HOME/vim/ultisnips")
648 let g:UltiSnipsSnippetDirectories = ["UltiSnips", "ultisnips"]
650 let g:UltiSnipsExpandTrigger = "<tab>"
651 let g:UltiSnipsJumpForwardTrigger = "<tab>"
652 let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
654 " UltiSnips completion function that tries to expand a snippet. If there's no
655 " snippet for expanding, it checks for completion window and if it's shown,
656 " selects first element. If there's no completion window it tries to jump to
657 " next placeholder. If there's no placeholder it just returns TAB key
658 " https://github.com/Valloric/YouCompleteMe/issues/36#issuecomment-15451411
659 function! g:UltiSnips_Complete()
660 call UltiSnips#ExpandSnippet()
661 if g:ulti_expand_res == 0
665 call UltiSnips#JumpForwards()
666 if g:ulti_jump_forwards_res == 0
673 au InsertEnter * exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=g:UltiSnips_Complete()<cr>"
674 let g:UltiSnipsListSnippets="<c-e>"
677 call unite#filters#matcher_default#use(['matcher_fuzzy'])
678 call unite#custom#profile('default', 'context', {
680 \ 'direction': 'botright'
683 nnoremap [unite] <Nop>
684 nmap <leader>u [unite]
685 nnoremap [unite]u :UniteResume<CR>
686 nnoremap <silent> [u :UnitePrevious<CR>
687 nnoremap <silent> ]u :UniteNext<CR>
690 " seems not respected
691 let g:unite_source_grep_max_candidates = 2000
693 " Use ag in unite grep source.
694 let g:unite_source_grep_command = 'ag'
695 let g:unite_source_grep_default_opts = '--smart-case --vimgrep --ignore ''.hg'' --ignore ''.svn'' --ignore ''.git'' --ignore ''.bzr'''
696 let g:unite_source_grep_recursive_opt = ''
698 nnoremap <silent> [unite]a :<C-u>Unite grep:.::
\12\17<CR>
699 nnoremap <silent> [unite]A :<C-u>Unite grep:.:-w:
\12\17<CR>
700 command! -nargs=1 Ag Unite grep:.::<args>
702 " unite-file_rec {{{3
704 " Use ag in unite rec source
705 let g:unite_source_rec_async_command = ['ag', '--follow', '--nocolor', '--nogroup', '-g', '']
707 nnoremap <silent> [unite]f :<C-u>Unite -start-insert file_rec/async<CR>
708 call unite#custom#source('file_rec/async', 'sorters', 'sorter_selecta')
711 call unite#custom#default_action('buffer', 'open')
712 nnoremap <silent> [unite]b :<C-u>Unite buffer:-<CR>
715 let g:unite_source_menu_menus = {}
716 let g:unite_source_menu_menus.fugitive = { 'description' : 'fugitive menu'}
717 let g:unite_source_menu_menus.fugitive.command_candidates = {
718 \ 'Gstatus <Leader>gs' : 'Gstatus',
719 \ 'Gcommit -v <Leader>gc' : 'Gcommit -v',
723 nnoremap <silent> <leader>gg :<C-u>Unite menu:fugitive<CR>
725 let g:unite_source_history_yank_enable = 1
726 nnoremap <silent> [unite]p :<C-u>Unite history/yank<CR>
729 nnoremap <silent> <leader>p :YRShow<cr>
730 let g:yankring_history_dir = expand('$XDG_CACHE_HOME/vim')
731 let g:yankring_replace_n_pkey = ''
732 let g:yankring_replace_n_nkey = ''
734 " map Y to y$ for the yank ring
735 function! YRRunAfterMaps()
736 nnoremap Y :<C-U>YRYankCount 'y$'<CR>
740 let g:ycm_extra_conf_globlist = ['~/src/*','/mnt/data/src/*']
741 " ycm-clangd requires you to symlink the compile_db to the root of the project
742 " let g:ycm_global_ycm_extra_conf = expand('$XDG_CONFIG_HOME/vim/ycm_extra_conf.py')
743 let g:ycm_clangd_binary_path = 'clangd' " use clangd in path
744 let g:ycm_extra_conf_vim_data = ['getcwd()']
745 let g:ycm_add_preview_to_completeopt = 1
746 let g:ycm_complete_in_comments = 1
747 let g:ycm_complete_in_strings = 1
748 let g:ycm_autoclose_preview_window_after_insertion = 0
750 " vim-easy-align {{{2
751 " start interactive EasyAlign in visual mode
752 vmap <Enter> <Plug>(EasyAlign)
753 nmap ga <Plug>(EasyAlign)
756 let g:gtest#highlight_failing_tests = 0
758 nnoremap <Leader>tt :GTestRun<CR>
759 nnoremap <Leader>ta :GTestCase *<CR>:GTestName *<CR>:GTestRun<CR>
760 nnoremap <Leader>tu :GTestRunUnderCursor<CR>
763 let g:vim_json_syntax_conceal = 0
766 let g:sneak#streak = 1
767 let g:sneak#target_labels = "aoeuisnthdpylrcgfqjkxzmwvz" " dvorak
768 let g:sneak#use_ic_scs = 1 " follow 'ignorecase' and 'smartcase'
785 let g:vimwiki_list = [{'path': '$XDG_DATA_HOME/vimwiki'}]
786 let g:vimwiki_auto_chdir = 1
788 au! BufRead $XDG_DATA_HOME/vimwiki/index.wiki !git -C "%:p:h" pull -q
789 au! BufRead,BufNewFile $XDG_DATA_HOME/vimwiki/diary/*.wiki !git -C "%:p:h" pull -q
790 au! BufWritePost $XDG_DATA_HOME/vimwiki/*.wiki exe '!git add "<afile>";git commit -qm"' . strftime("%FT%R") . '";git push -q'
795 " Convenient command to see the difference between the current buffer and the
796 " file it was loaded from, thus the changes you made.
797 " Only define it when not defined already.
798 if !exists(":DiffOrig")
799 command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
800 \ | wincmd p | diffthis
804 function! SortLinesOpFunc(...)
807 nnoremap <silent> gs :<C-U>set operatorfunc=SortLinesOpFunc<CR>g@
808 vnoremap <silent> gs :sort<cr>
811 function! EditConfig(what, ext = '.vim')
812 let l:dir = split(&runtimepath,',')[0]
814 let l:file = expand($MYVIMRC)
815 elseif ! isdirectory(globpath(l:dir, a:what))
816 echoe a:what." is not valid!"
817 elseif empty(&filetype)
818 echoe 'filetype is empty!'
820 let l:file = l:dir.'/'.a:what.'/'.&filetype.a:ext
823 execute ':vsplit '.file
826 nmap <leader>ev :call EditConfig('vimrc')<CR>
827 nmap <leader>ef :call EditConfig('ftplugin')<CR>
828 nmap <leader>es :call EditConfig('syntax')<CR>
829 nmap <leader>ei :call EditConfig('indent')<CR>
830 nmap <leader>eu :call EditConfig('ultisnips', '.snippets')<CR>
833 " http://tex.stackexchange.com/a/52932
834 let g:myLangList=["en_gb","en_us","de","fr"]
836 function! ToggleSpell()
837 if !exists("b:myLang")
840 execute "setlocal spell!"
842 echo "setlocal spelllang=" g:myLangList[b:myLang]
846 function! SwitchSpell()
847 if !exists("b:myLang")
851 let b:myLang=b:myLang+1
852 if b:myLang>=len(g:myLangList) | let b:myLang=0 | endif
854 execute "setlocal spell spelllang=".get(g:myLangList, b:myLang)
855 echo "setlocal spelllang=" g:myLangList[b:myLang]
858 nnoremap <silent> coS :call SwitchSpell()<CR>
859 " fix spelling with first choice
860 nnoremap <Leader>f 1z=
862 " gitdir or home {{{2
864 " http://git.io/v3GAV
865 function! FindGitDirOrHome()
866 let filedir = expand('%:p:h')
867 if isdirectory(filedir)
868 let cmd = 'bash -c "(cd ' . filedir . '; git rev-parse --show-toplevel 2>/dev/null)"'
869 let gitdir = system(cmd)
870 if strlen(gitdir) == 0
880 command! Cdr execute('cd ' . FindGitDirOrHome())
882 command! LCdr execute('lcd ' . FindGitDirOrHome())
884 " vim:set et sw=2 ts=2 tw=78: