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_c_build_dir_names = [ 'build-Linux-x86_64' ]
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 let g:ale_cpp_gcc_options = ''
80 let g:ale_cpp_clang_options = ''
82 Plug 'git@github.com:/ram-z/vim-orgmode', { 'branch': 'dev' } " {{{2
83 Plug 'vim-scripts/syntaxrange'
85 let g:org_agenda_files = ['~/org/*.org']
89 filetype plugin indent on
94 let g:gruvbox_contrast_dark = 'hard'
95 let g:gruvbox_contrast_light = 'soft'
97 " override the background to be black
98 highligh Normal ctermbg=None
101 " moving around, searching and patterns {{{2
102 set incsearch " show match for partly typed search command
103 set ignorecase " ignore case when using a search pattern
104 set smartcase " override 'ignorecase' when pattern has upper case characters
105 set hlsearch " highlight all matches for the last used search pattern
107 set nostartofline " don't move the cursor to the first non-blank char of a line
110 set path+=../include/
111 set path+=/usr/include/c++/*
113 " displaying text {{{2
114 set nowrap " long lines wrap
115 set linebreak " wrap long lines at a character in 'breakat'
116 set showbreak=↪ " show these chars for wrapped lines
117 set breakindent " preserve indentation in wrapped text
119 set lazyredraw " don't redraw while executing macros
121 set list " show chars defined in 'listchars'
122 set listchars=tab:❭\ " list of strings used for list mode
123 set listchars+=extends:❯,precedes:❮
124 " Only shown when not in insert mode
125 set listchars+=trail:·
128 au InsertEnter * :set listchars-=trail:·
129 au InsertLeave * :set listchars+=trail:·
132 set scrolloff=5 " number of screen lines to show around the cursor
133 set sidescroll=1 " number of collumns to scroll
134 set sidescrolloff=1 " don't scroll over the listchars
136 set fillchars=diff:⣿,vert:│
138 set nonumber " show the line number for each line
139 set norelativenumber " show the relative line number for each line
141 " syntax, highlighting and spelling {{{2
142 set synmaxcol=800 " don't highlight long lines
144 set dictionary=spell " list of dictionary files for keyword completion
148 " multiple windows {{{2
149 set laststatus=2 " 0, 1 or 2; when to use a status line for the last window
151 set previewheight=20 " default height for the preview window
155 " set splitbelow " a new window is put below of the current one
156 set splitright " a new window is put right of the current one
161 " using the mouse {{{2
162 set mouse=rnv " list of flags for using the mouse
163 set ttymouse=xterm " type of mouse
165 " messages and info {{{2
166 set showcmd " Show (partial) command in status line.
167 set ruler " show the cursor position all the time
168 set confirm " Ask what to do when closing unsaved documents
169 set shortmess= " reset option
170 set shortmess+=a " all abbreviations
171 set shortmess+=o " overwrite file-written message
172 set shortmess+=O " file-read message overrides previous
173 set shortmess+=t " truncate file message at start
174 set shortmess+=T " truncate other messages in the middle
175 set shortmess+=W " don't give 'written' or '[w]' when writing a file
176 set shortmess+=A " ignore swapfile warning
177 set shortmess+=I " no splash screen
180 set backspace=indent,eol,start " allow backspacing over everything in insert mode
182 set showmatch " Show matching brackets.
184 set nojoinspaces " don't use two spaces after '.' when joining a line
185 set formatoptions+=j " Delete comment leader when joining lines
186 set formatoptions+=c " Autowrap comments using textwidth
187 set formatoptions+=r " Insert comment leader after hitting <Enter>
188 set formatoptions+=n " Recognize numbered lists
189 set formatoptions+=q " Allow formatting of comments with "gq".
190 set formatoptions+=l " do not wrap lines that have been longer when starting insert mode already
191 set formatoptions+=t " Auto-wrap text using textwidth
192 set formatoptions-=o " Do not insert comment leader after hitting o or O in normal mode
194 set nrformats=hex " number formats recognized for CTRL-A and CTRL-X commands
196 set complete=. " scan the current buffer ( 'wrapscan' is ignored)
197 set complete+=w " scan buffers from other windows
198 set complete+=b " scan other loaded buffers that are in the buffer list
199 set complete+=u " scan the unloaded buffers that are in the buffer list
200 set complete+=t " scan tags
201 set complete+=i " scan current and included files
202 set complete+=kspell " use the currently active spell checking |spell|
204 " whether to use a popup menu for Insert mode completion
205 set completeopt=longest,menuone,preview
207 " tabs and indent {{{2
208 set shiftwidth=4 " number of spaces used for each step of (auto)indent
209 set smarttab " a <Tab> in an indent inserts 'shiftwidth' spaces
210 set softtabstop=4 " if non-zero, number of spaces to insert for a <Tab>
211 set shiftround " round to 'shiftwidth' for "<<" and ">>"
212 set expandtab " expand <Tab> to spaces in Insert mode
215 set pastetoggle=<F11> " key sequence to toggle paste mode
218 set foldmethod=marker " folding type
219 set foldlevelstart=0 " value for 'foldlevel' when starting to edit a file
221 " open folds when jumping to line
224 set viewoptions=cursor " save cursor position
225 set viewoptions+=folds " save folds
228 set diffopt+=filler " show filler lines
229 set diffopt+=vertical " always vertical split
230 set diffopt+=context:10 " 10 lines context between changes
232 " reading and writing files {{{2
233 set modeline " read modelines
234 set modelines=2 " only check first/last 2 lines
236 set writebackup " write a backup file before overwriting a file
237 set backup " keep a backup after owerwriting a file
238 set backupdir=$XDG_CACHE_HOME/vim/backup//
240 set backupskip+=.netrc " skip netrc
241 set backupskip+=/dev/shm/pass* " skip passwordstore files
243 set undofile " persistent undo history
244 set undodir=$XDG_CACHE_HOME/vim/undo//
248 au BufWritePre .netrc setlocal noundofile
249 au BufWritePre /dev/shm/pass* setlocal noundofile
250 au BufWritePre /tmp/* setlocal noundofile
253 set autowrite " automatically write a file when leaving a modified buffer
254 set autoread " automatically read a file that has been modified
258 set directory=$XDG_CACHE_HOME/vim/swap//
260 " command line editing {{{2
261 set history=5000 " how many command lines are remembered
262 set wildmenu " command-line completion shows a list of matches
263 set wildmode=longest:full,full " specifies how command line completion works
264 set wildignorecase " ignore case when completing file names
266 set wildignore+=.hg,.git,.svn " Version control
267 set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
268 set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
269 set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
270 set wildignore+=*.spl " compiled spelling word lists
271 set wildignore+=*.sw? " Vim swap files
272 set wildignore+=*.luac " Lua byte code
273 set wildignore+=*.pyc " Python byte code
274 set wildignore+=*.orig " Merge resolution files
276 " running make and jumping to errors {{{2
277 set makeprg=make\ -w " print changing directories
279 set grepprg=ag\ --vimgrep\ $*
281 " language specific {{{2
282 set isfname-== " don't treat `=` as being part of filenames
285 set virtualedit+=block " let cursor move past last char in <C-V> mode
286 set virtualedit+=onemore " allow the cursor to move just past the end of the line
287 set viminfo='100,<50,s10,h,n$XDG_CACHE_HOME/vim/viminfo " viminfo defaults but save file in .cache
289 set viewdir=$XDG_CACHE_HOME/vim/view//
291 set sessionoptions+=unix,slash " damn windows and it's silly ways
294 " Resize splits when the window is resized {{{2
297 autocmd VimResized * :wincmd =
300 " Only show cursorline in the current window and in normal mode {{{2
303 au WinLeave,InsertEnter * set nocursorline
304 au WinEnter,InsertLeave * set cursorline
307 " Treat buffers from stdin (e.g.: echo foo | vim -) as scratch {{{2
310 au StdinReadPost * :set buftype=nofile
313 " Jump to last known cursor position {{{2
316 " blacklist certain filetype
317 let blacklist = ['gitcommit']
318 autocmd BufReadPost *
319 \ if index(blacklist, &ft) < 0 && line("'\"") > 1 && line("'\"") <= line("$") |
320 \ exe "normal! g`\"" |
324 " Check for file modifications automatically {{{2
325 " (current buffer only)
326 " Use :NoAutoChecktime to disable it (uses b:autochecktime)
327 fun! MyAutoCheckTime()
328 " only check timestamp for normal files
329 if &buftype != '' | return | endif
330 if ! exists('b:autochecktime') || b:autochecktime
332 let b:autochecktime = 1
335 augroup MyAutoChecktime
337 au FocusGained,BufEnter,CursorHold,InsertEnter * call MyAutoCheckTime()
339 command! NoAutoChecktime let b:autochecktime=0
340 command! ToggleAutoChecktime let b:autochecktime=!get(b:, 'autochecktime', 0) | echom "b:autochecktime:" b:autochecktime
344 au TerminalOpen * if &buftype == 'terminal' | setlocal bufhidden=hide | endif
349 " allow both <space> and \ to be <leader>
355 if exists("b:make_dir")
356 let l:make_dir = "-C ".b:make_dir
357 elseif exists("g:make_dir")
358 let l:make_dir = "-C ".g:make_dir
361 let l:make_targets = ""
362 if exists("g:make_targets")
363 let l:make_targets = g:make_targets
365 execute "make! ".l:make_dir." ".l:make_targets
367 nnoremap <leader>r :call Make()<cr>
370 nnoremap <silent> <Leader>/ :silent nohl<CR>
373 nnoremap <leader>[ :tabprev<cr>
374 nnoremap <leader>] :tabnext<cr>
376 " paste from selection
377 nnoremap <leader>p* :silent! set paste<CR>"*p:set nopaste<CR>
378 " paste from clipboard
379 nnoremap <leader>p+ :silent! set paste<CR>"+p:set nopaste<CR>
381 " strip trailing whitespace
382 function! StripWhitespace(line1, line2, ...) " {{{2
383 let s_report = &report
385 let pattern = a:0 ? a:1 : '\s\+$'
386 let oldview = winsaveview()
387 exe 'keepjumps keeppatterns '.a:line1.','.a:line2.'substitute/'.pattern.'//e'
388 if oldview != winsaveview()
391 call winrestview(oldview)
392 let &report = s_report
394 command! -range=% -nargs=0 -bar Untrail keepjumps call StripWhitespace(<line1>,<line2>)
395 nnoremap <silent> <leader>ww :Untrail<CR>
398 vnoremap <leader>S y:execute @@<cr>:echo 'Sourced selection.'<cr>
399 nnoremap <leader>S ^vg_y:execute @@<cr>:echo 'Sourced line.'<cr>
401 " jump to last cursor position
404 " Select (charwise) the contents of the current line, excluding indentation.
408 nnoremap U :syntax sync fromstart<cr>:AirlineRefresh<cr>:redraw!<cr>
411 " nnoremap <leader>r :silent !ranger %:h<cr>:redraw!<cr>
412 " nnoremap <leader>R :silent !ranger<cr>:redraw!<cr>
419 " display the number of matches for the last search
420 nmap <Leader># :%s:<C-R>/::gn<CR>
422 " center cursor after search and open folds
426 " same when jumping around
429 nnoremap <c-o> <c-o>zzzv
430 nnoremap <c-i> <c-i>zzzv
432 " Not using the default mappings of 'To line from top/bottom'
438 " Heresy, emacs insert bindings
439 inoremap <C-A> <Esc>I
440 inoremap <C-E> <Esc>A
441 cnoremap <C-A> <Home>
444 " proper movement when lines are wrapped
445 noremap <silent><expr> j (v:count == 0 ? 'gj' : 'j')
446 noremap <silent><expr> k (v:count == 0 ? 'gk' : 'k')
452 noremap <Right> <NOP>
454 inoremap <Down> <NOP>
455 inoremap <Left> <NOP>
456 inoremap <Right> <NOP>
458 cnoremap <Down> <NOP>
459 cnoremap <Left> <NOP>
460 cnoremap <Right> <NOP>
462 cnoremap <C-J> <Down>
463 cnoremap <C-H> <Left>
464 cnoremap <C-L> <Right>
466 " close all folds open fold in cursor
469 map <F1> :ls<CR>:b<space>
471 " move between windows (skip previewwindow)
472 nnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
473 nnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
474 tnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
475 tnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
477 "xterm mouse with middleclick paste
478 nnoremap <MiddleMouse> i<MiddleMouse>
479 vnoremap <MiddleMouse> s<MiddleMouse>
481 " fix legacy vi inconsistency
486 " allow repeat operator on visual
487 vnoremap . :normal .<CR>
489 " add line without changing position or leaving mode
490 noremap <silent> <Leader>o :set paste<CR>m`o<ESC>``:set nopaste<CR>
491 noremap <silent> <Leader>O :set paste<CR>m`O<ESC>``:set nopaste<CR>
493 " Don't use Ex mode, use Q for formatting
496 " break undo sequence before removing word
497 inoremap <C-W> <C-G>u<C-W>
499 nnoremap coe :set <C-R>=&expandtab ? 'noexpandtab' : 'expandtab'<CR><CR>
500 nnoremap [oe :set expandtab<CR>
501 nnoremap ]oe :set noexpandtab<CR>
503 for idt in range(1,8)
504 exe 'nnoremap co'.idt.' :setlocal tabstop='.idt.' shiftwidth='.idt.' softtabstop='.idt.'<CR>'
507 " toggle auto format of text
508 nnoremap coa :set <C-R>=&formatoptions =~ "a" ? 'formatoptions-=a' : 'formatoptions+=a'<CR><CR>
509 nnoremap [oa :set formatoptions+=a<CR>
510 nnoremap ]oa :set formatoptions-=a<CR>
512 " space will toggle current fold in normal mode
513 nnoremap <leader><Space> za
514 " create folds around visual selection
515 vnoremap <leader><Space> zf
518 cabbrev w!! SudoWrite
520 " uppercase previous word
521 inoremap <C-C> <Esc>gUiwgi
523 " http://git.io/v3ZeU
524 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>
526 " plugins options {{{1
528 let g:airline#extensions#whitespace#enabled = 1
529 let g:airline#extensions#tabline#enabled = 1
530 let g:airline_powerline_fonts = 1
533 let g:checkattach_filebrowser = 'ranger'
534 let g:checkattach_once = 'y'
537 let delimitMate_expand_cr = 2
538 let g:delimitMate_expand_space = 1
541 nnoremap <silent> <Leader>ff :FSHere<CR>
542 nnoremap <silent> <Leader>fl :FSRight<CR>
543 nnoremap <silent> <Leader>fh :FSLeft<CR>
544 nnoremap <silent> <Leader>fj :FSBelow<CR>
545 nnoremap <silent> <Leader>fk :FSAbove<CR>
546 nnoremap <silent> <Leader>fL :FSSplitRight<CR>
547 nnoremap <silent> <Leader>fH :FSSplitLeft<CR>
548 nnoremap <silent> <Leader>fJ :FSSplitBelow<CR>
549 nnoremap <silent> <Leader>fK :FSSplitAbove<CR>
552 nmap <silent> <leader>dd :tab split \| Gdiff \| wincmd h<CR>
553 " delete fugitive buffers when closed
554 autocmd BufReadPost fugitive://* set bufhidden=delete
556 nnoremap <silent> <leader>gs :Gstatus<CR>
557 nnoremap <silent> <leader>gd :Gdiff<CR>
558 nnoremap <silent> <leader>gc :Gcommit -v<CR>
559 nnoremap <silent> <leader>ga :Gwrite<cr>
560 nnoremap <silent> <leader>gb :Gblame<cr>
562 augroup fugitive_gstatus
564 autocmd BufWinEnter */.git/index resize 16
568 nnoremap <F7> :GundoToggle<CR>
571 let g:indent_guides_default_mapping = 0
572 let g:indent_guides_guide_size = 1
573 nmap <silent> cog <Plug>IndentGuidesToggle
574 nmap <silent> [og <Plug>IndentGuidesEnable
575 nmap <silent> ]og <Plug>IndentGuidesDisable
577 " close-another-window {{{2
578 nnoremap <silent> <C-W>c <NOP>
579 nnoremap <silent> <C-W>cc <C-W>c
580 nnoremap <silent> <C-W>ch :CloseLeftWindow<CR>
581 nnoremap <silent> <C-W>cl :CloseRightWindow<CR>
582 nnoremap <silent> <C-W>cj :CloseBelowWindow<CR>
583 nnoremap <silent> <C-W>ck :CloseAboveWindow<CR>
587 let g:pymode_rope_completion = 0
588 let g:pymode_rope = 0
590 let g:pymode_folding = 1
591 let g:pymode_lint_ignore = "E221,E266,E501"
592 let g:pymode_lint_cwindow = 0 " don't open cwindow when linting
593 let g:pymode_syntax_space_errors = 0 " don't bother me when I'm typing
596 " disable '[ mappings
598 let g:SignatureMap = {
599 \ 'GotoNextLineAlpha' : "",
600 \ 'GotoPrevLineAlpha' : "",
601 \ 'GotoNextSpotAlpha' : "",
602 \ 'GotoPrevSpotAlpha' : "",
606 let g:switch_mapping = "<Leader>s"
609 nmap <silent> z] <Plug>(SpellRotateForward)
610 nmap <silent> z[ <Plug>(SpellRotateBackward)
611 vmap <silent> z] <Plug>(SpellRotateForwardV)
612 vmap <silent> z[ <Plug>(SpellRotateBackwardV)
615 let g:syntastic_enable_highlighting = 0
616 let g:syntastic_error_symbol='E'
617 let g:syntastic_style_error_symbol='S'
618 let g:syntastic_warning_symbol='W'
619 let g:syntastic_style_warning_symbol='S'
620 let g:syntastic_always_populate_loc_list=1
621 nmap <silent> <leader>y :SyntasticCheck<cr>
623 let g:syntastic_cpp_clang_tidy_post_args = "-p build*"
626 let g:syntastic_check_on_open=1
630 map <F5> :TagbarToggle<cr>
631 let g:tagbar_sort = 0
632 let g:tagbar_compact = 1
633 let g:tagbar_autoshowtag = 1
634 let g:tagbar_width = 25
635 let g:tagbar_iconchars = ['+', '-']
638 let g:tcomment_textobject_inlinecomment = 'gic'
639 let g:tcomment#filetype#guess = 0
642 let g:UltiSnipsEditSplit = 'vertical'
643 let g:UltiSnipsSnippetsDir = expand("$XDG_CONFIG_HOME/vim/ultisnips")
645 let g:UltiSnipsSnippetDirectories = ["UltiSnips", "ultisnips"]
647 let g:UltiSnipsExpandTrigger = "<tab>"
648 let g:UltiSnipsJumpForwardTrigger = "<tab>"
649 let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
651 " UltiSnips completion function that tries to expand a snippet. If there's no
652 " snippet for expanding, it checks for completion window and if it's shown,
653 " selects first element. If there's no completion window it tries to jump to
654 " next placeholder. If there's no placeholder it just returns TAB key
655 " https://github.com/Valloric/YouCompleteMe/issues/36#issuecomment-15451411
656 function! g:UltiSnips_Complete()
657 call UltiSnips#ExpandSnippet()
658 if g:ulti_expand_res == 0
662 call UltiSnips#JumpForwards()
663 if g:ulti_jump_forwards_res == 0
670 au InsertEnter * exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=g:UltiSnips_Complete()<cr>"
671 let g:UltiSnipsListSnippets="<c-e>"
674 call unite#filters#matcher_default#use(['matcher_fuzzy'])
675 call unite#custom#profile('default', 'context', {
677 \ 'direction': 'botright'
680 nnoremap [unite] <Nop>
681 nmap <leader>u [unite]
682 nnoremap [unite]u :UniteResume<CR>
683 nnoremap <silent> [u :UnitePrevious<CR>
684 nnoremap <silent> ]u :UniteNext<CR>
687 " seems not respected
688 let g:unite_source_grep_max_candidates = 2000
690 " Use ag in unite grep source.
691 let g:unite_source_grep_command = 'ag'
692 let g:unite_source_grep_default_opts = '--smart-case --vimgrep --ignore ''.hg'' --ignore ''.svn'' --ignore ''.git'' --ignore ''.bzr'''
693 let g:unite_source_grep_recursive_opt = ''
695 nnoremap <silent> [unite]a :<C-u>Unite grep:.::
\12\17<CR>
696 nnoremap <silent> [unite]A :<C-u>Unite grep:.:-w:
\12\17<CR>
697 command! -nargs=1 Ag Unite grep:.::<args>
699 " unite-file_rec {{{3
701 " Use ag in unite rec source
702 let g:unite_source_rec_async_command = ['ag', '--follow', '--nocolor', '--nogroup', '-g', '']
704 nnoremap <silent> [unite]f :<C-u>Unite -start-insert file_rec/async<CR>
705 call unite#custom#source('file_rec/async', 'sorters', 'sorter_selecta')
708 call unite#custom#default_action('buffer', 'open')
709 nnoremap <silent> [unite]b :<C-u>Unite buffer:-<CR>
712 let g:unite_source_menu_menus = {}
713 let g:unite_source_menu_menus.fugitive = { 'description' : 'fugitive menu'}
714 let g:unite_source_menu_menus.fugitive.command_candidates = {
715 \ 'Gstatus <Leader>gs' : 'Gstatus',
716 \ 'Gcommit -v <Leader>gc' : 'Gcommit -v',
720 nnoremap <silent> <leader>gg :<C-u>Unite menu:fugitive<CR>
722 let g:unite_source_history_yank_enable = 1
723 nnoremap <silent> [unite]p :<C-u>Unite history/yank<CR>
726 nnoremap <silent> <leader>p :YRShow<cr>
727 let g:yankring_history_dir = expand('$XDG_CACHE_HOME/vim')
728 let g:yankring_replace_n_pkey = ''
729 let g:yankring_replace_n_nkey = ''
731 " map Y to y$ for the yank ring
732 function! YRRunAfterMaps()
733 nnoremap Y :<C-U>YRYankCount 'y$'<CR>
737 let g:ycm_extra_conf_globlist = ['~/src/*','/mnt/data/src/*']
738 let g:ycm_global_ycm_extra_conf = expand('$XDG_CONFIG_HOME/vim/ycm_extra_conf.py')
739 let g:ycm_extra_conf_vim_data = ['getcwd()']
740 let g:ycm_add_preview_to_completeopt = 1
741 let g:ycm_complete_in_comments = 1
742 let g:ycm_complete_in_strings = 1
743 let g:ycm_autoclose_preview_window_after_insertion = 0
745 " vim-easy-align {{{2
746 " start interactive EasyAlign in visual mode
747 vmap <Enter> <Plug>(EasyAlign)
748 nmap ga <Plug>(EasyAlign)
751 let g:gtest#highlight_failing_tests = 0
753 nnoremap <Leader>tt :GTestRun<CR>
754 nnoremap <Leader>ta :GTestCase *<CR>:GTestName *<CR>:GTestRun<CR>
755 nnoremap <Leader>tu :GTestRunUnderCursor<CR>
758 let g:vim_json_syntax_conceal = 0
761 let g:sneak#streak = 1
762 let g:sneak#target_labels = "aoeuisnthdpylrcgfqjkxzmwvz" " dvorak
763 let g:sneak#use_ic_scs = 1 " follow 'ignorecase' and 'smartcase'
780 let g:vimwiki_list = [{'path': '$XDG_DATA_HOME/vimwiki'}]
781 let g:vimwiki_auto_chdir = 1
783 au! BufRead $XDG_DATA_HOME/vimwiki/index.wiki !git -C "%:p:h" pull -q
784 au! BufRead,BufNewFile $XDG_DATA_HOME/vimwiki/diary/*.wiki !git -C "%:p:h" pull -q
785 au! BufWritePost $XDG_DATA_HOME/vimwiki/*.wiki exe '!git add "<afile>";git commit -qm"' . strftime("%FT%R") . '";git push -q'
790 " Convenient command to see the difference between the current buffer and the
791 " file it was loaded from, thus the changes you made.
792 " Only define it when not defined already.
793 if !exists(":DiffOrig")
794 command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
795 \ | wincmd p | diffthis
799 function! SortLinesOpFunc(...)
802 nnoremap <silent> gs :<C-U>set operatorfunc=SortLinesOpFunc<CR>g@
803 vnoremap <silent> gs :sort<cr>
806 function! EditConfig(what, ext = '.vim')
807 let l:dir = split(&runtimepath,',')[0]
809 let l:file = expand($MYVIMRC)
810 elseif ! isdirectory(globpath(l:dir, a:what))
811 echoe a:what." is not valid!"
812 elseif empty(&filetype)
813 echoe 'filetype is empty!'
815 let l:file = l:dir.'/'.a:what.'/'.&filetype.a:ext
818 execute ':vsplit '.file
821 nmap <leader>ev :call EditConfig('vimrc')<CR>
822 nmap <leader>ef :call EditConfig('ftplugin')<CR>
823 nmap <leader>es :call EditConfig('syntax')<CR>
824 nmap <leader>ei :call EditConfig('indent')<CR>
825 nmap <leader>eu :call EditConfig('ultisnips', '.snippets')<CR>
828 " http://tex.stackexchange.com/a/52932
829 let g:myLangList=["en_gb","en_us","de","fr"]
831 function! ToggleSpell()
832 if !exists("b:myLang")
835 execute "setlocal spell!"
837 echo "setlocal spelllang=" g:myLangList[b:myLang]
841 function! SwitchSpell()
842 if !exists("b:myLang")
846 let b:myLang=b:myLang+1
847 if b:myLang>=len(g:myLangList) | let b:myLang=0 | endif
849 execute "setlocal spell spelllang=".get(g:myLangList, b:myLang)
850 echo "setlocal spelllang=" g:myLangList[b:myLang]
853 nnoremap <silent> coS :call SwitchSpell()<CR>
854 " fix spelling with first choice
855 nnoremap <Leader>f 1z=
857 " gitdir or home {{{2
859 " http://git.io/v3GAV
860 function! FindGitDirOrHome()
861 let filedir = expand('%:p:h')
862 if isdirectory(filedir)
863 let cmd = 'bash -c "(cd ' . filedir . '; git rev-parse --show-toplevel 2>/dev/null)"'
864 let gitdir = system(cmd)
865 if strlen(gitdir) == 0
875 command! Cdr execute('cd ' . FindGitDirOrHome())
877 command! LCdr execute('lcd ' . FindGitDirOrHome())
879 " vim:set et sw=2 ts=2 tw=78: