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
94 Plug 'git@github.com:/ram-z/vim-orgmode', { 'branch': 'dev' } " {{{2
95 Plug 'vim-scripts/syntaxrange'
97 let g:org_agenda_files = ['~/org/*.org']
99 Plug 'neovimhaskell/haskell-vim' " {{{2
100 let g:haskell_enable_quantification = 1 " to enable highlighting of `forall`
101 let g:haskell_enable_recursivedo = 1 " to enable highlighting of `mdo` and `rec`
102 let g:haskell_enable_arrowsyntax = 1 " to enable highlighting of `proc`
103 let g:haskell_enable_pattern_synonyms = 1 " to enable highlighting of `pattern`
104 let g:haskell_enable_typeroles = 1 " to enable highlighting of type roles
105 let g:haskell_enable_static_pointers = 1 " to enable highlighting of `static`
106 let g:haskell_backpack = 1 " to enable highlighting of backpack keywords
109 Plug 'aklt/plantuml-syntax'
111 Plug 'mtth/scratch.vim' " {{{2
112 let g:scratch_no_mappings = 1
113 let g:scratch_autohide = 0
116 Plug 'vim-utils/vim-man' " {{{2
122 filetype plugin indent on
127 let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
128 let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
131 "TODO see how I can integrate this into a theme that customises upstream Nord
132 hi debugPC term=reverse ctermbg=8
135 " moving around, searching and patterns {{{2
136 set incsearch " show match for partly typed search command
137 set ignorecase " ignore case when using a search pattern
138 set smartcase " override 'ignorecase' when pattern has upper case characters
139 set hlsearch " highlight all matches for the last used search pattern
141 set nostartofline " don't move the cursor to the first non-blank char of a line
144 set path+=../include/
145 set path+=/usr/include/c++/*
147 " displaying text {{{2
148 set nowrap " long lines wrap
149 set linebreak " wrap long lines at a character in 'breakat'
150 set showbreak=↪ " show these chars for wrapped lines
151 set breakindent " preserve indentation in wrapped text
153 set lazyredraw " don't redraw while executing macros
155 set list " show chars defined in 'listchars'
156 set listchars=tab:❭\ " list of strings used for list mode
157 set listchars+=extends:❯,precedes:❮
158 " Only shown when not in insert mode
159 set listchars+=trail:·
162 au FileType qf setlocal listchars-=trail:·
163 au InsertEnter * set listchars-=trail:·
164 au InsertLeave * set listchars+=trail:·
167 set scrolloff=5 " number of screen lines to show around the cursor
168 set sidescroll=1 " number of collumns to scroll
169 set sidescrolloff=1 " don't scroll over the listchars
171 set fillchars=diff:⣿,vert:│
173 set nonumber " show the line number for each line
174 set norelativenumber " show the relative line number for each line
176 " syntax, highlighting and spelling {{{2
177 set synmaxcol=800 " don't highlight long lines
179 set dictionary=spell " list of dictionary files for keyword completion
183 " multiple windows {{{2
184 set laststatus=2 " 0, 1 or 2; when to use a status line for the last window
186 set previewheight=20 " default height for the preview window
190 " set splitbelow " a new window is put below of the current one
191 set splitright " a new window is put right of the current one
196 " using the mouse {{{2
197 set mouse=rnv " list of flags for using the mouse
198 set ttymouse=xterm " type of mouse
200 " messages and info {{{2
201 set showcmd " Show (partial) command in status line.
202 set ruler " show the cursor position all the time
203 set confirm " Ask what to do when closing unsaved documents
204 set shortmess= " reset option
205 set shortmess+=a " all abbreviations
206 set shortmess+=o " overwrite file-written message
207 set shortmess+=O " file-read message overrides previous
208 set shortmess+=t " truncate file message at start
209 set shortmess+=T " truncate other messages in the middle
210 set shortmess+=W " don't give 'written' or '[w]' when writing a file
211 set shortmess+=A " ignore swapfile warning
212 set shortmess+=I " no splash screen
215 set backspace=indent,eol,start " allow backspacing over everything in insert mode
217 set showmatch " Show matching brackets.
219 set nojoinspaces " don't use two spaces after '.' when joining a line
220 set formatoptions+=j " Delete comment leader when joining lines
221 set formatoptions+=c " Autowrap comments using textwidth
222 set formatoptions+=r " Insert comment leader after hitting <Enter>
223 set formatoptions+=n " Recognize numbered lists
224 set formatoptions+=q " Allow formatting of comments with "gq".
225 set formatoptions+=l " do not wrap lines that have been longer when starting insert mode already
226 set formatoptions+=t " Auto-wrap text using textwidth
227 set formatoptions-=o " Do not insert comment leader after hitting o or O in normal mode
229 set nrformats=hex " number formats recognized for CTRL-A and CTRL-X commands
231 set complete=. " scan the current buffer ( 'wrapscan' is ignored)
232 set complete+=w " scan buffers from other windows
233 set complete+=b " scan other loaded buffers that are in the buffer list
234 set complete+=u " scan the unloaded buffers that are in the buffer list
235 set complete+=t " scan tags
236 set complete+=i " scan current and included files
237 set complete+=kspell " use the currently active spell checking |spell|
239 " whether to use a popup menu for Insert mode completion
240 set completeopt=longest,menuone,preview
242 " tabs and indent {{{2
243 set shiftwidth=4 " number of spaces used for each step of (auto)indent
244 set smarttab " a <Tab> in an indent inserts 'shiftwidth' spaces
245 set softtabstop=4 " if non-zero, number of spaces to insert for a <Tab>
246 set shiftround " round to 'shiftwidth' for "<<" and ">>"
247 set expandtab " expand <Tab> to spaces in Insert mode
250 set pastetoggle=<F11> " key sequence to toggle paste mode
253 set foldmethod=marker " folding type
254 set foldlevelstart=0 " value for 'foldlevel' when starting to edit a file
256 " open folds when jumping to line
259 set viewoptions=cursor " save cursor position
260 set viewoptions+=folds " save folds
263 set diffopt+=filler " show filler lines
264 set diffopt+=vertical " always vertical split
265 set diffopt+=context:10 " 10 lines context between changes
266 set diffopt+=internal
267 set diffopt+=algorithm:patience
269 " reading and writing files {{{2
270 set modeline " read modelines
271 set modelines=2 " only check first/last 2 lines
273 set writebackup " write a backup file before overwriting a file
274 set backup " keep a backup after owerwriting a file
275 set backupdir=$XDG_CACHE_HOME/vim/backup//
277 set backupskip+=.netrc " skip netrc
278 set backupskip+=/dev/shm/pass* " skip passwordstore files
280 set undofile " persistent undo history
281 set undodir=$XDG_CACHE_HOME/vim/undo//
285 au BufWritePre .netrc setlocal noundofile
286 au BufWritePre /dev/shm/pass* setlocal noundofile
287 au BufWritePre /tmp/* setlocal noundofile
290 set autowrite " automatically write a file when leaving a modified buffer
291 set autoread " automatically read a file that has been modified
295 set directory=$XDG_CACHE_HOME/vim/swap//
297 " command line editing {{{2
298 set history=5000 " how many command lines are remembered
299 set wildmenu " command-line completion shows a list of matches
300 set wildmode=longest:full,full " specifies how command line completion works
301 set wildignorecase " ignore case when completing file names
303 set wildignore+=.hg,.git,.svn " Version control
304 set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
305 set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
306 set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
307 set wildignore+=*.spl " compiled spelling word lists
308 set wildignore+=*.sw? " Vim swap files
309 set wildignore+=*.luac " Lua byte code
310 set wildignore+=*.pyc " Python byte code
311 set wildignore+=*.orig " Merge resolution files
313 " running make and jumping to errors {{{2
314 set makeprg=make\ -w " print changing directories
316 set grepprg=ag\ --vimgrep\ $*
318 " language specific {{{2
319 set isfname-== " don't treat `=` as being part of filenames
322 set virtualedit+=block " let cursor move past last char in <C-V> mode
323 set virtualedit+=onemore " allow the cursor to move just past the end of the line
324 set viminfo='100,<50,s10,h,n$XDG_CACHE_HOME/vim/viminfo " viminfo defaults but save file in .cache
326 set viewdir=$XDG_CACHE_HOME/vim/view//
328 set sessionoptions+=unix,slash " damn windows and it's silly ways
331 " Resize splits when the window is resized {{{2
334 autocmd VimResized * :wincmd =
337 " Only show cursorline in the current window and in normal mode {{{2
340 au WinLeave,InsertEnter * set nocursorline
341 au WinEnter,InsertLeave * set cursorline
344 " Treat buffers from stdin (e.g.: echo foo | vim -) as scratch {{{2
347 au StdinReadPost * :set buftype=nofile
350 " Jump to last known cursor position {{{2
353 " blacklist certain filetype
354 let blacklist = ['gitcommit']
355 autocmd BufReadPost *
356 \ if index(blacklist, &ft) < 0 && line("'\"") > 1 && line("'\"") <= line("$") |
357 \ exe "normal! g`\"" |
361 " Check for file modifications automatically {{{2
362 " (current buffer only)
363 " Use :NoAutoChecktime to disable it (uses b:autochecktime)
364 fun! MyAutoCheckTime()
365 " only check timestamp for normal files
366 if &buftype != '' | return | endif
367 if ! exists('b:autochecktime') || b:autochecktime
369 let b:autochecktime = 1
372 augroup MyAutoChecktime
374 au FocusGained,BufEnter,CursorHold,InsertEnter * call MyAutoCheckTime()
376 command! NoAutoChecktime let b:autochecktime=0
377 command! ToggleAutoChecktime let b:autochecktime=!get(b:, 'autochecktime', 0) | echom "b:autochecktime:" b:autochecktime
381 au TerminalOpen * if &buftype == 'terminal' | setlocal bufhidden=hide | endif
386 " allow both <space> and \ to be <leader>
392 if exists("b:make_dir")
393 let l:make_dir = "-C ".b:make_dir
394 elseif exists("g:make_dir")
395 let l:make_dir = "-C ".g:make_dir
398 let l:make_targets = ""
399 if exists("g:make_targets")
400 let l:make_targets = g:make_targets
402 execute "make! ".l:make_dir." ".l:make_targets
404 nnoremap <leader>r :call Make()<cr>
407 nnoremap <silent> <Leader>/ :silent nohl<CR>
410 nnoremap <leader>[ :tabprev<cr>
411 nnoremap <leader>] :tabnext<cr>
413 " paste from selection
414 nnoremap <leader>p* :silent! set paste<CR>"*p:set nopaste<CR>
415 " paste from clipboard
416 nnoremap <leader>p+ :silent! set paste<CR>"+p:set nopaste<CR>
418 " strip trailing whitespace
419 function! StripWhitespace(line1, line2, ...) " {{{2
420 let s_report = &report
422 let pattern = a:0 ? a:1 : '\s\+$'
423 let oldview = winsaveview()
424 exe 'keepjumps keeppatterns '.a:line1.','.a:line2.'substitute/'.pattern.'//e'
425 if oldview != winsaveview()
428 call winrestview(oldview)
429 let &report = s_report
431 command! -range=% -nargs=0 -bar Untrail keepjumps call StripWhitespace(<line1>,<line2>)
432 nnoremap <silent> <leader>ww :Untrail<CR>
435 vnoremap <leader>S y:execute @@<cr>:echo 'Sourced selection.'<cr>
436 nnoremap <leader>S ^vg_y:execute @@<cr>:echo 'Sourced line.'<cr>
438 " jump to last cursor position
441 " Select (charwise) the contents of the current line, excluding indentation.
446 \ :syntax sync fromstart<cr>
447 \ :AirlineRefresh<cr>
448 \ :call popup_clear(1)<cr>
452 " nnoremap <leader>r :silent !ranger %:h<cr>:redraw!<cr>
453 " nnoremap <leader>R :silent !ranger<cr>:redraw!<cr>
460 " display the number of matches for the last search
461 nmap <Leader># :%s:<C-R>/::gn<CR>
463 " center cursor after search and open folds
467 " same when jumping around
470 nnoremap <c-o> <c-o>zzzv
471 nnoremap <c-i> <c-i>zzzv
473 " Not using the default mappings of 'To line from top/bottom'
479 " Heresy, emacs insert bindings
480 inoremap <C-A> <Esc>I
481 inoremap <C-E> <Esc>A
482 cnoremap <C-A> <Home>
485 " proper movement when lines are wrapped
486 noremap <silent><expr> j (v:count == 0 ? 'gj' : 'j')
487 noremap <silent><expr> k (v:count == 0 ? 'gk' : 'k')
493 noremap <Right> <NOP>
495 inoremap <Down> <NOP>
496 inoremap <Left> <NOP>
497 inoremap <Right> <NOP>
499 cnoremap <Down> <NOP>
500 cnoremap <Left> <NOP>
501 cnoremap <Right> <NOP>
503 cnoremap <C-J> <Down>
504 cnoremap <C-H> <Left>
505 cnoremap <C-L> <Right>
507 " close all folds open fold in cursor
510 map <F1> :ls<CR>:b<space>
512 " move between windows (skip previewwindow)
513 nnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
514 nnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
515 tnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
516 tnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
518 "xterm mouse with middleclick paste
519 nnoremap <MiddleMouse> i<MiddleMouse>
520 vnoremap <MiddleMouse> s<MiddleMouse>
522 " fix legacy vi inconsistency
527 " allow repeat operator on visual
528 vnoremap . :normal .<CR>
530 " add line without changing position or leaving mode
531 noremap <silent> <Leader>o :set paste<CR>m`o<ESC>``:set nopaste<CR>
532 noremap <silent> <Leader>O :set paste<CR>m`O<ESC>``:set nopaste<CR>
534 " Don't use Ex mode, use Q for formatting
537 " break undo sequence before removing word
538 inoremap <C-W> <C-G>u<C-W>
540 nnoremap coe :set <C-R>=&expandtab ? 'noexpandtab' : 'expandtab'<CR><CR>
541 nnoremap [oe :set expandtab<CR>
542 nnoremap ]oe :set noexpandtab<CR>
544 for idt in range(1,8)
545 exe 'nnoremap co'.idt.' :setlocal tabstop='.idt.' shiftwidth='.idt.' softtabstop='.idt.'<CR>'
548 " toggle auto format of text
549 nnoremap coa :set <C-R>=&formatoptions =~ "a" ? 'formatoptions-=a' : 'formatoptions+=a'<CR><CR>
550 nnoremap [oa :set formatoptions+=a<CR>
551 nnoremap ]oa :set formatoptions-=a<CR>
553 " space will toggle current fold in normal mode
554 nnoremap <leader><Space> za
555 " create folds around visual selection
556 vnoremap <leader><Space> zf
559 cabbrev w!! SudoWrite
561 " uppercase previous word
562 inoremap <C-C> <Esc>gUiwgi
564 " http://git.io/v3ZeU
565 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>
567 " plugins options {{{1
569 let g:airline#extensions#whitespace#enabled = 1
570 let g:airline#extensions#tabline#enabled = 1
571 let g:airline#extensions#searchcount#enabled = 0
572 let g:airline_powerline_fonts = 1
575 let g:checkattach_filebrowser = 'ranger'
576 let g:checkattach_once = 'y'
579 let delimitMate_expand_cr = 2
580 let g:delimitMate_expand_space = 1
583 nnoremap <silent> <Leader>ff :FSHere<CR>
584 nnoremap <silent> <Leader>fl :FSRight<CR>
585 nnoremap <silent> <Leader>fh :FSLeft<CR>
586 nnoremap <silent> <Leader>fj :FSBelow<CR>
587 nnoremap <silent> <Leader>fk :FSAbove<CR>
588 nnoremap <silent> <Leader>fL :FSSplitRight<CR>
589 nnoremap <silent> <Leader>fH :FSSplitLeft<CR>
590 nnoremap <silent> <Leader>fJ :FSSplitBelow<CR>
591 nnoremap <silent> <Leader>fK :FSSplitAbove<CR>
594 nmap <silent> <leader>dd :tab split \| Gdiff \| wincmd h<CR>
595 " delete fugitive buffers when closed
596 autocmd BufReadPost fugitive://* set bufhidden=delete
598 nnoremap <silent> <leader>gs :Git<CR>
599 nnoremap <silent> <leader>gd :Gdiffsplit<CR>
600 nnoremap <silent> <leader>gc :echohl WarningMsg \| echo "use \<leader>gcc instead" \| echohl None<CR>
601 nnoremap <silent> <leader>gcc :tab G commit -v<CR>
602 nnoremap <silent> <leader>gca :tab G commit -v --amend<CR>
603 nnoremap <leader>gcf :tab G commit -v --fixup=
604 nnoremap <silent> <leader>gp :echohl WarningMsg \| echo "use \<leader>gpp instead" \| echohl None<CR>
605 nnoremap <silent> <leader>gpp :Git push \| copen<CR>
606 nnoremap <silent> <leader>gpf :Git push --force-with-lease \| copen<CR>
607 nnoremap <silent> <leader>gll :Git pull<CR>
608 nnoremap <silent> <leader>gru :Git rebase --interactive @{upstream}<CR>
609 nnoremap <silent> <leader>grp :Git rebase --interactive @{push}<CR>
610 nnoremap <silent> <leader>ga :Gwrite<cr>
611 nnoremap <silent> <leader>gb :G blame<cr>
613 augroup fugitive_gstatus
615 autocmd BufWinEnter */.git/index resize 16
619 nnoremap <F7> :GundoToggle<CR>
620 let g:gundo_prefer_python3 = 1
623 let g:indent_guides_default_mapping = 0
624 let g:indent_guides_guide_size = 1
625 nmap <silent> cog <Plug>IndentGuidesToggle
626 nmap <silent> [og <Plug>IndentGuidesEnable
627 nmap <silent> ]og <Plug>IndentGuidesDisable
629 " close-another-window {{{2
630 nnoremap <silent> <C-W>c <NOP>
631 nnoremap <silent> <C-W>cc <C-W>c
632 nnoremap <silent> <C-W>ch :CloseLeftWindow<CR>
633 nnoremap <silent> <C-W>cl :CloseRightWindow<CR>
634 nnoremap <silent> <C-W>cj :CloseBelowWindow<CR>
635 nnoremap <silent> <C-W>ck :CloseAboveWindow<CR>
639 let g:pymode_rope_completion = 0
640 let g:pymode_rope = 0
642 let g:pymode_folding = 1
643 let g:pymode_lint_ignore = "E221,E266,E501"
644 let g:pymode_lint_cwindow = 0 " don't open cwindow when linting
645 let g:pymode_syntax_space_errors = 0 " don't bother me when I'm typing
648 " disable '[ mappings
650 let g:SignatureMap = {
651 \ 'GotoNextLineAlpha' : "",
652 \ 'GotoPrevLineAlpha' : "",
653 \ 'GotoNextSpotAlpha' : "",
654 \ 'GotoPrevSpotAlpha' : "",
658 let g:switch_mapping = "<Leader>s"
661 nmap <silent> z] <Plug>(SpellRotateForward)
662 nmap <silent> z[ <Plug>(SpellRotateBackward)
663 vmap <silent> z] <Plug>(SpellRotateForwardV)
664 vmap <silent> z[ <Plug>(SpellRotateBackwardV)
667 let g:syntastic_enable_highlighting = 0
668 let g:syntastic_error_symbol='E'
669 let g:syntastic_style_error_symbol='S'
670 let g:syntastic_warning_symbol='W'
671 let g:syntastic_style_warning_symbol='S'
672 let g:syntastic_always_populate_loc_list=1
673 nmap <silent> <leader>y :SyntasticCheck<cr>
675 let g:syntastic_cpp_clang_tidy_post_args = "-p build*"
678 let g:syntastic_check_on_open=1
682 map <F5> :TagbarToggle<cr>
683 let g:tagbar_sort = 0
684 let g:tagbar_compact = 1
685 let g:tagbar_autoshowtag = 1
686 let g:tagbar_width = 25
687 let g:tagbar_iconchars = ['+', '-']
690 let g:tcomment_textobject_inlinecomment = 'gic'
691 let g:tcomment#filetype#guess = 0
694 let g:UltiSnipsEditSplit = 'vertical'
695 let g:UltiSnipsSnippetDirectories = [ expand("$XDG_CONFIG_HOME/vim/ultisnips") ]
697 let g:UltiSnipsSnippetDirectories = ["UltiSnips", "ultisnips"]
699 let g:UltiSnipsExpandTrigger = "<tab>"
700 let g:UltiSnipsJumpForwardTrigger = "<tab>"
701 let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
703 " UltiSnips completion function that tries to expand a snippet. If there's no
704 " snippet for expanding, it checks for completion window and if it's shown,
705 " selects first element. If there's no completion window it tries to jump to
706 " next placeholder. If there's no placeholder it just returns TAB key
707 " https://github.com/Valloric/YouCompleteMe/issues/36#issuecomment-15451411
708 function! g:UltiSnips_Complete()
709 call UltiSnips#ExpandSnippet()
710 if g:ulti_expand_res == 0
714 call UltiSnips#JumpForwards()
715 if g:ulti_jump_forwards_res == 0
722 au InsertEnter * exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=g:UltiSnips_Complete()<cr>"
723 let g:UltiSnipsListSnippets="<c-e>"
726 call unite#filters#matcher_default#use(['matcher_fuzzy'])
727 call unite#custom#profile('default', 'context', {
729 \ 'direction': 'botright'
732 nnoremap [unite] <Nop>
733 nmap <leader>u [unite]
734 nnoremap [unite]u :UniteResume<CR>
735 nnoremap <silent> [u :UnitePrevious<CR>
736 nnoremap <silent> ]u :UniteNext<CR>
739 " seems not respected
740 let g:unite_source_grep_max_candidates = 2000
742 " Use ag in unite grep source.
743 let g:unite_source_grep_command = 'ag'
744 let g:unite_source_grep_default_opts = '--smart-case --vimgrep --ignore ''.hg'' --ignore ''.svn'' --ignore ''.git'' --ignore ''.bzr'''
745 let g:unite_source_grep_recursive_opt = ''
747 nnoremap <silent> [unite]a :<C-u>Unite grep:.::
\12\17<CR>
748 nnoremap <silent> [unite]A :<C-u>Unite grep:.:-w:
\12\17<CR>
749 command! -nargs=+ Ag Unite -input=<args> grep:.:
751 " unite-file_rec {{{3
753 " Use ag in unite rec source
754 let g:unite_source_rec_async_command = ['ag', '--follow', '--nocolor', '--nogroup', '-g', '']
756 nnoremap <silent> [unite]f :<C-u>Unite -start-insert file_rec/async<CR>
757 call unite#custom#source('file_rec/async', 'sorters', 'sorter_selecta')
760 call unite#custom#default_action('buffer', 'open')
761 nnoremap <silent> [unite]b :<C-u>Unite buffer:-<CR>
763 " unite-jumplist {{{3
764 nnoremap <silent> [unite]j :<C-u>Unite output:jumps:<CR>
767 let g:unite_source_menu_menus = {}
768 let g:unite_source_menu_menus.fugitive = { 'description' : 'fugitive menu'}
769 let g:unite_source_menu_menus.fugitive.command_candidates = {
770 \ 'Gstatus <Leader>gs' : 'Gstatus',
771 \ 'Gcommit -v <Leader>gc' : 'Gcommit -v',
775 nnoremap <silent> <leader>gg :<C-u>Unite menu:fugitive<CR>
777 let g:unite_source_history_yank_enable = 1
778 nnoremap <silent> [unite]p :<C-u>Unite history/yank<CR>
781 nnoremap <silent> <leader>p :YRShow<cr>
782 let g:yankring_history_dir = expand('$XDG_CACHE_HOME/vim')
783 let g:yankring_replace_n_pkey = ''
784 let g:yankring_replace_n_nkey = ''
786 " map Y to y$ for the yank ring
787 function! YRRunAfterMaps()
788 nnoremap Y :<C-U>YRYankCount 'y$'<CR>
792 let g:ycm_clangd_binary_path = 'clangd' " use clangd in path
793 let g:ycm_clangd_args = ['--clang-tidy']
794 let g:ycm_extra_conf_vim_data = ['getcwd()']
795 let g:ycm_add_preview_to_completeopt = 1
796 let g:ycm_complete_in_comments = 1
797 let g:ycm_complete_in_strings = 1
798 let g:ycm_autoclose_preview_window_after_insertion = 0
800 " vim-easy-align {{{2
801 " start interactive EasyAlign in visual mode
802 vmap <Enter> <Plug>(EasyAlign)
803 nmap ga <Plug>(EasyAlign)
806 let g:gtest#highlight_failing_tests = 0
808 nnoremap <silent> <Leader>tt :GTestRun<CR>
809 nnoremap <Leader>tc :GTestCase<space>
810 nnoremap <Leader>tn :GTestName<space>
811 nnoremap <silent> <Leader>ta :GTestCase *<CR>:GTestName *<CR>:GTestRun<CR>
812 nnoremap <silent> <Leader>tu :GTestRunUnderCursor<CR>
815 let g:vim_json_syntax_conceal = 0
818 let g:sneak#streak = 1
819 let g:sneak#target_labels = "aoeuisnthdpylrcgfqjkxzmwvz" " dvorak
820 let g:sneak#use_ic_scs = 1 " follow 'ignorecase' and 'smartcase'
838 " Convenient command to see the difference between the current buffer and the
839 " file it was loaded from, thus the changes you made.
840 " Only define it when not defined already.
841 if !exists(":DiffOrig")
842 command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
843 \ | wincmd p | diffthis
847 function! SortLinesOpFunc(...)
850 nnoremap <silent> gs :<C-U>set operatorfunc=SortLinesOpFunc<CR>g@
851 vnoremap <silent> gs :sort<cr>
854 function! EditConfig(what, ext = '.vim')
855 let l:dir = split(&runtimepath,',')[0]
857 let l:file = expand($MYVIMRC)
858 elseif ! isdirectory(globpath(l:dir, a:what))
859 echoe a:what." is not valid!"
860 elseif empty(&filetype)
861 echoe 'filetype is empty!'
863 let l:file = l:dir.'/'.a:what.'/'.&filetype.a:ext
866 execute ':vsplit '.file
869 nmap <leader>ev :call EditConfig('vimrc')<CR>
870 nmap <leader>ef :call EditConfig('ftplugin')<CR>
871 nmap <leader>es :call EditConfig('syntax')<CR>
872 nmap <leader>ei :call EditConfig('indent')<CR>
873 nmap <leader>eu :call EditConfig('ultisnips', '.snippets')<CR>
876 " http://tex.stackexchange.com/a/52932
877 let g:myLangList=["en_gb","en_us","de","fr"]
879 function! ToggleSpell()
880 if !exists("b:myLang")
883 execute "setlocal spell!"
885 echo "setlocal spelllang=" g:myLangList[b:myLang]
889 function! SwitchSpell()
890 if !exists("b:myLang")
894 let b:myLang=b:myLang+1
895 if b:myLang>=len(g:myLangList) | let b:myLang=0 | endif
897 execute "setlocal spell spelllang=".get(g:myLangList, b:myLang)
898 echo "setlocal spelllang=" g:myLangList[b:myLang]
901 nnoremap <silent> coS :call SwitchSpell()<CR>
902 " fix spelling with first choice
903 nnoremap <Leader>f 1z=
905 " gitdir or home {{{2
907 " http://git.io/v3GAV
908 function! FindGitDirOrHome()
909 let filedir = expand('%:p:h')
910 if isdirectory(filedir)
911 let cmd = 'bash -c "(cd ' . filedir . '; git rev-parse --show-toplevel 2>/dev/null)"'
912 let gitdir = system(cmd)
913 if strlen(gitdir) == 0
923 command! Cdr execute('cd ' . FindGitDirOrHome())
925 command! LCdr execute('lcd ' . FindGitDirOrHome())
927 " vim:set et sw=2 ts=2 tw=78: