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-speeddating'
50 Plug 'tpope/vim-surround' "investigate vim-sandwich
51 Plug 'tpope/vim-unimpaired'
52 Plug 'tweekmonster/spellrotate.vim'
53 Plug 'valloric/youcompleteme', { 'do': './install.py --clangd-completer --clang-completer' }
54 Plug 'vim-scripts/mediawiki.vim'
55 Plug 'vim-scripts/replacewithregister'
56 Plug 'vim-scripts/yankring.vim'
60 Plug 'morhetz/gruvbox'
63 Plug 'sirver/ultisnips'
64 Plug 'honza/vim-snippets'
67 Plug 'kana/vim-textobj-user'
68 Plug 'julian/vim-textobj-variable-segment'
69 Plug 'sgur/vim-textobj-parameter'
70 Plug 'kana/vim-operator-user'
73 " Check LucHermites plugins: https://github.com/LucHermitte/lh-cpp
74 Plug 'dense-analysis/ale' " {{{2
75 let g:ale_echo_msg_format = '[%linter%] %code: %%s'
76 let g:ale_c_parse_compile_commands = 1
77 let g:ale_cpp_parse_compile_commands = 1
78 " don't use loclist as it's being populated by ycm
79 " (might want to enable for other filetypes)
80 let g:ale_set_loclist = 0
81 let g:ale_linters_ignore = { 'cpp': ['clangd', 'clangtidy', 'clang'] }
83 Plug 'git@github.com:/ram-z/vim-orgmode', { 'branch': 'dev' } " {{{2
84 Plug 'vim-scripts/syntaxrange'
86 let g:org_agenda_files = ['~/org/*.org']
90 filetype plugin indent on
95 let g:gruvbox_contrast_dark = 'hard'
96 let g:gruvbox_contrast_light = 'soft'
98 " override the background to be black
99 highligh Normal ctermbg=None
102 " moving around, searching and patterns {{{2
103 set incsearch " show match for partly typed search command
104 set ignorecase " ignore case when using a search pattern
105 set smartcase " override 'ignorecase' when pattern has upper case characters
106 set hlsearch " highlight all matches for the last used search pattern
108 set nostartofline " don't move the cursor to the first non-blank char of a line
111 set path+=../include/
112 set path+=/usr/include/c++/*
114 " displaying text {{{2
115 set nowrap " long lines wrap
116 set linebreak " wrap long lines at a character in 'breakat'
117 set showbreak=↪ " show these chars for wrapped lines
118 set breakindent " preserve indentation in wrapped text
120 set lazyredraw " don't redraw while executing macros
122 set list " show chars defined in 'listchars'
123 set listchars=tab:❭\ " list of strings used for list mode
124 set listchars+=extends:❯,precedes:❮
125 " Only shown when not in insert mode
126 set listchars+=trail:·
129 au InsertEnter * :set listchars-=trail:·
130 au InsertLeave * :set listchars+=trail:·
133 set scrolloff=5 " number of screen lines to show around the cursor
134 set sidescroll=1 " number of collumns to scroll
135 set sidescrolloff=1 " don't scroll over the listchars
137 set fillchars=diff:⣿,vert:│
139 set nonumber " show the line number for each line
140 set norelativenumber " show the relative line number for each line
142 " syntax, highlighting and spelling {{{2
143 set synmaxcol=800 " don't highlight long lines
145 set dictionary=spell " list of dictionary files for keyword completion
149 " multiple windows {{{2
150 set laststatus=2 " 0, 1 or 2; when to use a status line for the last window
152 set previewheight=20 " default height for the preview window
156 " set splitbelow " a new window is put below of the current one
157 set splitright " a new window is put right of the current one
162 " using the mouse {{{2
163 set mouse=rnv " list of flags for using the mouse
164 set ttymouse=xterm " type of mouse
166 " messages and info {{{2
167 set showcmd " Show (partial) command in status line.
168 set ruler " show the cursor position all the time
169 set confirm " Ask what to do when closing unsaved documents
170 set shortmess= " reset option
171 set shortmess+=a " all abbreviations
172 set shortmess+=o " overwrite file-written message
173 set shortmess+=O " file-read message overrides previous
174 set shortmess+=t " truncate file message at start
175 set shortmess+=T " truncate other messages in the middle
176 set shortmess+=W " don't give 'written' or '[w]' when writing a file
177 set shortmess+=A " ignore swapfile warning
178 set shortmess+=I " no splash screen
181 set backspace=indent,eol,start " allow backspacing over everything in insert mode
183 set showmatch " Show matching brackets.
185 set nojoinspaces " don't use two spaces after '.' when joining a line
186 set formatoptions+=j " Delete comment leader when joining lines
187 set formatoptions+=c " Autowrap comments using textwidth
188 set formatoptions+=r " Insert comment leader after hitting <Enter>
189 set formatoptions+=n " Recognize numbered lists
190 set formatoptions+=q " Allow formatting of comments with "gq".
191 set formatoptions+=l " do not wrap lines that have been longer when starting insert mode already
192 set formatoptions+=t " Auto-wrap text using textwidth
193 set formatoptions-=o " Do not insert comment leader after hitting o or O in normal mode
195 set nrformats=hex " number formats recognized for CTRL-A and CTRL-X commands
197 set complete=. " scan the current buffer ( 'wrapscan' is ignored)
198 set complete+=w " scan buffers from other windows
199 set complete+=b " scan other loaded buffers that are in the buffer list
200 set complete+=u " scan the unloaded buffers that are in the buffer list
201 set complete+=t " scan tags
202 set complete+=i " scan current and included files
203 set complete+=kspell " use the currently active spell checking |spell|
205 " whether to use a popup menu for Insert mode completion
206 set completeopt=longest,menuone,preview
208 " tabs and indent {{{2
209 set shiftwidth=4 " number of spaces used for each step of (auto)indent
210 set smarttab " a <Tab> in an indent inserts 'shiftwidth' spaces
211 set softtabstop=4 " if non-zero, number of spaces to insert for a <Tab>
212 set shiftround " round to 'shiftwidth' for "<<" and ">>"
213 set expandtab " expand <Tab> to spaces in Insert mode
216 set pastetoggle=<F11> " key sequence to toggle paste mode
219 set foldmethod=marker " folding type
220 set foldlevelstart=0 " value for 'foldlevel' when starting to edit a file
222 " open folds when jumping to line
225 set viewoptions=cursor " save cursor position
226 set viewoptions+=folds " save folds
229 set diffopt+=filler " show filler lines
230 set diffopt+=vertical " always vertical split
231 set diffopt+=context:10 " 10 lines context between changes
233 " reading and writing files {{{2
234 set modeline " read modelines
235 set modelines=2 " only check first/last 2 lines
237 set writebackup " write a backup file before overwriting a file
238 set backup " keep a backup after owerwriting a file
239 set backupdir=$XDG_CACHE_HOME/vim/backup//
241 set backupskip+=.netrc " skip netrc
242 set backupskip+=/dev/shm/pass* " skip passwordstore files
244 set undofile " persistent undo history
245 set undodir=$XDG_CACHE_HOME/vim/undo//
249 au BufWritePre .netrc setlocal noundofile
250 au BufWritePre /dev/shm/pass* setlocal noundofile
251 au BufWritePre /tmp/* setlocal noundofile
254 set autowrite " automatically write a file when leaving a modified buffer
255 set autoread " automatically read a file that has been modified
259 set directory=$XDG_CACHE_HOME/vim/swap//
261 " command line editing {{{2
262 set history=5000 " how many command lines are remembered
263 set wildmenu " command-line completion shows a list of matches
264 set wildmode=longest:full,full " specifies how command line completion works
265 set wildignorecase " ignore case when completing file names
267 set wildignore+=.hg,.git,.svn " Version control
268 set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
269 set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
270 set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
271 set wildignore+=*.spl " compiled spelling word lists
272 set wildignore+=*.sw? " Vim swap files
273 set wildignore+=*.luac " Lua byte code
274 set wildignore+=*.pyc " Python byte code
275 set wildignore+=*.orig " Merge resolution files
277 " running make and jumping to errors {{{2
278 set makeprg=make\ -w " print changing directories
280 set grepprg=ag\ --vimgrep\ $*
282 " language specific {{{2
283 set isfname-== " don't treat `=` as being part of filenames
286 set virtualedit+=block " let cursor move past last char in <C-V> mode
287 set virtualedit+=onemore " allow the cursor to move just past the end of the line
288 set viminfo='100,<50,s10,h,n$XDG_CACHE_HOME/vim/viminfo " viminfo defaults but save file in .cache
290 set viewdir=$XDG_CACHE_HOME/vim/view//
292 set sessionoptions+=unix,slash " damn windows and it's silly ways
295 " Resize splits when the window is resized {{{2
298 autocmd VimResized * :wincmd =
301 " Only show cursorline in the current window and in normal mode {{{2
304 au WinLeave,InsertEnter * set nocursorline
305 au WinEnter,InsertLeave * set cursorline
308 " Treat buffers from stdin (e.g.: echo foo | vim -) as scratch {{{2
311 au StdinReadPost * :set buftype=nofile
314 " Jump to last known cursor position {{{2
317 " blacklist certain filetype
318 let blacklist = ['gitcommit']
319 autocmd BufReadPost *
320 \ if index(blacklist, &ft) < 0 && line("'\"") > 1 && line("'\"") <= line("$") |
321 \ exe "normal! g`\"" |
325 " Check for file modifications automatically {{{2
326 " (current buffer only)
327 " Use :NoAutoChecktime to disable it (uses b:autochecktime)
328 fun! MyAutoCheckTime()
329 " only check timestamp for normal files
330 if &buftype != '' | return | endif
331 if ! exists('b:autochecktime') || b:autochecktime
333 let b:autochecktime = 1
336 augroup MyAutoChecktime
338 au FocusGained,BufEnter,CursorHold,InsertEnter * call MyAutoCheckTime()
340 command! NoAutoChecktime let b:autochecktime=0
341 command! ToggleAutoChecktime let b:autochecktime=!get(b:, 'autochecktime', 0) | echom "b:autochecktime:" b:autochecktime
345 au TerminalOpen * if &buftype == 'terminal' | setlocal bufhidden=hide | endif
350 " allow both <space> and \ to be <leader>
356 if exists("b:make_dir")
357 let l:make_dir = "-C ".b:make_dir
358 elseif exists("g:make_dir")
359 let l:make_dir = "-C ".g:make_dir
362 let l:make_targets = ""
363 if exists("g:make_targets")
364 let l:make_targets = g:make_targets
366 execute "make! ".l:make_dir." ".l:make_targets
368 nnoremap <leader>r :call Make()<cr>
371 nnoremap <silent> <Leader>/ :silent nohl<CR>
374 nnoremap <leader>[ :tabprev<cr>
375 nnoremap <leader>] :tabnext<cr>
377 " paste from selection
378 nnoremap <leader>p* :silent! set paste<CR>"*p:set nopaste<CR>
379 " paste from clipboard
380 nnoremap <leader>p+ :silent! set paste<CR>"+p:set nopaste<CR>
382 " strip trailing whitespace
383 function! StripWhitespace(line1, line2, ...) " {{{2
384 let s_report = &report
386 let pattern = a:0 ? a:1 : '\s\+$'
387 let oldview = winsaveview()
388 exe 'keepjumps keeppatterns '.a:line1.','.a:line2.'substitute/'.pattern.'//e'
389 if oldview != winsaveview()
392 call winrestview(oldview)
393 let &report = s_report
395 command! -range=% -nargs=0 -bar Untrail keepjumps call StripWhitespace(<line1>,<line2>)
396 nnoremap <silent> <leader>ww :Untrail<CR>
399 vnoremap <leader>S y:execute @@<cr>:echo 'Sourced selection.'<cr>
400 nnoremap <leader>S ^vg_y:execute @@<cr>:echo 'Sourced line.'<cr>
402 " jump to last cursor position
405 " Select (charwise) the contents of the current line, excluding indentation.
409 nnoremap U :syntax sync fromstart<cr>:AirlineRefresh<cr>:redraw!<cr>
412 " nnoremap <leader>r :silent !ranger %:h<cr>:redraw!<cr>
413 " nnoremap <leader>R :silent !ranger<cr>:redraw!<cr>
420 " display the number of matches for the last search
421 nmap <Leader># :%s:<C-R>/::gn<CR>
423 " center cursor after search and open folds
427 " same when jumping around
430 nnoremap <c-o> <c-o>zzzv
431 nnoremap <c-i> <c-i>zzzv
433 " Not using the default mappings of 'To line from top/bottom'
439 " Heresy, emacs insert bindings
440 inoremap <C-A> <Esc>I
441 inoremap <C-E> <Esc>A
442 cnoremap <C-A> <Home>
445 " proper movement when lines are wrapped
446 noremap <silent><expr> j (v:count == 0 ? 'gj' : 'j')
447 noremap <silent><expr> k (v:count == 0 ? 'gk' : 'k')
453 noremap <Right> <NOP>
455 inoremap <Down> <NOP>
456 inoremap <Left> <NOP>
457 inoremap <Right> <NOP>
459 cnoremap <Down> <NOP>
460 cnoremap <Left> <NOP>
461 cnoremap <Right> <NOP>
463 cnoremap <C-J> <Down>
464 cnoremap <C-H> <Left>
465 cnoremap <C-L> <Right>
467 " close all folds open fold in cursor
470 map <F1> :ls<CR>:b<space>
472 " move between windows (skip previewwindow)
473 nnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
474 nnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
475 tnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
476 tnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
478 "xterm mouse with middleclick paste
479 nnoremap <MiddleMouse> i<MiddleMouse>
480 vnoremap <MiddleMouse> s<MiddleMouse>
482 " fix legacy vi inconsistency
487 " allow repeat operator on visual
488 vnoremap . :normal .<CR>
490 " add line without changing position or leaving mode
491 noremap <silent> <Leader>o :set paste<CR>m`o<ESC>``:set nopaste<CR>
492 noremap <silent> <Leader>O :set paste<CR>m`O<ESC>``:set nopaste<CR>
494 " Don't use Ex mode, use Q for formatting
497 " break undo sequence before removing word
498 inoremap <C-W> <C-G>u<C-W>
500 nnoremap coe :set <C-R>=&expandtab ? 'noexpandtab' : 'expandtab'<CR><CR>
501 nnoremap [oe :set expandtab<CR>
502 nnoremap ]oe :set noexpandtab<CR>
504 for idt in range(1,8)
505 exe 'nnoremap co'.idt.' :setlocal tabstop='.idt.' shiftwidth='.idt.' softtabstop='.idt.'<CR>'
508 " toggle auto format of text
509 nnoremap coa :set <C-R>=&formatoptions =~ "a" ? 'formatoptions-=a' : 'formatoptions+=a'<CR><CR>
510 nnoremap [oa :set formatoptions+=a<CR>
511 nnoremap ]oa :set formatoptions-=a<CR>
513 " space will toggle current fold in normal mode
514 nnoremap <leader><Space> za
515 " create folds around visual selection
516 vnoremap <leader><Space> zf
519 cabbrev w!! SudoWrite
521 " uppercase previous word
522 inoremap <C-C> <Esc>gUiwgi
524 " http://git.io/v3ZeU
525 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>
527 " plugins options {{{1
529 let g:airline#extensions#whitespace#enabled = 1
530 let g:airline#extensions#tabline#enabled = 1
531 let g:airline_powerline_fonts = 1
534 let g:checkattach_filebrowser = 'ranger'
535 let g:checkattach_once = 'y'
538 let delimitMate_expand_cr = 2
539 let g:delimitMate_expand_space = 1
542 nnoremap <silent> <Leader>ff :FSHere<CR>
543 nnoremap <silent> <Leader>fl :FSRight<CR>
544 nnoremap <silent> <Leader>fh :FSLeft<CR>
545 nnoremap <silent> <Leader>fj :FSBelow<CR>
546 nnoremap <silent> <Leader>fk :FSAbove<CR>
547 nnoremap <silent> <Leader>fL :FSSplitRight<CR>
548 nnoremap <silent> <Leader>fH :FSSplitLeft<CR>
549 nnoremap <silent> <Leader>fJ :FSSplitBelow<CR>
550 nnoremap <silent> <Leader>fK :FSSplitAbove<CR>
553 nmap <silent> <leader>dd :tab split \| Gdiff \| wincmd h<CR>
554 " delete fugitive buffers when closed
555 autocmd BufReadPost fugitive://* set bufhidden=delete
557 nnoremap <silent> <leader>gs :Gstatus<CR>
558 nnoremap <silent> <leader>gd :Gdiff<CR>
559 nnoremap <silent> <leader>gc :Gcommit -v<CR>
560 nnoremap <silent> <leader>ga :Gwrite<cr>
561 nnoremap <silent> <leader>gb :Gblame<cr>
563 augroup fugitive_gstatus
565 autocmd BufWinEnter */.git/index resize 16
569 nnoremap <F7> :GundoToggle<CR>
572 let g:indent_guides_default_mapping = 0
573 let g:indent_guides_guide_size = 1
574 nmap <silent> cog <Plug>IndentGuidesToggle
575 nmap <silent> [og <Plug>IndentGuidesEnable
576 nmap <silent> ]og <Plug>IndentGuidesDisable
578 " close-another-window {{{2
579 nnoremap <silent> <C-W>c <NOP>
580 nnoremap <silent> <C-W>cc <C-W>c
581 nnoremap <silent> <C-W>ch :CloseLeftWindow<CR>
582 nnoremap <silent> <C-W>cl :CloseRightWindow<CR>
583 nnoremap <silent> <C-W>cj :CloseBelowWindow<CR>
584 nnoremap <silent> <C-W>ck :CloseAboveWindow<CR>
588 let g:pymode_rope_completion = 0
589 let g:pymode_rope = 0
591 let g:pymode_folding = 1
592 let g:pymode_lint_ignore = "E221,E266,E501"
593 let g:pymode_lint_cwindow = 0 " don't open cwindow when linting
594 let g:pymode_syntax_space_errors = 0 " don't bother me when I'm typing
597 " disable '[ mappings
599 let g:SignatureMap = {
600 \ 'GotoNextLineAlpha' : "",
601 \ 'GotoPrevLineAlpha' : "",
602 \ 'GotoNextSpotAlpha' : "",
603 \ 'GotoPrevSpotAlpha' : "",
607 let g:switch_mapping = "<Leader>s"
610 nmap <silent> z] <Plug>(SpellRotateForward)
611 nmap <silent> z[ <Plug>(SpellRotateBackward)
612 vmap <silent> z] <Plug>(SpellRotateForwardV)
613 vmap <silent> z[ <Plug>(SpellRotateBackwardV)
616 let g:syntastic_enable_highlighting = 0
617 let g:syntastic_error_symbol='E'
618 let g:syntastic_style_error_symbol='S'
619 let g:syntastic_warning_symbol='W'
620 let g:syntastic_style_warning_symbol='S'
621 let g:syntastic_always_populate_loc_list=1
622 nmap <silent> <leader>y :SyntasticCheck<cr>
624 let g:syntastic_cpp_clang_tidy_post_args = "-p build*"
627 let g:syntastic_check_on_open=1
631 map <F5> :TagbarToggle<cr>
632 let g:tagbar_sort = 0
633 let g:tagbar_compact = 1
634 let g:tagbar_autoshowtag = 1
635 let g:tagbar_width = 25
636 let g:tagbar_iconchars = ['+', '-']
639 let g:tcomment_textobject_inlinecomment = 'gic'
640 let g:tcomment#filetype#guess = 0
643 let g:UltiSnipsEditSplit = 'vertical'
644 let g:UltiSnipsSnippetsDir = expand("$XDG_CONFIG_HOME/vim/ultisnips")
646 let g:UltiSnipsSnippetDirectories = ["UltiSnips", "ultisnips"]
648 let g:UltiSnipsExpandTrigger = "<tab>"
649 let g:UltiSnipsJumpForwardTrigger = "<tab>"
650 let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
652 " UltiSnips completion function that tries to expand a snippet. If there's no
653 " snippet for expanding, it checks for completion window and if it's shown,
654 " selects first element. If there's no completion window it tries to jump to
655 " next placeholder. If there's no placeholder it just returns TAB key
656 " https://github.com/Valloric/YouCompleteMe/issues/36#issuecomment-15451411
657 function! g:UltiSnips_Complete()
658 call UltiSnips#ExpandSnippet()
659 if g:ulti_expand_res == 0
663 call UltiSnips#JumpForwards()
664 if g:ulti_jump_forwards_res == 0
671 au InsertEnter * exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=g:UltiSnips_Complete()<cr>"
672 let g:UltiSnipsListSnippets="<c-e>"
675 call unite#filters#matcher_default#use(['matcher_fuzzy'])
676 call unite#custom#profile('default', 'context', {
678 \ 'direction': 'botright'
681 nnoremap [unite] <Nop>
682 nmap <leader>u [unite]
683 nnoremap [unite]u :UniteResume<CR>
684 nnoremap <silent> [u :UnitePrevious<CR>
685 nnoremap <silent> ]u :UniteNext<CR>
688 " seems not respected
689 let g:unite_source_grep_max_candidates = 2000
691 " Use ag in unite grep source.
692 let g:unite_source_grep_command = 'ag'
693 let g:unite_source_grep_default_opts = '--smart-case --vimgrep --ignore ''.hg'' --ignore ''.svn'' --ignore ''.git'' --ignore ''.bzr'''
694 let g:unite_source_grep_recursive_opt = ''
696 nnoremap <silent> [unite]a :<C-u>Unite grep:.::
\12\17<CR>
697 nnoremap <silent> [unite]A :<C-u>Unite grep:.:-w:
\12\17<CR>
698 command! -nargs=1 Ag Unite grep:.::<args>
700 " unite-file_rec {{{3
702 " Use ag in unite rec source
703 let g:unite_source_rec_async_command = ['ag', '--follow', '--nocolor', '--nogroup', '-g', '']
705 nnoremap <silent> [unite]f :<C-u>Unite -start-insert file_rec/async<CR>
706 call unite#custom#source('file_rec/async', 'sorters', 'sorter_selecta')
709 call unite#custom#default_action('buffer', 'open')
710 nnoremap <silent> [unite]b :<C-u>Unite buffer:-<CR>
713 let g:unite_source_menu_menus = {}
714 let g:unite_source_menu_menus.fugitive = { 'description' : 'fugitive menu'}
715 let g:unite_source_menu_menus.fugitive.command_candidates = {
716 \ 'Gstatus <Leader>gs' : 'Gstatus',
717 \ 'Gcommit -v <Leader>gc' : 'Gcommit -v',
721 nnoremap <silent> <leader>gg :<C-u>Unite menu:fugitive<CR>
723 let g:unite_source_history_yank_enable = 1
724 nnoremap <silent> [unite]p :<C-u>Unite history/yank<CR>
727 nnoremap <silent> <leader>p :YRShow<cr>
728 let g:yankring_history_dir = expand('$XDG_CACHE_HOME/vim')
729 let g:yankring_replace_n_pkey = ''
730 let g:yankring_replace_n_nkey = ''
732 " map Y to y$ for the yank ring
733 function! YRRunAfterMaps()
734 nnoremap Y :<C-U>YRYankCount 'y$'<CR>
738 let g:ycm_extra_conf_globlist = ['~/src/*','/mnt/data/src/*']
739 " ycm-clangd requires you to symlink the compile_db to the root of the project
740 " let g:ycm_global_ycm_extra_conf = expand('$XDG_CONFIG_HOME/vim/ycm_extra_conf.py')
741 let g:ycm_clangd_binary_path = 'clangd' " use clangd in path
742 let g:ycm_extra_conf_vim_data = ['getcwd()']
743 let g:ycm_add_preview_to_completeopt = 1
744 let g:ycm_complete_in_comments = 1
745 let g:ycm_complete_in_strings = 1
746 let g:ycm_autoclose_preview_window_after_insertion = 0
748 " vim-easy-align {{{2
749 " start interactive EasyAlign in visual mode
750 vmap <Enter> <Plug>(EasyAlign)
751 nmap ga <Plug>(EasyAlign)
754 let g:gtest#highlight_failing_tests = 0
756 nnoremap <Leader>tt :GTestRun<CR>
757 nnoremap <Leader>ta :GTestCase *<CR>:GTestName *<CR>:GTestRun<CR>
758 nnoremap <Leader>tu :GTestRunUnderCursor<CR>
761 let g:vim_json_syntax_conceal = 0
764 let g:sneak#streak = 1
765 let g:sneak#target_labels = "aoeuisnthdpylrcgfqjkxzmwvz" " dvorak
766 let g:sneak#use_ic_scs = 1 " follow 'ignorecase' and 'smartcase'
783 let g:vimwiki_list = [{'path': '$XDG_DATA_HOME/vimwiki'}]
784 let g:vimwiki_auto_chdir = 1
786 au! BufRead $XDG_DATA_HOME/vimwiki/index.wiki !git -C "%:p:h" pull -q
787 au! BufRead,BufNewFile $XDG_DATA_HOME/vimwiki/diary/*.wiki !git -C "%:p:h" pull -q
788 au! BufWritePost $XDG_DATA_HOME/vimwiki/*.wiki exe '!git add "<afile>";git commit -qm"' . strftime("%FT%R") . '";git push -q'
793 " Convenient command to see the difference between the current buffer and the
794 " file it was loaded from, thus the changes you made.
795 " Only define it when not defined already.
796 if !exists(":DiffOrig")
797 command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
798 \ | wincmd p | diffthis
802 function! SortLinesOpFunc(...)
805 nnoremap <silent> gs :<C-U>set operatorfunc=SortLinesOpFunc<CR>g@
806 vnoremap <silent> gs :sort<cr>
809 function! EditConfig(what, ext = '.vim')
810 let l:dir = split(&runtimepath,',')[0]
812 let l:file = expand($MYVIMRC)
813 elseif ! isdirectory(globpath(l:dir, a:what))
814 echoe a:what." is not valid!"
815 elseif empty(&filetype)
816 echoe 'filetype is empty!'
818 let l:file = l:dir.'/'.a:what.'/'.&filetype.a:ext
821 execute ':vsplit '.file
824 nmap <leader>ev :call EditConfig('vimrc')<CR>
825 nmap <leader>ef :call EditConfig('ftplugin')<CR>
826 nmap <leader>es :call EditConfig('syntax')<CR>
827 nmap <leader>ei :call EditConfig('indent')<CR>
828 nmap <leader>eu :call EditConfig('ultisnips', '.snippets')<CR>
831 " http://tex.stackexchange.com/a/52932
832 let g:myLangList=["en_gb","en_us","de","fr"]
834 function! ToggleSpell()
835 if !exists("b:myLang")
838 execute "setlocal spell!"
840 echo "setlocal spelllang=" g:myLangList[b:myLang]
844 function! SwitchSpell()
845 if !exists("b:myLang")
849 let b:myLang=b:myLang+1
850 if b:myLang>=len(g:myLangList) | let b:myLang=0 | endif
852 execute "setlocal spell spelllang=".get(g:myLangList, b:myLang)
853 echo "setlocal spelllang=" g:myLangList[b:myLang]
856 nnoremap <silent> coS :call SwitchSpell()<CR>
857 " fix spelling with first choice
858 nnoremap <Leader>f 1z=
860 " gitdir or home {{{2
862 " http://git.io/v3GAV
863 function! FindGitDirOrHome()
864 let filedir = expand('%:p:h')
865 if isdirectory(filedir)
866 let cmd = 'bash -c "(cd ' . filedir . '; git rev-parse --show-toplevel 2>/dev/null)"'
867 let gitdir = system(cmd)
868 if strlen(gitdir) == 0
878 command! Cdr execute('cd ' . FindGitDirOrHome())
880 command! LCdr execute('lcd ' . FindGitDirOrHome())
882 " vim:set et sw=2 ts=2 tw=78: