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'
101 filetype plugin indent on
106 let g:gruvbox_contrast_dark = 'hard'
107 let g:gruvbox_contrast_light = 'soft'
109 " override the background to be black
110 highligh Normal ctermbg=None
113 " moving around, searching and patterns {{{2
114 set incsearch " show match for partly typed search command
115 set ignorecase " ignore case when using a search pattern
116 set smartcase " override 'ignorecase' when pattern has upper case characters
117 set hlsearch " highlight all matches for the last used search pattern
119 set nostartofline " don't move the cursor to the first non-blank char of a line
122 set path+=../include/
123 set path+=/usr/include/c++/*
125 " displaying text {{{2
126 set nowrap " long lines wrap
127 set linebreak " wrap long lines at a character in 'breakat'
128 set showbreak=↪ " show these chars for wrapped lines
129 set breakindent " preserve indentation in wrapped text
131 set lazyredraw " don't redraw while executing macros
133 set list " show chars defined in 'listchars'
134 set listchars=tab:❭\ " list of strings used for list mode
135 set listchars+=extends:❯,precedes:❮
136 " Only shown when not in insert mode
137 set listchars+=trail:·
140 au InsertEnter * :set listchars-=trail:·
141 au InsertLeave * :set listchars+=trail:·
144 set scrolloff=5 " number of screen lines to show around the cursor
145 set sidescroll=1 " number of collumns to scroll
146 set sidescrolloff=1 " don't scroll over the listchars
148 set fillchars=diff:⣿,vert:│
150 set nonumber " show the line number for each line
151 set norelativenumber " show the relative line number for each line
153 " syntax, highlighting and spelling {{{2
154 set synmaxcol=800 " don't highlight long lines
156 set dictionary=spell " list of dictionary files for keyword completion
160 " multiple windows {{{2
161 set laststatus=2 " 0, 1 or 2; when to use a status line for the last window
163 set previewheight=20 " default height for the preview window
167 " set splitbelow " a new window is put below of the current one
168 set splitright " a new window is put right of the current one
173 " using the mouse {{{2
174 set mouse=rnv " list of flags for using the mouse
175 set ttymouse=xterm " type of mouse
177 " messages and info {{{2
178 set showcmd " Show (partial) command in status line.
179 set ruler " show the cursor position all the time
180 set confirm " Ask what to do when closing unsaved documents
181 set shortmess= " reset option
182 set shortmess+=a " all abbreviations
183 set shortmess+=o " overwrite file-written message
184 set shortmess+=O " file-read message overrides previous
185 set shortmess+=t " truncate file message at start
186 set shortmess+=T " truncate other messages in the middle
187 set shortmess+=W " don't give 'written' or '[w]' when writing a file
188 set shortmess+=A " ignore swapfile warning
189 set shortmess+=I " no splash screen
192 set backspace=indent,eol,start " allow backspacing over everything in insert mode
194 set showmatch " Show matching brackets.
196 set nojoinspaces " don't use two spaces after '.' when joining a line
197 set formatoptions+=j " Delete comment leader when joining lines
198 set formatoptions+=c " Autowrap comments using textwidth
199 set formatoptions+=r " Insert comment leader after hitting <Enter>
200 set formatoptions+=n " Recognize numbered lists
201 set formatoptions+=q " Allow formatting of comments with "gq".
202 set formatoptions+=l " do not wrap lines that have been longer when starting insert mode already
203 set formatoptions+=t " Auto-wrap text using textwidth
204 set formatoptions-=o " Do not insert comment leader after hitting o or O in normal mode
206 set nrformats=hex " number formats recognized for CTRL-A and CTRL-X commands
208 set complete=. " scan the current buffer ( 'wrapscan' is ignored)
209 set complete+=w " scan buffers from other windows
210 set complete+=b " scan other loaded buffers that are in the buffer list
211 set complete+=u " scan the unloaded buffers that are in the buffer list
212 set complete+=t " scan tags
213 set complete+=i " scan current and included files
214 set complete+=kspell " use the currently active spell checking |spell|
216 " whether to use a popup menu for Insert mode completion
217 set completeopt=longest,menuone,preview
219 " tabs and indent {{{2
220 set shiftwidth=4 " number of spaces used for each step of (auto)indent
221 set smarttab " a <Tab> in an indent inserts 'shiftwidth' spaces
222 set softtabstop=4 " if non-zero, number of spaces to insert for a <Tab>
223 set shiftround " round to 'shiftwidth' for "<<" and ">>"
224 set expandtab " expand <Tab> to spaces in Insert mode
227 set pastetoggle=<F11> " key sequence to toggle paste mode
230 set foldmethod=marker " folding type
231 set foldlevelstart=0 " value for 'foldlevel' when starting to edit a file
233 " open folds when jumping to line
236 set viewoptions=cursor " save cursor position
237 set viewoptions+=folds " save folds
240 set diffopt+=filler " show filler lines
241 set diffopt+=vertical " always vertical split
242 set diffopt+=context:10 " 10 lines context between changes
244 " reading and writing files {{{2
245 set modeline " read modelines
246 set modelines=2 " only check first/last 2 lines
248 set writebackup " write a backup file before overwriting a file
249 set backup " keep a backup after owerwriting a file
250 set backupdir=$XDG_CACHE_HOME/vim/backup//
252 set backupskip+=.netrc " skip netrc
253 set backupskip+=/dev/shm/pass* " skip passwordstore files
255 set undofile " persistent undo history
256 set undodir=$XDG_CACHE_HOME/vim/undo//
260 au BufWritePre .netrc setlocal noundofile
261 au BufWritePre /dev/shm/pass* setlocal noundofile
262 au BufWritePre /tmp/* setlocal noundofile
265 set autowrite " automatically write a file when leaving a modified buffer
266 set autoread " automatically read a file that has been modified
270 set directory=$XDG_CACHE_HOME/vim/swap//
272 " command line editing {{{2
273 set history=5000 " how many command lines are remembered
274 set wildmenu " command-line completion shows a list of matches
275 set wildmode=longest:full,full " specifies how command line completion works
276 set wildignorecase " ignore case when completing file names
278 set wildignore+=.hg,.git,.svn " Version control
279 set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
280 set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
281 set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
282 set wildignore+=*.spl " compiled spelling word lists
283 set wildignore+=*.sw? " Vim swap files
284 set wildignore+=*.luac " Lua byte code
285 set wildignore+=*.pyc " Python byte code
286 set wildignore+=*.orig " Merge resolution files
288 " running make and jumping to errors {{{2
289 set makeprg=make\ -w " print changing directories
291 set grepprg=ag\ --vimgrep\ $*
293 " language specific {{{2
294 set isfname-== " don't treat `=` as being part of filenames
297 set virtualedit+=block " let cursor move past last char in <C-V> mode
298 set virtualedit+=onemore " allow the cursor to move just past the end of the line
299 set viminfo='100,<50,s10,h,n$XDG_CACHE_HOME/vim/viminfo " viminfo defaults but save file in .cache
301 set viewdir=$XDG_CACHE_HOME/vim/view//
303 set sessionoptions+=unix,slash " damn windows and it's silly ways
306 " Resize splits when the window is resized {{{2
309 autocmd VimResized * :wincmd =
312 " Only show cursorline in the current window and in normal mode {{{2
315 au WinLeave,InsertEnter * set nocursorline
316 au WinEnter,InsertLeave * set cursorline
319 " Treat buffers from stdin (e.g.: echo foo | vim -) as scratch {{{2
322 au StdinReadPost * :set buftype=nofile
325 " Jump to last known cursor position {{{2
328 " blacklist certain filetype
329 let blacklist = ['gitcommit']
330 autocmd BufReadPost *
331 \ if index(blacklist, &ft) < 0 && line("'\"") > 1 && line("'\"") <= line("$") |
332 \ exe "normal! g`\"" |
336 " Check for file modifications automatically {{{2
337 " (current buffer only)
338 " Use :NoAutoChecktime to disable it (uses b:autochecktime)
339 fun! MyAutoCheckTime()
340 " only check timestamp for normal files
341 if &buftype != '' | return | endif
342 if ! exists('b:autochecktime') || b:autochecktime
344 let b:autochecktime = 1
347 augroup MyAutoChecktime
349 au FocusGained,BufEnter,CursorHold,InsertEnter * call MyAutoCheckTime()
351 command! NoAutoChecktime let b:autochecktime=0
352 command! ToggleAutoChecktime let b:autochecktime=!get(b:, 'autochecktime', 0) | echom "b:autochecktime:" b:autochecktime
356 au TerminalOpen * if &buftype == 'terminal' | setlocal bufhidden=hide | endif
361 " allow both <space> and \ to be <leader>
367 if exists("b:make_dir")
368 let l:make_dir = "-C ".b:make_dir
369 elseif exists("g:make_dir")
370 let l:make_dir = "-C ".g:make_dir
373 let l:make_targets = ""
374 if exists("g:make_targets")
375 let l:make_targets = g:make_targets
377 execute "make! ".l:make_dir." ".l:make_targets
379 nnoremap <leader>r :call Make()<cr>
382 nnoremap <silent> <Leader>/ :silent nohl<CR>
385 nnoremap <leader>[ :tabprev<cr>
386 nnoremap <leader>] :tabnext<cr>
388 " paste from selection
389 nnoremap <leader>p* :silent! set paste<CR>"*p:set nopaste<CR>
390 " paste from clipboard
391 nnoremap <leader>p+ :silent! set paste<CR>"+p:set nopaste<CR>
393 " strip trailing whitespace
394 function! StripWhitespace(line1, line2, ...) " {{{2
395 let s_report = &report
397 let pattern = a:0 ? a:1 : '\s\+$'
398 let oldview = winsaveview()
399 exe 'keepjumps keeppatterns '.a:line1.','.a:line2.'substitute/'.pattern.'//e'
400 if oldview != winsaveview()
403 call winrestview(oldview)
404 let &report = s_report
406 command! -range=% -nargs=0 -bar Untrail keepjumps call StripWhitespace(<line1>,<line2>)
407 nnoremap <silent> <leader>ww :Untrail<CR>
410 vnoremap <leader>S y:execute @@<cr>:echo 'Sourced selection.'<cr>
411 nnoremap <leader>S ^vg_y:execute @@<cr>:echo 'Sourced line.'<cr>
413 " jump to last cursor position
416 " Select (charwise) the contents of the current line, excluding indentation.
420 nnoremap U :syntax sync fromstart<cr>:AirlineRefresh<cr>:redraw!<cr>
423 " nnoremap <leader>r :silent !ranger %:h<cr>:redraw!<cr>
424 " nnoremap <leader>R :silent !ranger<cr>:redraw!<cr>
431 " display the number of matches for the last search
432 nmap <Leader># :%s:<C-R>/::gn<CR>
434 " center cursor after search and open folds
438 " same when jumping around
441 nnoremap <c-o> <c-o>zzzv
442 nnoremap <c-i> <c-i>zzzv
444 " Not using the default mappings of 'To line from top/bottom'
450 " Heresy, emacs insert bindings
451 inoremap <C-A> <Esc>I
452 inoremap <C-E> <Esc>A
453 cnoremap <C-A> <Home>
456 " proper movement when lines are wrapped
457 noremap <silent><expr> j (v:count == 0 ? 'gj' : 'j')
458 noremap <silent><expr> k (v:count == 0 ? 'gk' : 'k')
464 noremap <Right> <NOP>
466 inoremap <Down> <NOP>
467 inoremap <Left> <NOP>
468 inoremap <Right> <NOP>
470 cnoremap <Down> <NOP>
471 cnoremap <Left> <NOP>
472 cnoremap <Right> <NOP>
474 cnoremap <C-J> <Down>
475 cnoremap <C-H> <Left>
476 cnoremap <C-L> <Right>
478 " close all folds open fold in cursor
481 map <F1> :ls<CR>:b<space>
483 " move between windows (skip previewwindow)
484 nnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
485 nnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
486 tnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
487 tnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
489 "xterm mouse with middleclick paste
490 nnoremap <MiddleMouse> i<MiddleMouse>
491 vnoremap <MiddleMouse> s<MiddleMouse>
493 " fix legacy vi inconsistency
498 " allow repeat operator on visual
499 vnoremap . :normal .<CR>
501 " add line without changing position or leaving mode
502 noremap <silent> <Leader>o :set paste<CR>m`o<ESC>``:set nopaste<CR>
503 noremap <silent> <Leader>O :set paste<CR>m`O<ESC>``:set nopaste<CR>
505 " Don't use Ex mode, use Q for formatting
508 " break undo sequence before removing word
509 inoremap <C-W> <C-G>u<C-W>
511 nnoremap coe :set <C-R>=&expandtab ? 'noexpandtab' : 'expandtab'<CR><CR>
512 nnoremap [oe :set expandtab<CR>
513 nnoremap ]oe :set noexpandtab<CR>
515 for idt in range(1,8)
516 exe 'nnoremap co'.idt.' :setlocal tabstop='.idt.' shiftwidth='.idt.' softtabstop='.idt.'<CR>'
519 " toggle auto format of text
520 nnoremap coa :set <C-R>=&formatoptions =~ "a" ? 'formatoptions-=a' : 'formatoptions+=a'<CR><CR>
521 nnoremap [oa :set formatoptions+=a<CR>
522 nnoremap ]oa :set formatoptions-=a<CR>
524 " space will toggle current fold in normal mode
525 nnoremap <leader><Space> za
526 " create folds around visual selection
527 vnoremap <leader><Space> zf
530 cabbrev w!! SudoWrite
532 " uppercase previous word
533 inoremap <C-C> <Esc>gUiwgi
535 " http://git.io/v3ZeU
536 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>
538 " plugins options {{{1
540 let g:airline#extensions#whitespace#enabled = 1
541 let g:airline#extensions#tabline#enabled = 1
542 let g:airline_powerline_fonts = 1
545 let g:checkattach_filebrowser = 'ranger'
546 let g:checkattach_once = 'y'
549 let delimitMate_expand_cr = 2
550 let g:delimitMate_expand_space = 1
553 nnoremap <silent> <Leader>ff :FSHere<CR>
554 nnoremap <silent> <Leader>fl :FSRight<CR>
555 nnoremap <silent> <Leader>fh :FSLeft<CR>
556 nnoremap <silent> <Leader>fj :FSBelow<CR>
557 nnoremap <silent> <Leader>fk :FSAbove<CR>
558 nnoremap <silent> <Leader>fL :FSSplitRight<CR>
559 nnoremap <silent> <Leader>fH :FSSplitLeft<CR>
560 nnoremap <silent> <Leader>fJ :FSSplitBelow<CR>
561 nnoremap <silent> <Leader>fK :FSSplitAbove<CR>
564 nmap <silent> <leader>dd :tab split \| Gdiff \| wincmd h<CR>
565 " delete fugitive buffers when closed
566 autocmd BufReadPost fugitive://* set bufhidden=delete
568 nnoremap <silent> <leader>gs :Git<CR>
569 nnoremap <silent> <leader>gd :Gdiffsplit<CR>
570 nnoremap <silent> <leader>gc :tab G commit -v<CR>
571 nnoremap <silent> <leader>ga :Gwrite<cr>
572 nnoremap <silent> <leader>gb :G blame<cr>
574 augroup fugitive_gstatus
576 autocmd BufWinEnter */.git/index resize 16
580 nnoremap <F7> :GundoToggle<CR>
583 let g:indent_guides_default_mapping = 0
584 let g:indent_guides_guide_size = 1
585 nmap <silent> cog <Plug>IndentGuidesToggle
586 nmap <silent> [og <Plug>IndentGuidesEnable
587 nmap <silent> ]og <Plug>IndentGuidesDisable
589 " close-another-window {{{2
590 nnoremap <silent> <C-W>c <NOP>
591 nnoremap <silent> <C-W>cc <C-W>c
592 nnoremap <silent> <C-W>ch :CloseLeftWindow<CR>
593 nnoremap <silent> <C-W>cl :CloseRightWindow<CR>
594 nnoremap <silent> <C-W>cj :CloseBelowWindow<CR>
595 nnoremap <silent> <C-W>ck :CloseAboveWindow<CR>
599 let g:pymode_rope_completion = 0
600 let g:pymode_rope = 0
602 let g:pymode_folding = 1
603 let g:pymode_lint_ignore = "E221,E266,E501"
604 let g:pymode_lint_cwindow = 0 " don't open cwindow when linting
605 let g:pymode_syntax_space_errors = 0 " don't bother me when I'm typing
608 " disable '[ mappings
610 let g:SignatureMap = {
611 \ 'GotoNextLineAlpha' : "",
612 \ 'GotoPrevLineAlpha' : "",
613 \ 'GotoNextSpotAlpha' : "",
614 \ 'GotoPrevSpotAlpha' : "",
618 let g:switch_mapping = "<Leader>s"
621 nmap <silent> z] <Plug>(SpellRotateForward)
622 nmap <silent> z[ <Plug>(SpellRotateBackward)
623 vmap <silent> z] <Plug>(SpellRotateForwardV)
624 vmap <silent> z[ <Plug>(SpellRotateBackwardV)
627 let g:syntastic_enable_highlighting = 0
628 let g:syntastic_error_symbol='E'
629 let g:syntastic_style_error_symbol='S'
630 let g:syntastic_warning_symbol='W'
631 let g:syntastic_style_warning_symbol='S'
632 let g:syntastic_always_populate_loc_list=1
633 nmap <silent> <leader>y :SyntasticCheck<cr>
635 let g:syntastic_cpp_clang_tidy_post_args = "-p build*"
638 let g:syntastic_check_on_open=1
642 map <F5> :TagbarToggle<cr>
643 let g:tagbar_sort = 0
644 let g:tagbar_compact = 1
645 let g:tagbar_autoshowtag = 1
646 let g:tagbar_width = 25
647 let g:tagbar_iconchars = ['+', '-']
650 let g:tcomment_textobject_inlinecomment = 'gic'
651 let g:tcomment#filetype#guess = 0
654 let g:UltiSnipsEditSplit = 'vertical'
655 let g:UltiSnipsSnippetDirectories = [ expand("$XDG_CONFIG_HOME/vim/ultisnips") ]
657 let g:UltiSnipsSnippetDirectories = ["UltiSnips", "ultisnips"]
659 let g:UltiSnipsExpandTrigger = "<tab>"
660 let g:UltiSnipsJumpForwardTrigger = "<tab>"
661 let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
663 " UltiSnips completion function that tries to expand a snippet. If there's no
664 " snippet for expanding, it checks for completion window and if it's shown,
665 " selects first element. If there's no completion window it tries to jump to
666 " next placeholder. If there's no placeholder it just returns TAB key
667 " https://github.com/Valloric/YouCompleteMe/issues/36#issuecomment-15451411
668 function! g:UltiSnips_Complete()
669 call UltiSnips#ExpandSnippet()
670 if g:ulti_expand_res == 0
674 call UltiSnips#JumpForwards()
675 if g:ulti_jump_forwards_res == 0
682 au InsertEnter * exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=g:UltiSnips_Complete()<cr>"
683 let g:UltiSnipsListSnippets="<c-e>"
686 call unite#filters#matcher_default#use(['matcher_fuzzy'])
687 call unite#custom#profile('default', 'context', {
689 \ 'direction': 'botright'
692 nnoremap [unite] <Nop>
693 nmap <leader>u [unite]
694 nnoremap [unite]u :UniteResume<CR>
695 nnoremap <silent> [u :UnitePrevious<CR>
696 nnoremap <silent> ]u :UniteNext<CR>
699 " seems not respected
700 let g:unite_source_grep_max_candidates = 2000
702 " Use ag in unite grep source.
703 let g:unite_source_grep_command = 'ag'
704 let g:unite_source_grep_default_opts = '--smart-case --vimgrep --ignore ''.hg'' --ignore ''.svn'' --ignore ''.git'' --ignore ''.bzr'''
705 let g:unite_source_grep_recursive_opt = ''
707 nnoremap <silent> [unite]a :<C-u>Unite grep:.::
\12\17<CR>
708 nnoremap <silent> [unite]A :<C-u>Unite grep:.:-w:
\12\17<CR>
709 command! -nargs=1 Ag Unite grep:.::<args>
711 " unite-file_rec {{{3
713 " Use ag in unite rec source
714 let g:unite_source_rec_async_command = ['ag', '--follow', '--nocolor', '--nogroup', '-g', '']
716 nnoremap <silent> [unite]f :<C-u>Unite -start-insert file_rec/async<CR>
717 call unite#custom#source('file_rec/async', 'sorters', 'sorter_selecta')
720 call unite#custom#default_action('buffer', 'open')
721 nnoremap <silent> [unite]b :<C-u>Unite buffer:-<CR>
723 " unite-jumplist {{{3
724 nnoremap <silent> [unite]j :<C-u>Unite output:jumps:<CR>
727 let g:unite_source_menu_menus = {}
728 let g:unite_source_menu_menus.fugitive = { 'description' : 'fugitive menu'}
729 let g:unite_source_menu_menus.fugitive.command_candidates = {
730 \ 'Gstatus <Leader>gs' : 'Gstatus',
731 \ 'Gcommit -v <Leader>gc' : 'Gcommit -v',
735 nnoremap <silent> <leader>gg :<C-u>Unite menu:fugitive<CR>
737 let g:unite_source_history_yank_enable = 1
738 nnoremap <silent> [unite]p :<C-u>Unite history/yank<CR>
741 nnoremap <silent> <leader>p :YRShow<cr>
742 let g:yankring_history_dir = expand('$XDG_CACHE_HOME/vim')
743 let g:yankring_replace_n_pkey = ''
744 let g:yankring_replace_n_nkey = ''
746 " map Y to y$ for the yank ring
747 function! YRRunAfterMaps()
748 nnoremap Y :<C-U>YRYankCount 'y$'<CR>
752 let g:ycm_clangd_binary_path = 'clangd' " use clangd in path
753 let g:ycm_clangd_args = ['--clang-tidy']
754 let g:ycm_extra_conf_vim_data = ['getcwd()']
755 let g:ycm_add_preview_to_completeopt = 1
756 let g:ycm_complete_in_comments = 1
757 let g:ycm_complete_in_strings = 1
758 let g:ycm_autoclose_preview_window_after_insertion = 0
760 " vim-easy-align {{{2
761 " start interactive EasyAlign in visual mode
762 vmap <Enter> <Plug>(EasyAlign)
763 nmap ga <Plug>(EasyAlign)
766 let g:gtest#highlight_failing_tests = 0
768 nnoremap <silent> <Leader>tt :GTestRun<CR>
769 nnoremap <Leader>tc :GTestCase<space>
770 nnoremap <Leader>tn :GTestName<space>
771 nnoremap <silent> <Leader>ta :GTestCase *<CR>:GTestName *<CR>:GTestRun<CR>
772 nnoremap <silent> <Leader>tu :GTestRunUnderCursor<CR>
775 let g:vim_json_syntax_conceal = 0
778 let g:sneak#streak = 1
779 let g:sneak#target_labels = "aoeuisnthdpylrcgfqjkxzmwvz" " dvorak
780 let g:sneak#use_ic_scs = 1 " follow 'ignorecase' and 'smartcase'
798 " Convenient command to see the difference between the current buffer and the
799 " file it was loaded from, thus the changes you made.
800 " Only define it when not defined already.
801 if !exists(":DiffOrig")
802 command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
803 \ | wincmd p | diffthis
807 function! SortLinesOpFunc(...)
810 nnoremap <silent> gs :<C-U>set operatorfunc=SortLinesOpFunc<CR>g@
811 vnoremap <silent> gs :sort<cr>
814 function! EditConfig(what, ext = '.vim')
815 let l:dir = split(&runtimepath,',')[0]
817 let l:file = expand($MYVIMRC)
818 elseif ! isdirectory(globpath(l:dir, a:what))
819 echoe a:what." is not valid!"
820 elseif empty(&filetype)
821 echoe 'filetype is empty!'
823 let l:file = l:dir.'/'.a:what.'/'.&filetype.a:ext
826 execute ':vsplit '.file
829 nmap <leader>ev :call EditConfig('vimrc')<CR>
830 nmap <leader>ef :call EditConfig('ftplugin')<CR>
831 nmap <leader>es :call EditConfig('syntax')<CR>
832 nmap <leader>ei :call EditConfig('indent')<CR>
833 nmap <leader>eu :call EditConfig('ultisnips', '.snippets')<CR>
836 " http://tex.stackexchange.com/a/52932
837 let g:myLangList=["en_gb","en_us","de","fr"]
839 function! ToggleSpell()
840 if !exists("b:myLang")
843 execute "setlocal spell!"
845 echo "setlocal spelllang=" g:myLangList[b:myLang]
849 function! SwitchSpell()
850 if !exists("b:myLang")
854 let b:myLang=b:myLang+1
855 if b:myLang>=len(g:myLangList) | let b:myLang=0 | endif
857 execute "setlocal spell spelllang=".get(g:myLangList, b:myLang)
858 echo "setlocal spelllang=" g:myLangList[b:myLang]
861 nnoremap <silent> coS :call SwitchSpell()<CR>
862 " fix spelling with first choice
863 nnoremap <Leader>f 1z=
865 " gitdir or home {{{2
867 " http://git.io/v3GAV
868 function! FindGitDirOrHome()
869 let filedir = expand('%:p:h')
870 if isdirectory(filedir)
871 let cmd = 'bash -c "(cd ' . filedir . '; git rev-parse --show-toplevel 2>/dev/null)"'
872 let gitdir = system(cmd)
873 if strlen(gitdir) == 0
883 command! Cdr execute('cd ' . FindGitDirOrHome())
885 command! LCdr execute('lcd ' . FindGitDirOrHome())
887 " vim:set et sw=2 ts=2 tw=78: