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'
68 Plug 'sirver/ultisnips'
69 Plug 'honza/vim-snippets'
72 Plug 'kana/vim-textobj-user'
73 Plug 'julian/vim-textobj-variable-segment'
74 Plug 'sgur/vim-textobj-parameter'
75 Plug 'kana/vim-operator-user'
78 " Check LucHermites plugins: https://github.com/LucHermitte/lh-cpp
79 Plug 'dense-analysis/ale' " {{{2
80 let g:ale_echo_msg_format = '[%linter%] %code: %%s'
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']
87 Plug 'neovimhaskell/haskell-vim' " {{{2
88 let g:haskell_enable_quantification = 1 " to enable highlighting of `forall`
89 let g:haskell_enable_recursivedo = 1 " to enable highlighting of `mdo` and `rec`
90 let g:haskell_enable_arrowsyntax = 1 " to enable highlighting of `proc`
91 let g:haskell_enable_pattern_synonyms = 1 " to enable highlighting of `pattern`
92 let g:haskell_enable_typeroles = 1 " to enable highlighting of type roles
93 let g:haskell_enable_static_pointers = 1 " to enable highlighting of `static`
94 let g:haskell_backpack = 1 " to enable highlighting of backpack keywords
97 Plug 'aklt/plantuml-syntax'
99 Plug 'mtth/scratch.vim' " {{{2
100 let g:scratch_no_mappings = 1
105 filetype plugin indent on
110 let g:gruvbox_contrast_dark = 'hard'
111 let g:gruvbox_contrast_light = 'soft'
113 " override the background to be black
114 highligh Normal ctermbg=None
117 " moving around, searching and patterns {{{2
118 set incsearch " show match for partly typed search command
119 set ignorecase " ignore case when using a search pattern
120 set smartcase " override 'ignorecase' when pattern has upper case characters
121 set hlsearch " highlight all matches for the last used search pattern
123 set nostartofline " don't move the cursor to the first non-blank char of a line
126 set path+=../include/
127 set path+=/usr/include/c++/*
129 " displaying text {{{2
130 set nowrap " long lines wrap
131 set linebreak " wrap long lines at a character in 'breakat'
132 set showbreak=↪ " show these chars for wrapped lines
133 set breakindent " preserve indentation in wrapped text
135 set lazyredraw " don't redraw while executing macros
137 set list " show chars defined in 'listchars'
138 set listchars=tab:❭\ " list of strings used for list mode
139 set listchars+=extends:❯,precedes:❮
140 " Only shown when not in insert mode
141 set listchars+=trail:·
144 au InsertEnter * :set listchars-=trail:·
145 au InsertLeave * :set listchars+=trail:·
148 set scrolloff=5 " number of screen lines to show around the cursor
149 set sidescroll=1 " number of collumns to scroll
150 set sidescrolloff=1 " don't scroll over the listchars
152 set fillchars=diff:⣿,vert:│
154 set nonumber " show the line number for each line
155 set norelativenumber " show the relative line number for each line
157 " syntax, highlighting and spelling {{{2
158 set synmaxcol=800 " don't highlight long lines
160 set dictionary=spell " list of dictionary files for keyword completion
164 " multiple windows {{{2
165 set laststatus=2 " 0, 1 or 2; when to use a status line for the last window
167 set previewheight=20 " default height for the preview window
171 " set splitbelow " a new window is put below of the current one
172 set splitright " a new window is put right of the current one
177 " using the mouse {{{2
178 set mouse=rnv " list of flags for using the mouse
179 set ttymouse=xterm " type of mouse
181 " messages and info {{{2
182 set showcmd " Show (partial) command in status line.
183 set ruler " show the cursor position all the time
184 set confirm " Ask what to do when closing unsaved documents
185 set shortmess= " reset option
186 set shortmess+=a " all abbreviations
187 set shortmess+=o " overwrite file-written message
188 set shortmess+=O " file-read message overrides previous
189 set shortmess+=t " truncate file message at start
190 set shortmess+=T " truncate other messages in the middle
191 set shortmess+=W " don't give 'written' or '[w]' when writing a file
192 set shortmess+=A " ignore swapfile warning
193 set shortmess+=I " no splash screen
196 set backspace=indent,eol,start " allow backspacing over everything in insert mode
198 set showmatch " Show matching brackets.
200 set nojoinspaces " don't use two spaces after '.' when joining a line
201 set formatoptions+=j " Delete comment leader when joining lines
202 set formatoptions+=c " Autowrap comments using textwidth
203 set formatoptions+=r " Insert comment leader after hitting <Enter>
204 set formatoptions+=n " Recognize numbered lists
205 set formatoptions+=q " Allow formatting of comments with "gq".
206 set formatoptions+=l " do not wrap lines that have been longer when starting insert mode already
207 set formatoptions+=t " Auto-wrap text using textwidth
208 set formatoptions-=o " Do not insert comment leader after hitting o or O in normal mode
210 set nrformats=hex " number formats recognized for CTRL-A and CTRL-X commands
212 set complete=. " scan the current buffer ( 'wrapscan' is ignored)
213 set complete+=w " scan buffers from other windows
214 set complete+=b " scan other loaded buffers that are in the buffer list
215 set complete+=u " scan the unloaded buffers that are in the buffer list
216 set complete+=t " scan tags
217 set complete+=i " scan current and included files
218 set complete+=kspell " use the currently active spell checking |spell|
220 " whether to use a popup menu for Insert mode completion
221 set completeopt=longest,menuone,preview
223 " tabs and indent {{{2
224 set shiftwidth=4 " number of spaces used for each step of (auto)indent
225 set smarttab " a <Tab> in an indent inserts 'shiftwidth' spaces
226 set softtabstop=4 " if non-zero, number of spaces to insert for a <Tab>
227 set shiftround " round to 'shiftwidth' for "<<" and ">>"
228 set expandtab " expand <Tab> to spaces in Insert mode
231 set pastetoggle=<F11> " key sequence to toggle paste mode
234 set foldmethod=marker " folding type
235 set foldlevelstart=0 " value for 'foldlevel' when starting to edit a file
237 " open folds when jumping to line
240 set viewoptions=cursor " save cursor position
241 set viewoptions+=folds " save folds
244 set diffopt+=filler " show filler lines
245 set diffopt+=vertical " always vertical split
246 set diffopt+=context:10 " 10 lines context between changes
248 " reading and writing files {{{2
249 set modeline " read modelines
250 set modelines=2 " only check first/last 2 lines
252 set writebackup " write a backup file before overwriting a file
253 set backup " keep a backup after owerwriting a file
254 set backupdir=$XDG_CACHE_HOME/vim/backup//
256 set backupskip+=.netrc " skip netrc
257 set backupskip+=/dev/shm/pass* " skip passwordstore files
259 set undofile " persistent undo history
260 set undodir=$XDG_CACHE_HOME/vim/undo//
264 au BufWritePre .netrc setlocal noundofile
265 au BufWritePre /dev/shm/pass* setlocal noundofile
266 au BufWritePre /tmp/* setlocal noundofile
269 set autowrite " automatically write a file when leaving a modified buffer
270 set autoread " automatically read a file that has been modified
274 set directory=$XDG_CACHE_HOME/vim/swap//
276 " command line editing {{{2
277 set history=5000 " how many command lines are remembered
278 set wildmenu " command-line completion shows a list of matches
279 set wildmode=longest:full,full " specifies how command line completion works
280 set wildignorecase " ignore case when completing file names
282 set wildignore+=.hg,.git,.svn " Version control
283 set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
284 set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
285 set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
286 set wildignore+=*.spl " compiled spelling word lists
287 set wildignore+=*.sw? " Vim swap files
288 set wildignore+=*.luac " Lua byte code
289 set wildignore+=*.pyc " Python byte code
290 set wildignore+=*.orig " Merge resolution files
292 " running make and jumping to errors {{{2
293 set makeprg=make\ -w " print changing directories
295 set grepprg=ag\ --vimgrep\ $*
297 " language specific {{{2
298 set isfname-== " don't treat `=` as being part of filenames
301 set virtualedit+=block " let cursor move past last char in <C-V> mode
302 set virtualedit+=onemore " allow the cursor to move just past the end of the line
303 set viminfo='100,<50,s10,h,n$XDG_CACHE_HOME/vim/viminfo " viminfo defaults but save file in .cache
305 set viewdir=$XDG_CACHE_HOME/vim/view//
307 set sessionoptions+=unix,slash " damn windows and it's silly ways
310 " Resize splits when the window is resized {{{2
313 autocmd VimResized * :wincmd =
316 " Only show cursorline in the current window and in normal mode {{{2
319 au WinLeave,InsertEnter * set nocursorline
320 au WinEnter,InsertLeave * set cursorline
323 " Treat buffers from stdin (e.g.: echo foo | vim -) as scratch {{{2
326 au StdinReadPost * :set buftype=nofile
329 " Jump to last known cursor position {{{2
332 " blacklist certain filetype
333 let blacklist = ['gitcommit']
334 autocmd BufReadPost *
335 \ if index(blacklist, &ft) < 0 && line("'\"") > 1 && line("'\"") <= line("$") |
336 \ exe "normal! g`\"" |
340 " Check for file modifications automatically {{{2
341 " (current buffer only)
342 " Use :NoAutoChecktime to disable it (uses b:autochecktime)
343 fun! MyAutoCheckTime()
344 " only check timestamp for normal files
345 if &buftype != '' | return | endif
346 if ! exists('b:autochecktime') || b:autochecktime
348 let b:autochecktime = 1
351 augroup MyAutoChecktime
353 au FocusGained,BufEnter,CursorHold,InsertEnter * call MyAutoCheckTime()
355 command! NoAutoChecktime let b:autochecktime=0
356 command! ToggleAutoChecktime let b:autochecktime=!get(b:, 'autochecktime', 0) | echom "b:autochecktime:" b:autochecktime
360 au TerminalOpen * if &buftype == 'terminal' | setlocal bufhidden=hide | endif
365 " allow both <space> and \ to be <leader>
371 if exists("b:make_dir")
372 let l:make_dir = "-C ".b:make_dir
373 elseif exists("g:make_dir")
374 let l:make_dir = "-C ".g:make_dir
377 let l:make_targets = ""
378 if exists("g:make_targets")
379 let l:make_targets = g:make_targets
381 execute "make! ".l:make_dir." ".l:make_targets
383 nnoremap <leader>r :call Make()<cr>
386 nnoremap <silent> <Leader>/ :silent nohl<CR>
389 nnoremap <leader>[ :tabprev<cr>
390 nnoremap <leader>] :tabnext<cr>
392 " paste from selection
393 nnoremap <leader>p* :silent! set paste<CR>"*p:set nopaste<CR>
394 " paste from clipboard
395 nnoremap <leader>p+ :silent! set paste<CR>"+p:set nopaste<CR>
397 " strip trailing whitespace
398 function! StripWhitespace(line1, line2, ...) " {{{2
399 let s_report = &report
401 let pattern = a:0 ? a:1 : '\s\+$'
402 let oldview = winsaveview()
403 exe 'keepjumps keeppatterns '.a:line1.','.a:line2.'substitute/'.pattern.'//e'
404 if oldview != winsaveview()
407 call winrestview(oldview)
408 let &report = s_report
410 command! -range=% -nargs=0 -bar Untrail keepjumps call StripWhitespace(<line1>,<line2>)
411 nnoremap <silent> <leader>ww :Untrail<CR>
414 vnoremap <leader>S y:execute @@<cr>:echo 'Sourced selection.'<cr>
415 nnoremap <leader>S ^vg_y:execute @@<cr>:echo 'Sourced line.'<cr>
417 " jump to last cursor position
420 " Select (charwise) the contents of the current line, excluding indentation.
424 nnoremap U :syntax sync fromstart<cr>:AirlineRefresh<cr>:redraw!<cr>
427 " nnoremap <leader>r :silent !ranger %:h<cr>:redraw!<cr>
428 " nnoremap <leader>R :silent !ranger<cr>:redraw!<cr>
435 " display the number of matches for the last search
436 nmap <Leader># :%s:<C-R>/::gn<CR>
438 " center cursor after search and open folds
442 " same when jumping around
445 nnoremap <c-o> <c-o>zzzv
446 nnoremap <c-i> <c-i>zzzv
448 " Not using the default mappings of 'To line from top/bottom'
454 " Heresy, emacs insert bindings
455 inoremap <C-A> <Esc>I
456 inoremap <C-E> <Esc>A
457 cnoremap <C-A> <Home>
460 " proper movement when lines are wrapped
461 noremap <silent><expr> j (v:count == 0 ? 'gj' : 'j')
462 noremap <silent><expr> k (v:count == 0 ? 'gk' : 'k')
468 noremap <Right> <NOP>
470 inoremap <Down> <NOP>
471 inoremap <Left> <NOP>
472 inoremap <Right> <NOP>
474 cnoremap <Down> <NOP>
475 cnoremap <Left> <NOP>
476 cnoremap <Right> <NOP>
478 cnoremap <C-J> <Down>
479 cnoremap <C-H> <Left>
480 cnoremap <C-L> <Right>
482 " close all folds open fold in cursor
485 map <F1> :ls<CR>:b<space>
487 " move between windows (skip previewwindow)
488 nnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
489 nnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
490 tnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
491 tnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
493 "xterm mouse with middleclick paste
494 nnoremap <MiddleMouse> i<MiddleMouse>
495 vnoremap <MiddleMouse> s<MiddleMouse>
497 " fix legacy vi inconsistency
502 " allow repeat operator on visual
503 vnoremap . :normal .<CR>
505 " add line without changing position or leaving mode
506 noremap <silent> <Leader>o :set paste<CR>m`o<ESC>``:set nopaste<CR>
507 noremap <silent> <Leader>O :set paste<CR>m`O<ESC>``:set nopaste<CR>
509 " Don't use Ex mode, use Q for formatting
512 " break undo sequence before removing word
513 inoremap <C-W> <C-G>u<C-W>
515 nnoremap coe :set <C-R>=&expandtab ? 'noexpandtab' : 'expandtab'<CR><CR>
516 nnoremap [oe :set expandtab<CR>
517 nnoremap ]oe :set noexpandtab<CR>
519 for idt in range(1,8)
520 exe 'nnoremap co'.idt.' :setlocal tabstop='.idt.' shiftwidth='.idt.' softtabstop='.idt.'<CR>'
523 " toggle auto format of text
524 nnoremap coa :set <C-R>=&formatoptions =~ "a" ? 'formatoptions-=a' : 'formatoptions+=a'<CR><CR>
525 nnoremap [oa :set formatoptions+=a<CR>
526 nnoremap ]oa :set formatoptions-=a<CR>
528 " space will toggle current fold in normal mode
529 nnoremap <leader><Space> za
530 " create folds around visual selection
531 vnoremap <leader><Space> zf
534 cabbrev w!! SudoWrite
536 " uppercase previous word
537 inoremap <C-C> <Esc>gUiwgi
539 " http://git.io/v3ZeU
540 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>
542 " plugins options {{{1
544 let g:airline#extensions#whitespace#enabled = 1
545 let g:airline#extensions#tabline#enabled = 1
546 let g:airline_powerline_fonts = 1
549 let g:checkattach_filebrowser = 'ranger'
550 let g:checkattach_once = 'y'
553 let delimitMate_expand_cr = 2
554 let g:delimitMate_expand_space = 1
557 nnoremap <silent> <Leader>ff :FSHere<CR>
558 nnoremap <silent> <Leader>fl :FSRight<CR>
559 nnoremap <silent> <Leader>fh :FSLeft<CR>
560 nnoremap <silent> <Leader>fj :FSBelow<CR>
561 nnoremap <silent> <Leader>fk :FSAbove<CR>
562 nnoremap <silent> <Leader>fL :FSSplitRight<CR>
563 nnoremap <silent> <Leader>fH :FSSplitLeft<CR>
564 nnoremap <silent> <Leader>fJ :FSSplitBelow<CR>
565 nnoremap <silent> <Leader>fK :FSSplitAbove<CR>
568 nmap <silent> <leader>dd :tab split \| Gdiff \| wincmd h<CR>
569 " delete fugitive buffers when closed
570 autocmd BufReadPost fugitive://* set bufhidden=delete
572 nnoremap <silent> <leader>gs :Git<CR>
573 nnoremap <silent> <leader>gd :Gdiffsplit<CR>
574 nnoremap <silent> <leader>gc :tab G commit -v<CR>
575 nnoremap <silent> <leader>ga :Gwrite<cr>
576 nnoremap <silent> <leader>gb :G blame<cr>
578 augroup fugitive_gstatus
580 autocmd BufWinEnter */.git/index resize 16
584 nnoremap <F7> :GundoToggle<CR>
587 let g:indent_guides_default_mapping = 0
588 let g:indent_guides_guide_size = 1
589 nmap <silent> cog <Plug>IndentGuidesToggle
590 nmap <silent> [og <Plug>IndentGuidesEnable
591 nmap <silent> ]og <Plug>IndentGuidesDisable
593 " close-another-window {{{2
594 nnoremap <silent> <C-W>c <NOP>
595 nnoremap <silent> <C-W>cc <C-W>c
596 nnoremap <silent> <C-W>ch :CloseLeftWindow<CR>
597 nnoremap <silent> <C-W>cl :CloseRightWindow<CR>
598 nnoremap <silent> <C-W>cj :CloseBelowWindow<CR>
599 nnoremap <silent> <C-W>ck :CloseAboveWindow<CR>
603 let g:pymode_rope_completion = 0
604 let g:pymode_rope = 0
606 let g:pymode_folding = 1
607 let g:pymode_lint_ignore = "E221,E266,E501"
608 let g:pymode_lint_cwindow = 0 " don't open cwindow when linting
609 let g:pymode_syntax_space_errors = 0 " don't bother me when I'm typing
612 " disable '[ mappings
614 let g:SignatureMap = {
615 \ 'GotoNextLineAlpha' : "",
616 \ 'GotoPrevLineAlpha' : "",
617 \ 'GotoNextSpotAlpha' : "",
618 \ 'GotoPrevSpotAlpha' : "",
622 let g:switch_mapping = "<Leader>s"
625 nmap <silent> z] <Plug>(SpellRotateForward)
626 nmap <silent> z[ <Plug>(SpellRotateBackward)
627 vmap <silent> z] <Plug>(SpellRotateForwardV)
628 vmap <silent> z[ <Plug>(SpellRotateBackwardV)
631 let g:syntastic_enable_highlighting = 0
632 let g:syntastic_error_symbol='E'
633 let g:syntastic_style_error_symbol='S'
634 let g:syntastic_warning_symbol='W'
635 let g:syntastic_style_warning_symbol='S'
636 let g:syntastic_always_populate_loc_list=1
637 nmap <silent> <leader>y :SyntasticCheck<cr>
639 let g:syntastic_cpp_clang_tidy_post_args = "-p build*"
642 let g:syntastic_check_on_open=1
646 map <F5> :TagbarToggle<cr>
647 let g:tagbar_sort = 0
648 let g:tagbar_compact = 1
649 let g:tagbar_autoshowtag = 1
650 let g:tagbar_width = 25
651 let g:tagbar_iconchars = ['+', '-']
654 let g:tcomment_textobject_inlinecomment = 'gic'
655 let g:tcomment#filetype#guess = 0
658 let g:UltiSnipsEditSplit = 'vertical'
659 let g:UltiSnipsSnippetDirectories = [ expand("$XDG_CONFIG_HOME/vim/ultisnips") ]
661 let g:UltiSnipsSnippetDirectories = ["UltiSnips", "ultisnips"]
663 let g:UltiSnipsExpandTrigger = "<tab>"
664 let g:UltiSnipsJumpForwardTrigger = "<tab>"
665 let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
667 " UltiSnips completion function that tries to expand a snippet. If there's no
668 " snippet for expanding, it checks for completion window and if it's shown,
669 " selects first element. If there's no completion window it tries to jump to
670 " next placeholder. If there's no placeholder it just returns TAB key
671 " https://github.com/Valloric/YouCompleteMe/issues/36#issuecomment-15451411
672 function! g:UltiSnips_Complete()
673 call UltiSnips#ExpandSnippet()
674 if g:ulti_expand_res == 0
678 call UltiSnips#JumpForwards()
679 if g:ulti_jump_forwards_res == 0
686 au InsertEnter * exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=g:UltiSnips_Complete()<cr>"
687 let g:UltiSnipsListSnippets="<c-e>"
690 call unite#filters#matcher_default#use(['matcher_fuzzy'])
691 call unite#custom#profile('default', 'context', {
693 \ 'direction': 'botright'
696 nnoremap [unite] <Nop>
697 nmap <leader>u [unite]
698 nnoremap [unite]u :UniteResume<CR>
699 nnoremap <silent> [u :UnitePrevious<CR>
700 nnoremap <silent> ]u :UniteNext<CR>
703 " seems not respected
704 let g:unite_source_grep_max_candidates = 2000
706 " Use ag in unite grep source.
707 let g:unite_source_grep_command = 'ag'
708 let g:unite_source_grep_default_opts = '--smart-case --vimgrep --ignore ''.hg'' --ignore ''.svn'' --ignore ''.git'' --ignore ''.bzr'''
709 let g:unite_source_grep_recursive_opt = ''
711 nnoremap <silent> [unite]a :<C-u>Unite grep:.::
\12\17<CR>
712 nnoremap <silent> [unite]A :<C-u>Unite grep:.:-w:
\12\17<CR>
713 command! -nargs=1 Ag Unite grep:.::<args>
715 " unite-file_rec {{{3
717 " Use ag in unite rec source
718 let g:unite_source_rec_async_command = ['ag', '--follow', '--nocolor', '--nogroup', '-g', '']
720 nnoremap <silent> [unite]f :<C-u>Unite -start-insert file_rec/async<CR>
721 call unite#custom#source('file_rec/async', 'sorters', 'sorter_selecta')
724 call unite#custom#default_action('buffer', 'open')
725 nnoremap <silent> [unite]b :<C-u>Unite buffer:-<CR>
727 " unite-jumplist {{{3
728 nnoremap <silent> [unite]j :<C-u>Unite output:jumps:<CR>
731 let g:unite_source_menu_menus = {}
732 let g:unite_source_menu_menus.fugitive = { 'description' : 'fugitive menu'}
733 let g:unite_source_menu_menus.fugitive.command_candidates = {
734 \ 'Gstatus <Leader>gs' : 'Gstatus',
735 \ 'Gcommit -v <Leader>gc' : 'Gcommit -v',
739 nnoremap <silent> <leader>gg :<C-u>Unite menu:fugitive<CR>
741 let g:unite_source_history_yank_enable = 1
742 nnoremap <silent> [unite]p :<C-u>Unite history/yank<CR>
745 nnoremap <silent> <leader>p :YRShow<cr>
746 let g:yankring_history_dir = expand('$XDG_CACHE_HOME/vim')
747 let g:yankring_replace_n_pkey = ''
748 let g:yankring_replace_n_nkey = ''
750 " map Y to y$ for the yank ring
751 function! YRRunAfterMaps()
752 nnoremap Y :<C-U>YRYankCount 'y$'<CR>
756 let g:ycm_clangd_binary_path = 'clangd' " use clangd in path
757 let g:ycm_clangd_args = ['--clang-tidy']
758 let g:ycm_extra_conf_vim_data = ['getcwd()']
759 let g:ycm_add_preview_to_completeopt = 1
760 let g:ycm_complete_in_comments = 1
761 let g:ycm_complete_in_strings = 1
762 let g:ycm_autoclose_preview_window_after_insertion = 0
764 " vim-easy-align {{{2
765 " start interactive EasyAlign in visual mode
766 vmap <Enter> <Plug>(EasyAlign)
767 nmap ga <Plug>(EasyAlign)
770 let g:gtest#highlight_failing_tests = 0
772 nnoremap <silent> <Leader>tt :GTestRun<CR>
773 nnoremap <Leader>tc :GTestCase<space>
774 nnoremap <Leader>tn :GTestName<space>
775 nnoremap <silent> <Leader>ta :GTestCase *<CR>:GTestName *<CR>:GTestRun<CR>
776 nnoremap <silent> <Leader>tu :GTestRunUnderCursor<CR>
779 let g:vim_json_syntax_conceal = 0
782 let g:sneak#streak = 1
783 let g:sneak#target_labels = "aoeuisnthdpylrcgfqjkxzmwvz" " dvorak
784 let g:sneak#use_ic_scs = 1 " follow 'ignorecase' and 'smartcase'
802 " Convenient command to see the difference between the current buffer and the
803 " file it was loaded from, thus the changes you made.
804 " Only define it when not defined already.
805 if !exists(":DiffOrig")
806 command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
807 \ | wincmd p | diffthis
811 function! SortLinesOpFunc(...)
814 nnoremap <silent> gs :<C-U>set operatorfunc=SortLinesOpFunc<CR>g@
815 vnoremap <silent> gs :sort<cr>
818 function! EditConfig(what, ext = '.vim')
819 let l:dir = split(&runtimepath,',')[0]
821 let l:file = expand($MYVIMRC)
822 elseif ! isdirectory(globpath(l:dir, a:what))
823 echoe a:what." is not valid!"
824 elseif empty(&filetype)
825 echoe 'filetype is empty!'
827 let l:file = l:dir.'/'.a:what.'/'.&filetype.a:ext
830 execute ':vsplit '.file
833 nmap <leader>ev :call EditConfig('vimrc')<CR>
834 nmap <leader>ef :call EditConfig('ftplugin')<CR>
835 nmap <leader>es :call EditConfig('syntax')<CR>
836 nmap <leader>ei :call EditConfig('indent')<CR>
837 nmap <leader>eu :call EditConfig('ultisnips', '.snippets')<CR>
840 " http://tex.stackexchange.com/a/52932
841 let g:myLangList=["en_gb","en_us","de","fr"]
843 function! ToggleSpell()
844 if !exists("b:myLang")
847 execute "setlocal spell!"
849 echo "setlocal spelllang=" g:myLangList[b:myLang]
853 function! SwitchSpell()
854 if !exists("b:myLang")
858 let b:myLang=b:myLang+1
859 if b:myLang>=len(g:myLangList) | let b:myLang=0 | endif
861 execute "setlocal spell spelllang=".get(g:myLangList, b:myLang)
862 echo "setlocal spelllang=" g:myLangList[b:myLang]
865 nnoremap <silent> coS :call SwitchSpell()<CR>
866 " fix spelling with first choice
867 nnoremap <Leader>f 1z=
869 " gitdir or home {{{2
871 " http://git.io/v3GAV
872 function! FindGitDirOrHome()
873 let filedir = expand('%:p:h')
874 if isdirectory(filedir)
875 let cmd = 'bash -c "(cd ' . filedir . '; git rev-parse --show-toplevel 2>/dev/null)"'
876 let gitdir = system(cmd)
877 if strlen(gitdir) == 0
887 command! Cdr execute('cd ' . FindGitDirOrHome())
889 command! LCdr execute('lcd ' . FindGitDirOrHome())
891 " vim:set et sw=2 ts=2 tw=78: