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' " {{{2
66 let g:gruvbox_contrast_dark = 'hard'
67 let g:gruvbox_contrast_light = 'soft'
69 Plug 'arcticicestudio/nord-vim' " {{{2
72 let g:nord_italic_comments = 1
73 let g:nord_underline = 1
74 let g:nord_uniform_status_lines = 0
75 let g:nord_uniform_diff_background = 0
76 let g:nord_cursor_line_number_background = 0
77 let g:nord_bold_vertical_split_line = 0
82 Plug 'sirver/ultisnips'
83 Plug 'honza/vim-snippets'
86 Plug 'kana/vim-textobj-user'
87 Plug 'julian/vim-textobj-variable-segment'
88 Plug 'sgur/vim-textobj-parameter'
89 Plug 'kana/vim-operator-user'
92 " Check LucHermites plugins: https://github.com/LucHermitte/lh-cpp
93 Plug 'dense-analysis/ale' " {{{2
94 let g:ale_echo_msg_format = '[%linter%] %code: %%s'
96 Plug 'git@github.com:/ram-z/vim-orgmode', { 'branch': 'dev' } " {{{2
97 Plug 'vim-scripts/syntaxrange'
99 let g:org_agenda_files = ['~/org/*.org']
101 Plug 'neovimhaskell/haskell-vim' " {{{2
102 let g:haskell_enable_quantification = 1 " to enable highlighting of `forall`
103 let g:haskell_enable_recursivedo = 1 " to enable highlighting of `mdo` and `rec`
104 let g:haskell_enable_arrowsyntax = 1 " to enable highlighting of `proc`
105 let g:haskell_enable_pattern_synonyms = 1 " to enable highlighting of `pattern`
106 let g:haskell_enable_typeroles = 1 " to enable highlighting of type roles
107 let g:haskell_enable_static_pointers = 1 " to enable highlighting of `static`
108 let g:haskell_backpack = 1 " to enable highlighting of backpack keywords
111 Plug 'aklt/plantuml-syntax'
113 Plug 'mtth/scratch.vim' " {{{2
114 let g:scratch_no_mappings = 1
117 Plug 'vim-utils/vim-man' " {{{2
123 filetype plugin indent on
128 let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
129 let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
134 " moving around, searching and patterns {{{2
135 set incsearch " show match for partly typed search command
136 set ignorecase " ignore case when using a search pattern
137 set smartcase " override 'ignorecase' when pattern has upper case characters
138 set hlsearch " highlight all matches for the last used search pattern
140 set nostartofline " don't move the cursor to the first non-blank char of a line
143 set path+=../include/
144 set path+=/usr/include/c++/*
146 " displaying text {{{2
147 set nowrap " long lines wrap
148 set linebreak " wrap long lines at a character in 'breakat'
149 set showbreak=↪ " show these chars for wrapped lines
150 set breakindent " preserve indentation in wrapped text
152 set lazyredraw " don't redraw while executing macros
154 set list " show chars defined in 'listchars'
155 set listchars=tab:❭\ " list of strings used for list mode
156 set listchars+=extends:❯,precedes:❮
157 " Only shown when not in insert mode
158 set listchars+=trail:·
161 au InsertEnter * :set listchars-=trail:·
162 au InsertLeave * :set listchars+=trail:·
165 set scrolloff=5 " number of screen lines to show around the cursor
166 set sidescroll=1 " number of collumns to scroll
167 set sidescrolloff=1 " don't scroll over the listchars
169 set fillchars=diff:⣿,vert:│
171 set nonumber " show the line number for each line
172 set norelativenumber " show the relative line number for each line
174 " syntax, highlighting and spelling {{{2
175 set synmaxcol=800 " don't highlight long lines
177 set dictionary=spell " list of dictionary files for keyword completion
181 " multiple windows {{{2
182 set laststatus=2 " 0, 1 or 2; when to use a status line for the last window
184 set previewheight=20 " default height for the preview window
188 " set splitbelow " a new window is put below of the current one
189 set splitright " a new window is put right of the current one
194 " using the mouse {{{2
195 set mouse=rnv " list of flags for using the mouse
196 set ttymouse=xterm " type of mouse
198 " messages and info {{{2
199 set showcmd " Show (partial) command in status line.
200 set ruler " show the cursor position all the time
201 set confirm " Ask what to do when closing unsaved documents
202 set shortmess= " reset option
203 set shortmess+=a " all abbreviations
204 set shortmess+=o " overwrite file-written message
205 set shortmess+=O " file-read message overrides previous
206 set shortmess+=t " truncate file message at start
207 set shortmess+=T " truncate other messages in the middle
208 set shortmess+=W " don't give 'written' or '[w]' when writing a file
209 set shortmess+=A " ignore swapfile warning
210 set shortmess+=I " no splash screen
213 set backspace=indent,eol,start " allow backspacing over everything in insert mode
215 set showmatch " Show matching brackets.
217 set nojoinspaces " don't use two spaces after '.' when joining a line
218 set formatoptions+=j " Delete comment leader when joining lines
219 set formatoptions+=c " Autowrap comments using textwidth
220 set formatoptions+=r " Insert comment leader after hitting <Enter>
221 set formatoptions+=n " Recognize numbered lists
222 set formatoptions+=q " Allow formatting of comments with "gq".
223 set formatoptions+=l " do not wrap lines that have been longer when starting insert mode already
224 set formatoptions+=t " Auto-wrap text using textwidth
225 set formatoptions-=o " Do not insert comment leader after hitting o or O in normal mode
227 set nrformats=hex " number formats recognized for CTRL-A and CTRL-X commands
229 set complete=. " scan the current buffer ( 'wrapscan' is ignored)
230 set complete+=w " scan buffers from other windows
231 set complete+=b " scan other loaded buffers that are in the buffer list
232 set complete+=u " scan the unloaded buffers that are in the buffer list
233 set complete+=t " scan tags
234 set complete+=i " scan current and included files
235 set complete+=kspell " use the currently active spell checking |spell|
237 " whether to use a popup menu for Insert mode completion
238 set completeopt=longest,menuone,preview
240 " tabs and indent {{{2
241 set shiftwidth=4 " number of spaces used for each step of (auto)indent
242 set smarttab " a <Tab> in an indent inserts 'shiftwidth' spaces
243 set softtabstop=4 " if non-zero, number of spaces to insert for a <Tab>
244 set shiftround " round to 'shiftwidth' for "<<" and ">>"
245 set expandtab " expand <Tab> to spaces in Insert mode
248 set pastetoggle=<F11> " key sequence to toggle paste mode
251 set foldmethod=marker " folding type
252 set foldlevelstart=0 " value for 'foldlevel' when starting to edit a file
254 " open folds when jumping to line
257 set viewoptions=cursor " save cursor position
258 set viewoptions+=folds " save folds
261 set diffopt+=filler " show filler lines
262 set diffopt+=vertical " always vertical split
263 set diffopt+=context:10 " 10 lines context between changes
265 " reading and writing files {{{2
266 set modeline " read modelines
267 set modelines=2 " only check first/last 2 lines
269 set writebackup " write a backup file before overwriting a file
270 set backup " keep a backup after owerwriting a file
271 set backupdir=$XDG_CACHE_HOME/vim/backup//
273 set backupskip+=.netrc " skip netrc
274 set backupskip+=/dev/shm/pass* " skip passwordstore files
276 set undofile " persistent undo history
277 set undodir=$XDG_CACHE_HOME/vim/undo//
281 au BufWritePre .netrc setlocal noundofile
282 au BufWritePre /dev/shm/pass* setlocal noundofile
283 au BufWritePre /tmp/* setlocal noundofile
286 set autowrite " automatically write a file when leaving a modified buffer
287 set autoread " automatically read a file that has been modified
291 set directory=$XDG_CACHE_HOME/vim/swap//
293 " command line editing {{{2
294 set history=5000 " how many command lines are remembered
295 set wildmenu " command-line completion shows a list of matches
296 set wildmode=longest:full,full " specifies how command line completion works
297 set wildignorecase " ignore case when completing file names
299 set wildignore+=.hg,.git,.svn " Version control
300 set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
301 set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
302 set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
303 set wildignore+=*.spl " compiled spelling word lists
304 set wildignore+=*.sw? " Vim swap files
305 set wildignore+=*.luac " Lua byte code
306 set wildignore+=*.pyc " Python byte code
307 set wildignore+=*.orig " Merge resolution files
309 " running make and jumping to errors {{{2
310 set makeprg=make\ -w " print changing directories
312 set grepprg=ag\ --vimgrep\ $*
314 " language specific {{{2
315 set isfname-== " don't treat `=` as being part of filenames
318 set virtualedit+=block " let cursor move past last char in <C-V> mode
319 set virtualedit+=onemore " allow the cursor to move just past the end of the line
320 set viminfo='100,<50,s10,h,n$XDG_CACHE_HOME/vim/viminfo " viminfo defaults but save file in .cache
322 set viewdir=$XDG_CACHE_HOME/vim/view//
324 set sessionoptions+=unix,slash " damn windows and it's silly ways
327 " Resize splits when the window is resized {{{2
330 autocmd VimResized * :wincmd =
333 " Only show cursorline in the current window and in normal mode {{{2
336 au WinLeave,InsertEnter * set nocursorline
337 au WinEnter,InsertLeave * set cursorline
340 " Treat buffers from stdin (e.g.: echo foo | vim -) as scratch {{{2
343 au StdinReadPost * :set buftype=nofile
346 " Jump to last known cursor position {{{2
349 " blacklist certain filetype
350 let blacklist = ['gitcommit']
351 autocmd BufReadPost *
352 \ if index(blacklist, &ft) < 0 && line("'\"") > 1 && line("'\"") <= line("$") |
353 \ exe "normal! g`\"" |
357 " Check for file modifications automatically {{{2
358 " (current buffer only)
359 " Use :NoAutoChecktime to disable it (uses b:autochecktime)
360 fun! MyAutoCheckTime()
361 " only check timestamp for normal files
362 if &buftype != '' | return | endif
363 if ! exists('b:autochecktime') || b:autochecktime
365 let b:autochecktime = 1
368 augroup MyAutoChecktime
370 au FocusGained,BufEnter,CursorHold,InsertEnter * call MyAutoCheckTime()
372 command! NoAutoChecktime let b:autochecktime=0
373 command! ToggleAutoChecktime let b:autochecktime=!get(b:, 'autochecktime', 0) | echom "b:autochecktime:" b:autochecktime
377 au TerminalOpen * if &buftype == 'terminal' | setlocal bufhidden=hide | endif
382 " allow both <space> and \ to be <leader>
388 if exists("b:make_dir")
389 let l:make_dir = "-C ".b:make_dir
390 elseif exists("g:make_dir")
391 let l:make_dir = "-C ".g:make_dir
394 let l:make_targets = ""
395 if exists("g:make_targets")
396 let l:make_targets = g:make_targets
398 execute "make! ".l:make_dir." ".l:make_targets
400 nnoremap <leader>r :call Make()<cr>
403 nnoremap <silent> <Leader>/ :silent nohl<CR>
406 nnoremap <leader>[ :tabprev<cr>
407 nnoremap <leader>] :tabnext<cr>
409 " paste from selection
410 nnoremap <leader>p* :silent! set paste<CR>"*p:set nopaste<CR>
411 " paste from clipboard
412 nnoremap <leader>p+ :silent! set paste<CR>"+p:set nopaste<CR>
414 " strip trailing whitespace
415 function! StripWhitespace(line1, line2, ...) " {{{2
416 let s_report = &report
418 let pattern = a:0 ? a:1 : '\s\+$'
419 let oldview = winsaveview()
420 exe 'keepjumps keeppatterns '.a:line1.','.a:line2.'substitute/'.pattern.'//e'
421 if oldview != winsaveview()
424 call winrestview(oldview)
425 let &report = s_report
427 command! -range=% -nargs=0 -bar Untrail keepjumps call StripWhitespace(<line1>,<line2>)
428 nnoremap <silent> <leader>ww :Untrail<CR>
431 vnoremap <leader>S y:execute @@<cr>:echo 'Sourced selection.'<cr>
432 nnoremap <leader>S ^vg_y:execute @@<cr>:echo 'Sourced line.'<cr>
434 " jump to last cursor position
437 " Select (charwise) the contents of the current line, excluding indentation.
442 \ :syntax sync fromstart<cr>
443 \ :AirlineRefresh<cr>
444 \ :call popup_clear(1)<cr>
448 " nnoremap <leader>r :silent !ranger %:h<cr>:redraw!<cr>
449 " nnoremap <leader>R :silent !ranger<cr>:redraw!<cr>
456 " display the number of matches for the last search
457 nmap <Leader># :%s:<C-R>/::gn<CR>
459 " center cursor after search and open folds
463 " same when jumping around
466 nnoremap <c-o> <c-o>zzzv
467 nnoremap <c-i> <c-i>zzzv
469 " Not using the default mappings of 'To line from top/bottom'
475 " Heresy, emacs insert bindings
476 inoremap <C-A> <Esc>I
477 inoremap <C-E> <Esc>A
478 cnoremap <C-A> <Home>
481 " proper movement when lines are wrapped
482 noremap <silent><expr> j (v:count == 0 ? 'gj' : 'j')
483 noremap <silent><expr> k (v:count == 0 ? 'gk' : 'k')
489 noremap <Right> <NOP>
491 inoremap <Down> <NOP>
492 inoremap <Left> <NOP>
493 inoremap <Right> <NOP>
495 cnoremap <Down> <NOP>
496 cnoremap <Left> <NOP>
497 cnoremap <Right> <NOP>
499 cnoremap <C-J> <Down>
500 cnoremap <C-H> <Left>
501 cnoremap <C-L> <Right>
503 " close all folds open fold in cursor
506 map <F1> :ls<CR>:b<space>
508 " move between windows (skip previewwindow)
509 nnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
510 nnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
511 tnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
512 tnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
514 "xterm mouse with middleclick paste
515 nnoremap <MiddleMouse> i<MiddleMouse>
516 vnoremap <MiddleMouse> s<MiddleMouse>
518 " fix legacy vi inconsistency
523 " allow repeat operator on visual
524 vnoremap . :normal .<CR>
526 " add line without changing position or leaving mode
527 noremap <silent> <Leader>o :set paste<CR>m`o<ESC>``:set nopaste<CR>
528 noremap <silent> <Leader>O :set paste<CR>m`O<ESC>``:set nopaste<CR>
530 " Don't use Ex mode, use Q for formatting
533 " break undo sequence before removing word
534 inoremap <C-W> <C-G>u<C-W>
536 nnoremap coe :set <C-R>=&expandtab ? 'noexpandtab' : 'expandtab'<CR><CR>
537 nnoremap [oe :set expandtab<CR>
538 nnoremap ]oe :set noexpandtab<CR>
540 for idt in range(1,8)
541 exe 'nnoremap co'.idt.' :setlocal tabstop='.idt.' shiftwidth='.idt.' softtabstop='.idt.'<CR>'
544 " toggle auto format of text
545 nnoremap coa :set <C-R>=&formatoptions =~ "a" ? 'formatoptions-=a' : 'formatoptions+=a'<CR><CR>
546 nnoremap [oa :set formatoptions+=a<CR>
547 nnoremap ]oa :set formatoptions-=a<CR>
549 " space will toggle current fold in normal mode
550 nnoremap <leader><Space> za
551 " create folds around visual selection
552 vnoremap <leader><Space> zf
555 cabbrev w!! SudoWrite
557 " uppercase previous word
558 inoremap <C-C> <Esc>gUiwgi
560 " http://git.io/v3ZeU
561 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>
563 " plugins options {{{1
565 let g:airline#extensions#whitespace#enabled = 1
566 let g:airline#extensions#tabline#enabled = 1
567 let g:airline_powerline_fonts = 1
570 let g:checkattach_filebrowser = 'ranger'
571 let g:checkattach_once = 'y'
574 let delimitMate_expand_cr = 2
575 let g:delimitMate_expand_space = 1
578 nnoremap <silent> <Leader>ff :FSHere<CR>
579 nnoremap <silent> <Leader>fl :FSRight<CR>
580 nnoremap <silent> <Leader>fh :FSLeft<CR>
581 nnoremap <silent> <Leader>fj :FSBelow<CR>
582 nnoremap <silent> <Leader>fk :FSAbove<CR>
583 nnoremap <silent> <Leader>fL :FSSplitRight<CR>
584 nnoremap <silent> <Leader>fH :FSSplitLeft<CR>
585 nnoremap <silent> <Leader>fJ :FSSplitBelow<CR>
586 nnoremap <silent> <Leader>fK :FSSplitAbove<CR>
589 nmap <silent> <leader>dd :tab split \| Gdiff \| wincmd h<CR>
590 " delete fugitive buffers when closed
591 autocmd BufReadPost fugitive://* set bufhidden=delete
593 nnoremap <silent> <leader>gs :Git<CR>
594 nnoremap <silent> <leader>gd :Gdiffsplit<CR>
595 nnoremap <silent> <leader>gc :echohl WarningMsg \| echo "use \<leader>gcc instead" \| echohl None<CR>
596 nnoremap <silent> <leader>gcc :tab G commit -v<CR>
597 nnoremap <silent> <leader>gca :tab G commit -v --amend<CR>
598 nnoremap <leader>gcf :tab G commit -v --fixup=
599 nnoremap <silent> <leader>gp :echohl WarningMsg \| echo "use \<leader>gpp instead" \| echohl None<CR>
600 nnoremap <silent> <leader>gpp :G push<CR>
601 nnoremap <silent> <leader>gpf :G push --force-with-lease<CR>
602 nnoremap <silent> <leader>ga :Gwrite<cr>
603 nnoremap <silent> <leader>gb :G blame<cr>
605 augroup fugitive_gstatus
607 autocmd BufWinEnter */.git/index resize 16
611 nnoremap <F7> :GundoToggle<CR>
614 let g:indent_guides_default_mapping = 0
615 let g:indent_guides_guide_size = 1
616 nmap <silent> cog <Plug>IndentGuidesToggle
617 nmap <silent> [og <Plug>IndentGuidesEnable
618 nmap <silent> ]og <Plug>IndentGuidesDisable
620 " close-another-window {{{2
621 nnoremap <silent> <C-W>c <NOP>
622 nnoremap <silent> <C-W>cc <C-W>c
623 nnoremap <silent> <C-W>ch :CloseLeftWindow<CR>
624 nnoremap <silent> <C-W>cl :CloseRightWindow<CR>
625 nnoremap <silent> <C-W>cj :CloseBelowWindow<CR>
626 nnoremap <silent> <C-W>ck :CloseAboveWindow<CR>
630 let g:pymode_rope_completion = 0
631 let g:pymode_rope = 0
633 let g:pymode_folding = 1
634 let g:pymode_lint_ignore = "E221,E266,E501"
635 let g:pymode_lint_cwindow = 0 " don't open cwindow when linting
636 let g:pymode_syntax_space_errors = 0 " don't bother me when I'm typing
639 " disable '[ mappings
641 let g:SignatureMap = {
642 \ 'GotoNextLineAlpha' : "",
643 \ 'GotoPrevLineAlpha' : "",
644 \ 'GotoNextSpotAlpha' : "",
645 \ 'GotoPrevSpotAlpha' : "",
649 let g:switch_mapping = "<Leader>s"
652 nmap <silent> z] <Plug>(SpellRotateForward)
653 nmap <silent> z[ <Plug>(SpellRotateBackward)
654 vmap <silent> z] <Plug>(SpellRotateForwardV)
655 vmap <silent> z[ <Plug>(SpellRotateBackwardV)
658 let g:syntastic_enable_highlighting = 0
659 let g:syntastic_error_symbol='E'
660 let g:syntastic_style_error_symbol='S'
661 let g:syntastic_warning_symbol='W'
662 let g:syntastic_style_warning_symbol='S'
663 let g:syntastic_always_populate_loc_list=1
664 nmap <silent> <leader>y :SyntasticCheck<cr>
666 let g:syntastic_cpp_clang_tidy_post_args = "-p build*"
669 let g:syntastic_check_on_open=1
673 map <F5> :TagbarToggle<cr>
674 let g:tagbar_sort = 0
675 let g:tagbar_compact = 1
676 let g:tagbar_autoshowtag = 1
677 let g:tagbar_width = 25
678 let g:tagbar_iconchars = ['+', '-']
681 let g:tcomment_textobject_inlinecomment = 'gic'
682 let g:tcomment#filetype#guess = 0
685 let g:UltiSnipsEditSplit = 'vertical'
686 let g:UltiSnipsSnippetDirectories = [ expand("$XDG_CONFIG_HOME/vim/ultisnips") ]
688 let g:UltiSnipsSnippetDirectories = ["UltiSnips", "ultisnips"]
690 let g:UltiSnipsExpandTrigger = "<tab>"
691 let g:UltiSnipsJumpForwardTrigger = "<tab>"
692 let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
694 " UltiSnips completion function that tries to expand a snippet. If there's no
695 " snippet for expanding, it checks for completion window and if it's shown,
696 " selects first element. If there's no completion window it tries to jump to
697 " next placeholder. If there's no placeholder it just returns TAB key
698 " https://github.com/Valloric/YouCompleteMe/issues/36#issuecomment-15451411
699 function! g:UltiSnips_Complete()
700 call UltiSnips#ExpandSnippet()
701 if g:ulti_expand_res == 0
705 call UltiSnips#JumpForwards()
706 if g:ulti_jump_forwards_res == 0
713 au InsertEnter * exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=g:UltiSnips_Complete()<cr>"
714 let g:UltiSnipsListSnippets="<c-e>"
717 call unite#filters#matcher_default#use(['matcher_fuzzy'])
718 call unite#custom#profile('default', 'context', {
720 \ 'direction': 'botright'
723 nnoremap [unite] <Nop>
724 nmap <leader>u [unite]
725 nnoremap [unite]u :UniteResume<CR>
726 nnoremap <silent> [u :UnitePrevious<CR>
727 nnoremap <silent> ]u :UniteNext<CR>
730 " seems not respected
731 let g:unite_source_grep_max_candidates = 2000
733 " Use ag in unite grep source.
734 let g:unite_source_grep_command = 'ag'
735 let g:unite_source_grep_default_opts = '--smart-case --vimgrep --ignore ''.hg'' --ignore ''.svn'' --ignore ''.git'' --ignore ''.bzr'''
736 let g:unite_source_grep_recursive_opt = ''
738 nnoremap <silent> [unite]a :<C-u>Unite grep:.::
\12\17<CR>
739 nnoremap <silent> [unite]A :<C-u>Unite grep:.:-w:
\12\17<CR>
740 command! -nargs=+ Ag Unite -input=<args> grep:.:
742 " unite-file_rec {{{3
744 " Use ag in unite rec source
745 let g:unite_source_rec_async_command = ['ag', '--follow', '--nocolor', '--nogroup', '-g', '']
747 nnoremap <silent> [unite]f :<C-u>Unite -start-insert file_rec/async<CR>
748 call unite#custom#source('file_rec/async', 'sorters', 'sorter_selecta')
751 call unite#custom#default_action('buffer', 'open')
752 nnoremap <silent> [unite]b :<C-u>Unite buffer:-<CR>
754 " unite-jumplist {{{3
755 nnoremap <silent> [unite]j :<C-u>Unite output:jumps:<CR>
758 let g:unite_source_menu_menus = {}
759 let g:unite_source_menu_menus.fugitive = { 'description' : 'fugitive menu'}
760 let g:unite_source_menu_menus.fugitive.command_candidates = {
761 \ 'Gstatus <Leader>gs' : 'Gstatus',
762 \ 'Gcommit -v <Leader>gc' : 'Gcommit -v',
766 nnoremap <silent> <leader>gg :<C-u>Unite menu:fugitive<CR>
768 let g:unite_source_history_yank_enable = 1
769 nnoremap <silent> [unite]p :<C-u>Unite history/yank<CR>
772 nnoremap <silent> <leader>p :YRShow<cr>
773 let g:yankring_history_dir = expand('$XDG_CACHE_HOME/vim')
774 let g:yankring_replace_n_pkey = ''
775 let g:yankring_replace_n_nkey = ''
777 " map Y to y$ for the yank ring
778 function! YRRunAfterMaps()
779 nnoremap Y :<C-U>YRYankCount 'y$'<CR>
783 let g:ycm_clangd_binary_path = 'clangd' " use clangd in path
784 let g:ycm_clangd_args = ['--clang-tidy']
785 let g:ycm_extra_conf_vim_data = ['getcwd()']
786 let g:ycm_add_preview_to_completeopt = 1
787 let g:ycm_complete_in_comments = 1
788 let g:ycm_complete_in_strings = 1
789 let g:ycm_autoclose_preview_window_after_insertion = 0
791 " vim-easy-align {{{2
792 " start interactive EasyAlign in visual mode
793 vmap <Enter> <Plug>(EasyAlign)
794 nmap ga <Plug>(EasyAlign)
797 let g:gtest#highlight_failing_tests = 0
799 nnoremap <silent> <Leader>tt :GTestRun<CR>
800 nnoremap <Leader>tc :GTestCase<space>
801 nnoremap <Leader>tn :GTestName<space>
802 nnoremap <silent> <Leader>ta :GTestCase *<CR>:GTestName *<CR>:GTestRun<CR>
803 nnoremap <silent> <Leader>tu :GTestRunUnderCursor<CR>
806 let g:vim_json_syntax_conceal = 0
809 let g:sneak#streak = 1
810 let g:sneak#target_labels = "aoeuisnthdpylrcgfqjkxzmwvz" " dvorak
811 let g:sneak#use_ic_scs = 1 " follow 'ignorecase' and 'smartcase'
829 " Convenient command to see the difference between the current buffer and the
830 " file it was loaded from, thus the changes you made.
831 " Only define it when not defined already.
832 if !exists(":DiffOrig")
833 command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
834 \ | wincmd p | diffthis
838 function! SortLinesOpFunc(...)
841 nnoremap <silent> gs :<C-U>set operatorfunc=SortLinesOpFunc<CR>g@
842 vnoremap <silent> gs :sort<cr>
845 function! EditConfig(what, ext = '.vim')
846 let l:dir = split(&runtimepath,',')[0]
848 let l:file = expand($MYVIMRC)
849 elseif ! isdirectory(globpath(l:dir, a:what))
850 echoe a:what." is not valid!"
851 elseif empty(&filetype)
852 echoe 'filetype is empty!'
854 let l:file = l:dir.'/'.a:what.'/'.&filetype.a:ext
857 execute ':vsplit '.file
860 nmap <leader>ev :call EditConfig('vimrc')<CR>
861 nmap <leader>ef :call EditConfig('ftplugin')<CR>
862 nmap <leader>es :call EditConfig('syntax')<CR>
863 nmap <leader>ei :call EditConfig('indent')<CR>
864 nmap <leader>eu :call EditConfig('ultisnips', '.snippets')<CR>
867 " http://tex.stackexchange.com/a/52932
868 let g:myLangList=["en_gb","en_us","de","fr"]
870 function! ToggleSpell()
871 if !exists("b:myLang")
874 execute "setlocal spell!"
876 echo "setlocal spelllang=" g:myLangList[b:myLang]
880 function! SwitchSpell()
881 if !exists("b:myLang")
885 let b:myLang=b:myLang+1
886 if b:myLang>=len(g:myLangList) | let b:myLang=0 | endif
888 execute "setlocal spell spelllang=".get(g:myLangList, b:myLang)
889 echo "setlocal spelllang=" g:myLangList[b:myLang]
892 nnoremap <silent> coS :call SwitchSpell()<CR>
893 " fix spelling with first choice
894 nnoremap <Leader>f 1z=
896 " gitdir or home {{{2
898 " http://git.io/v3GAV
899 function! FindGitDirOrHome()
900 let filedir = expand('%:p:h')
901 if isdirectory(filedir)
902 let cmd = 'bash -c "(cd ' . filedir . '; git rev-parse --show-toplevel 2>/dev/null)"'
903 let gitdir = system(cmd)
904 if strlen(gitdir) == 0
914 command! Cdr execute('cd ' . FindGitDirOrHome())
916 command! LCdr execute('lcd ' . FindGitDirOrHome())
918 " vim:set et sw=2 ts=2 tw=78: