2 set runtimepath ^=$XDG_CONFIG_HOME/vim
3 set runtimepath +=$XDG_CONFIG_HOME/vim/after
6 if has('python3') | endif
9 " remove all autocommands
12 call plug#begin('$XDG_DATA_HOME/vim')
13 " This does not update vim-plug, use PlugUpgrade instead
14 Plug 'junegunn/vim-plug'
16 Plug 'airblade/vim-gitgutter' " {{{
17 " prefer other signs such as ycm diags
18 let g:gitgutter_sign_priority = 1
19 " don't clobber other signs
20 let g:gitgutter_sign_allow_clobber = 0
22 Plug 'alepez/vim-gtest'
24 Plug 'andrewradev/sideways.vim' " {{{2
25 nnoremap <silent> ,h :SidewaysLeft<CR>:delmarks z<CR>
26 nnoremap <silent> ,l :SidewaysRight<CR>:delmarks z<CR>
28 Plug 'andrewradev/switch.vim'
30 Plug 'bling/vim-airline' "{{{2
31 let g:airline#extensions#whitespace#enabled = 1
32 let g:airline#extensions#tabline#enabled = 1
33 let g:airline#extensions#searchcount#enabled = 0
34 let g:airline_powerline_fonts = 1
36 let g:asyncrun_status = "stopped"
37 " let g:airline_section_error = airline#section#create_right(['%{g:asyncrun_status}'])
41 Plug 'chrisbra/checkattach'
42 Plug 'derekwyatt/vim-fswitch'
44 Plug 'firef0x/pkgbuild.vim'
45 Plug 'junegunn/vim-easy-align'
46 Plug 'justinmk/vim-sneak'
47 Plug 'klen/python-mode'
48 Plug 'kshenoy/vim-signature'
49 Plug 'majutsushi/tagbar'
50 Plug 'octol/vim-cpp-enhanced-highlight'
51 Plug 'raimondi/delimitmate'
52 Plug 'sgeb/vim-diff-fold'
53 Plug 'skywind3000/asyncrun.vim' " {{{2
54 command! -bang -nargs=* -complete=file Make AsyncRun -save=2 -program=make @ <args>
55 let g:asyncrun_open = 10
57 Plug 'shougo/unite.vim'
58 Plug 'shougo/vimproc.vim', {'do': 'make'}
60 Plug 'thinca/vim-qfreplace'
61 Plug 'tomtom/tcomment_vim'
62 Plug 'tpope/vim-abolish'
63 Plug 'tpope/vim-characterize'
64 Plug 'tpope/vim-endwise'
65 Plug 'tpope/vim-eunuch'
66 Plug 'tpope/vim-fugitive'
67 Plug 'tpope/vim-repeat'
68 Plug 'tpope/vim-scriptease'
69 Plug 'tpope/vim-speeddating'
70 Plug 'tpope/vim-surround' "investigate vim-sandwich
71 Plug 'tpope/vim-unimpaired'
72 Plug 'tweekmonster/spellrotate.vim'
73 Plug 'valloric/youcompleteme', { 'do': './install.py --clangd-completer --clang-completer' }
74 Plug 'vim-scripts/mediawiki.vim'
75 Plug 'vim-scripts/replacewithregister'
76 Plug 'vim-scripts/yankring.vim'
80 Plug 'morhetz/gruvbox' " {{{2
81 let g:gruvbox_contrast_dark = 'hard'
82 let g:gruvbox_contrast_light = 'soft'
85 Plug 'arcticicestudio/nord-vim' " {{{2
88 let g:nord_italic_comments = 1
89 let g:nord_underline = 1
90 let g:nord_uniform_status_lines = 0
91 let g:nord_uniform_diff_background = 0
92 let g:nord_cursor_line_number_background = 0
93 let g:nord_bold_vertical_split_line = 0
99 Plug 'sirver/ultisnips'
100 Plug 'honza/vim-snippets'
103 Plug 'kana/vim-textobj-user'
104 Plug 'julian/vim-textobj-variable-segment'
105 Plug 'sgur/vim-textobj-parameter'
106 Plug 'kana/vim-operator-user'
109 " Check LucHermites plugins: https://github.com/LucHermitte/lh-cpp
111 Plug 'git@github.com:/ram-z/vim-orgmode', { 'branch': 'dev' } " {{{2
112 Plug 'vim-scripts/syntaxrange'
114 let g:org_agenda_files = ['~/org/*.org']
116 Plug 'neovimhaskell/haskell-vim' " {{{2
117 let g:haskell_enable_quantification = 1 " to enable highlighting of `forall`
118 let g:haskell_enable_recursivedo = 1 " to enable highlighting of `mdo` and `rec`
119 let g:haskell_enable_arrowsyntax = 1 " to enable highlighting of `proc`
120 let g:haskell_enable_pattern_synonyms = 1 " to enable highlighting of `pattern`
121 let g:haskell_enable_typeroles = 1 " to enable highlighting of type roles
122 let g:haskell_enable_static_pointers = 1 " to enable highlighting of `static`
123 let g:haskell_backpack = 1 " to enable highlighting of backpack keywords
125 let g:haskell_indent_before_where = 2
128 Plug 'aklt/plantuml-syntax'
130 Plug 'mtth/scratch.vim' " {{{2
131 let g:scratch_no_mappings = 1
132 let g:scratch_autohide = 0
135 let g:man_hardwrap = 80
137 Plug 'vim-utils/vim-man' " {{{2
142 Plug 'jenterkin/vim-autosource' " {{{2
143 let g:autosource_hashdir = $XDG_CACHE_HOME . '/vim/vim-autosource'
144 let g:autosource_conf_names = ['.vimrc', '.vimrc.lua']
148 filetype plugin indent on
153 let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
154 let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
157 "TODO see how I can integrate this into a theme that customises upstream Nord
158 hi debugPC term=reverse ctermbg=8
161 " moving around, searching and patterns {{{2
162 set incsearch " show match for partly typed search command
163 set ignorecase " ignore case when using a search pattern
164 set smartcase " override 'ignorecase' when pattern has upper case characters
165 set hlsearch " highlight all matches for the last used search pattern
167 set nostartofline " don't move the cursor to the first non-blank char of a line
170 set path+=../include/
171 set path+=/usr/include/c++/*
173 " displaying text {{{2
174 set nowrap " long lines wrap
175 set linebreak " wrap long lines at a character in 'breakat'
176 set showbreak=↪ " show these chars for wrapped lines
177 set breakindent " preserve indentation in wrapped text
179 set lazyredraw " don't redraw while executing macros
181 set list " show chars defined in 'listchars'
182 set listchars=tab:❭\ " list of strings used for list mode
183 set listchars+=extends:❯,precedes:❮
184 " Only shown when not in insert mode
185 set listchars+=trail:·
188 au FileType qf setlocal listchars-=trail:·
189 au InsertEnter * set listchars-=trail:·
190 au InsertLeave * set listchars+=trail:·
193 set scrolloff=5 " number of screen lines to show around the cursor
194 set sidescroll=1 " number of collumns to scroll
195 set sidescrolloff=1 " don't scroll over the listchars
197 set fillchars=diff:⣿,vert:│
199 set nonumber " show the line number for each line
200 set norelativenumber " show the relative line number for each line
202 " syntax, highlighting and spelling {{{2
203 set synmaxcol=800 " don't highlight long lines
205 set dictionary=spell " list of dictionary files for keyword completion
209 " multiple windows {{{2
210 set laststatus=2 " 0, 1 or 2; when to use a status line for the last window
212 set previewheight=20 " default height for the preview window
216 " set splitbelow " a new window is put below of the current one
217 set splitright " a new window is put right of the current one
222 " using the mouse {{{2
223 set mouse=rnv " list of flags for using the mouse
224 set ttymouse=xterm " type of mouse
226 " messages and info {{{2
227 set showcmd " Show (partial) command in status line.
228 set ruler " show the cursor position all the time
229 set confirm " Ask what to do when closing unsaved documents
230 set shortmess= " reset option
231 set shortmess+=a " all abbreviations
232 set shortmess+=o " overwrite file-written message
233 set shortmess+=O " file-read message overrides previous
234 set shortmess+=t " truncate file message at start
235 set shortmess+=T " truncate other messages in the middle
236 set shortmess+=W " don't give 'written' or '[w]' when writing a file
237 set shortmess+=A " ignore swapfile warning
238 set shortmess+=I " no splash screen
241 set backspace=indent,eol,start " allow backspacing over everything in insert mode
243 set showmatch " Show matching brackets.
245 set nojoinspaces " don't use two spaces after '.' when joining a line
246 set formatoptions+=j " Delete comment leader when joining lines
247 set formatoptions+=c " Autowrap comments using textwidth
248 set formatoptions+=r " Insert comment leader after hitting <Enter>
249 set formatoptions+=n " Recognize numbered lists
250 set formatoptions+=q " Allow formatting of comments with "gq".
251 set formatoptions+=l " do not wrap lines that have been longer when starting insert mode already
252 set formatoptions+=t " Auto-wrap text using textwidth
253 set formatoptions-=o " Do not insert comment leader after hitting o or O in normal mode
255 set nrformats=hex " number formats recognized for CTRL-A and CTRL-X commands
257 set complete=. " scan the current buffer ( 'wrapscan' is ignored)
258 set complete+=w " scan buffers from other windows
259 set complete+=b " scan other loaded buffers that are in the buffer list
260 set complete+=u " scan the unloaded buffers that are in the buffer list
261 set complete+=t " scan tags
262 set complete+=i " scan current and included files
263 set complete+=kspell " use the currently active spell checking |spell|
265 " whether to use a popup menu for Insert mode completion
266 set completeopt=longest,menuone,preview
268 " tabs and indent {{{2
269 set shiftwidth=4 " number of spaces used for each step of (auto)indent
270 set smarttab " a <Tab> in an indent inserts 'shiftwidth' spaces
271 set softtabstop=4 " if non-zero, number of spaces to insert for a <Tab>
272 set shiftround " round to 'shiftwidth' for "<<" and ">>"
273 set expandtab " expand <Tab> to spaces in Insert mode
276 set pastetoggle=<F11> " key sequence to toggle paste mode
279 set foldmethod=marker " folding type
280 set foldlevelstart=0 " value for 'foldlevel' when starting to edit a file
282 " open folds when jumping to line
285 set viewoptions=cursor " save cursor position
286 set viewoptions+=folds " save folds
289 set diffopt+=filler " show filler lines
290 set diffopt+=vertical " always vertical split
291 set diffopt+=context:10 " 10 lines context between changes
292 set diffopt+=internal
293 set diffopt+=algorithm:patience
295 " reading and writing files {{{2
296 set modeline " read modelines
297 set modelines=2 " only check first/last 2 lines
299 set writebackup " write a backup file before overwriting a file
300 set backup " keep a backup after owerwriting a file
301 set backupdir=$XDG_CACHE_HOME/vim/backup//
303 set backupskip+=.netrc " skip netrc
304 set backupskip+=/dev/shm/pass* " skip passwordstore files
306 set undofile " persistent undo history
307 set undodir=$XDG_CACHE_HOME/vim/undo//
311 au BufWritePre .netrc setlocal noundofile
312 au BufWritePre /dev/shm/pass* setlocal noundofile
313 au BufWritePre /tmp/* setlocal noundofile
316 set autowrite " automatically write a file when leaving a modified buffer
317 set autoread " automatically read a file that has been modified
321 set directory=$XDG_CACHE_HOME/vim/swap//
323 " command line editing {{{2
324 set history=5000 " how many command lines are remembered
325 set wildmenu " command-line completion shows a list of matches
326 set wildmode=longest:full,full " specifies how command line completion works
327 set wildignorecase " ignore case when completing file names
329 set wildignore+=.hg,.git,.svn " Version control
330 set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
331 set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
332 set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
333 set wildignore+=*.spl " compiled spelling word lists
334 set wildignore+=*.sw? " Vim swap files
335 set wildignore+=*.luac " Lua byte code
336 set wildignore+=*.pyc " Python byte code
337 set wildignore+=*.orig " Merge resolution files
339 " running make and jumping to errors {{{2
340 set makeprg=make\ -w " print changing directories
342 set grepprg=ag\ --vimgrep\ $*
344 " language specific {{{2
345 set isfname-== " don't treat `=` as being part of filenames
348 set virtualedit+=block " let cursor move past last char in <C-V> mode
349 set virtualedit+=onemore " allow the cursor to move just past the end of the line
350 set viminfo='100,<50,s10,h,n$XDG_CACHE_HOME/vim/viminfo " viminfo defaults but save file in .cache
352 set viewdir=$XDG_CACHE_HOME/vim/view//
354 set sessionoptions+=unix,slash " damn windows and it's silly ways
357 " Resize splits when the window is resized {{{2
360 autocmd VimResized * :wincmd =
363 " Only show cursorline in the current window and in normal mode {{{2
366 au WinLeave,InsertEnter * set nocursorline
367 au WinEnter,InsertLeave * set cursorline
370 " Treat buffers from stdin (e.g.: echo foo | vim -) as scratch {{{2
373 au StdinReadPost * :set buftype=nofile
376 " Jump to last known cursor position {{{2
379 " blacklist certain filetype
380 let blacklist = ['gitcommit']
381 autocmd BufReadPost *
382 \ if index(blacklist, &ft) < 0 && line("'\"") > 1 && line("'\"") <= line("$") |
383 \ exe "normal! g`\"" |
387 " Check for file modifications automatically {{{2
388 " (current buffer only)
389 " Use :NoAutoChecktime to disable it (uses b:autochecktime)
390 fun! MyAutoCheckTime()
391 " only check timestamp for normal files
392 if &buftype != '' | return | endif
393 if ! exists('b:autochecktime') || b:autochecktime
395 let b:autochecktime = 1
398 augroup MyAutoChecktime
400 au FocusGained,BufEnter,CursorHold,InsertEnter * call MyAutoCheckTime()
402 command! NoAutoChecktime let b:autochecktime=0
403 command! ToggleAutoChecktime let b:autochecktime=!get(b:, 'autochecktime', 0) | echom "b:autochecktime:" b:autochecktime
407 au TerminalOpen * if &buftype == 'terminal' | setlocal bufhidden=hide | endif
412 " allow both <space> and \ to be <leader>
416 function! MakeWithOpt()
417 " TODO only do this if makeprg matches make
418 " if &makeprg =~ "make"
420 if exists("b:make_dir")
421 let l:make_dir = "-C ".b:make_dir
422 elseif exists("t:make_dir")
423 let l:make_dir = "-C ".t:make_dir
424 elseif exists("g:make_dir")
425 let l:make_dir = "-C ".g:make_dir
428 let l:make_targets = ""
429 if exists("g:make_targets")
430 let l:make_targets = g:make_targets
432 execute "Make ".l:make_dir." ".l:make_targets
434 nnoremap <silent> <leader>r :call MakeWithOpt()<cr>
437 nnoremap <silent> <Leader>/ :silent nohl<CR>
440 nnoremap <leader>[ :tabprev<cr>
441 nnoremap <leader>] :tabnext<cr>
443 " paste from selection
444 nnoremap <leader>p* :silent! set paste<CR>"*p:set nopaste<CR>
445 " paste from clipboard
446 nnoremap <leader>p+ :silent! set paste<CR>"+p:set nopaste<CR>
448 " strip trailing whitespace
449 function! StripWhitespace(line1, line2, ...) " {{{2
450 let s_report = &report
452 let pattern = a:0 ? a:1 : '\s\+$'
453 let oldview = winsaveview()
454 exe 'keepjumps keeppatterns '.a:line1.','.a:line2.'substitute/'.pattern.'//e'
455 if oldview != winsaveview()
458 call winrestview(oldview)
459 let &report = s_report
461 command! -range=% -nargs=0 -bar Untrail keepjumps call StripWhitespace(<line1>,<line2>)
462 nnoremap <silent> <leader>ww :Untrail<CR>
465 vnoremap <leader>S y:execute @@<cr>:echo 'Sourced selection.'<cr>
466 nnoremap <leader>S ^vg_y:execute @@<cr>:echo 'Sourced line.'<cr>
468 " jump to last cursor position
471 " Select (charwise) the contents of the current line, excluding indentation.
476 \ :syntax sync fromstart<cr>
477 \ :AirlineRefresh<cr>
478 \ :call popup_clear(1)<cr>
482 " nnoremap <leader>r :silent !ranger %:h<cr>:redraw!<cr>
483 " nnoremap <leader>R :silent !ranger<cr>:redraw!<cr>
490 " display the number of matches for the last search
491 nmap <Leader># :%s:<C-R>/::gn<CR>
493 " center cursor after search and open folds
497 " same when jumping around
500 nnoremap <c-o> <c-o>zzzv
501 nnoremap <c-i> <c-i>zzzv
503 " Not using the default mappings of 'To line from top/bottom'
509 " Heresy, emacs insert bindings
510 inoremap <C-A> <Esc>I
511 inoremap <C-E> <Esc>A
512 cnoremap <C-A> <Home>
515 " proper movement when lines are wrapped
516 noremap <silent><expr> j (v:count == 0 ? 'gj' : 'j')
517 noremap <silent><expr> k (v:count == 0 ? 'gk' : 'k')
523 noremap <Right> <NOP>
525 inoremap <Down> <NOP>
526 inoremap <Left> <NOP>
527 inoremap <Right> <NOP>
529 cnoremap <Down> <NOP>
530 cnoremap <Left> <NOP>
531 cnoremap <Right> <NOP>
533 cnoremap <C-J> <Down>
534 cnoremap <C-H> <Left>
535 cnoremap <C-L> <Right>
537 " close all folds open fold in cursor
540 map <F1> :ls<CR>:b<space>
542 " move between windows (skip previewwindow)
543 nnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
544 nnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
545 tnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
546 tnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
548 "xterm mouse with middleclick paste
549 nnoremap <MiddleMouse> i<MiddleMouse>
550 vnoremap <MiddleMouse> s<MiddleMouse>
552 " fix legacy vi inconsistency
557 " allow repeat operator on visual
558 vnoremap . :normal .<CR>
560 " add line without changing position or leaving mode
561 noremap <silent> <Leader>o :set paste<CR>m`o<ESC>``:set nopaste<CR>
562 noremap <silent> <Leader>O :set paste<CR>m`O<ESC>``:set nopaste<CR>
564 " Don't use Ex mode, use Q for formatting
567 " break undo sequence before removing word
568 inoremap <C-W> <C-G>u<C-W>
570 nnoremap coe :set <C-R>=&expandtab ? 'noexpandtab' : 'expandtab'<CR><CR>
571 nnoremap [oe :set expandtab<CR>
572 nnoremap ]oe :set noexpandtab<CR>
574 for idt in range(1,8)
575 exe 'nnoremap co'.idt.' :setlocal tabstop='.idt.' shiftwidth='.idt.' softtabstop='.idt.'<CR>'
578 " toggle auto format of text
579 nnoremap coa :set <C-R>=&formatoptions =~ "a" ? 'formatoptions-=a' : 'formatoptions+=a'<CR><CR>
580 nnoremap [oa :set formatoptions+=a<CR>
581 nnoremap ]oa :set formatoptions-=a<CR>
583 " space will toggle current fold in normal mode
584 nnoremap <leader><Space> za
585 " create folds around visual selection
586 vnoremap <leader><Space> zf
589 cabbrev w!! SudoWrite
591 " uppercase previous word
592 inoremap <C-C> <Esc>gUiwgi
594 " http://git.io/v3ZeU
595 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>
597 " plugins options {{{1
599 let g:checkattach_filebrowser = 'ranger'
600 let g:checkattach_once = 'y'
603 let delimitMate_expand_cr = 2
604 let g:delimitMate_expand_space = 1
607 nnoremap <silent> <Leader>ff :FSHere<CR>
608 nnoremap <silent> <Leader>fl :FSRight<CR>
609 nnoremap <silent> <Leader>fh :FSLeft<CR>
610 nnoremap <silent> <Leader>fj :FSBelow<CR>
611 nnoremap <silent> <Leader>fk :FSAbove<CR>
612 nnoremap <silent> <Leader>fL :FSSplitRight<CR>
613 nnoremap <silent> <Leader>fH :FSSplitLeft<CR>
614 nnoremap <silent> <Leader>fJ :FSSplitBelow<CR>
615 nnoremap <silent> <Leader>fK :FSSplitAbove<CR>
618 nmap <silent> <leader>dd :tab split \| Gdiff \| wincmd h<CR>
619 " delete fugitive buffers when closed
620 autocmd BufReadPost fugitive://* set bufhidden=delete
622 function! GitToggle()
623 let l:status_buffer = bufname('^fugitive:///*/.git{/worktrees/*,}//$')
624 if buflisted(l:status_buffer)
625 execute 'bdelete '.l:status_buffer
631 command! GitToggle :call GitToggle()
632 command! GToggle GitToggle
633 nnoremap <silent> <leader>gs :GitToggle<CR>
635 nnoremap <silent> <leader>gd :Gdiffsplit<CR>
636 nnoremap <silent> <leader>gc :echohl WarningMsg \| echo "use \<leader>gcc instead" \| echohl None<CR>
637 nnoremap <silent> <leader>gcc :tab G commit -v<CR>
638 nnoremap <silent> <leader>gca :tab G commit -v --amend<CR>
639 nnoremap <leader>gcf :tab G commit -v --fixup=
640 nnoremap <silent> <leader>gp :echohl WarningMsg \| echo "use \<leader>gpp instead" \| echohl None<CR>
641 nnoremap <silent> <leader>gpp :Git push \| copen<CR>
642 nnoremap <silent> <leader>gpf :Git push --force-with-lease \| copen<CR>
643 nnoremap <silent> <leader>gll :Git pull<CR>
644 nnoremap <silent> <leader>gru :Git rebase --interactive @{upstream}<CR>
645 nnoremap <silent> <leader>grp :Git rebase --interactive @{push}<CR>
646 nnoremap <silent> <leader>ga :Gwrite<cr>
647 nnoremap <silent> <leader>gb :G blame<cr>
649 augroup fugitive_gstatus
651 autocmd User FugitiveIndex setlocal winfixheight
652 autocmd User FugitiveIndex nmap <buffer> <leader><space> =
656 nnoremap <F7> :GundoToggle<CR>
657 let g:gundo_prefer_python3 = 1
660 let g:indent_guides_default_mapping = 0
661 let g:indent_guides_guide_size = 1
662 nmap <silent> cog <Plug>IndentGuidesToggle
663 nmap <silent> [og <Plug>IndentGuidesEnable
664 nmap <silent> ]og <Plug>IndentGuidesDisable
666 " close-another-window {{{2
667 nnoremap <silent> <C-W>c <NOP>
668 nnoremap <silent> <C-W>cc <C-W>c
669 nnoremap <silent> <C-W>ch :CloseLeftWindow<CR>
670 nnoremap <silent> <C-W>cl :CloseRightWindow<CR>
671 nnoremap <silent> <C-W>cj :CloseBelowWindow<CR>
672 nnoremap <silent> <C-W>ck :CloseAboveWindow<CR>
676 let g:pymode_rope_completion = 0
677 let g:pymode_rope = 0
679 let g:pymode_folding = 1
680 let g:pymode_lint_ignore = "E221,E266,E501"
681 let g:pymode_lint_cwindow = 0 " don't open cwindow when linting
682 let g:pymode_syntax_space_errors = 0 " don't bother me when I'm typing
685 " disable '[ mappings
687 let g:SignatureMap = {
688 \ 'GotoNextLineAlpha' : "",
689 \ 'GotoPrevLineAlpha' : "",
690 \ 'GotoNextSpotAlpha' : "",
691 \ 'GotoPrevSpotAlpha' : "",
695 let g:switch_mapping = "<Leader>s"
696 let g:switch_custom_definitions = [
701 nmap <silent> z] <Plug>(SpellRotateForward)
702 nmap <silent> z[ <Plug>(SpellRotateBackward)
703 vmap <silent> z] <Plug>(SpellRotateForwardV)
704 vmap <silent> z[ <Plug>(SpellRotateBackwardV)
707 let g:syntastic_enable_highlighting = 0
708 let g:syntastic_error_symbol='E'
709 let g:syntastic_style_error_symbol='S'
710 let g:syntastic_warning_symbol='W'
711 let g:syntastic_style_warning_symbol='S'
712 let g:syntastic_always_populate_loc_list=1
713 nmap <silent> <leader>y :SyntasticCheck<cr>
715 let g:syntastic_cpp_clang_tidy_post_args = "-p build*"
718 let g:syntastic_check_on_open=1
722 map <F5> :TagbarToggle<cr>
723 let g:tagbar_sort = 0
724 let g:tagbar_compact = 1
725 let g:tagbar_autoshowtag = 1
726 let g:tagbar_width = 25
727 let g:tagbar_iconchars = ['+', '-']
730 let g:tcomment_textobject_inlinecomment = 'gic'
731 let g:tcomment#filetype#guess = 0
732 "let g:tcomment#options = {'whitespace' : 'no'}
735 let g:UltiSnipsEditSplit = 'vertical'
736 let g:UltiSnipsSnippetDirectories = [ expand("$XDG_CONFIG_HOME/vim/ultisnips") ]
738 let g:UltiSnipsSnippetDirectories = ["UltiSnips", "ultisnips"]
740 let g:UltiSnipsExpandTrigger = "<tab>"
741 let g:UltiSnipsJumpForwardTrigger = "<tab>"
742 let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
744 " UltiSnips completion function that tries to expand a snippet. If there's no
745 " snippet for expanding, it checks for completion window and if it's shown,
746 " selects first element. If there's no completion window it tries to jump to
747 " next placeholder. If there's no placeholder it just returns TAB key
748 " https://github.com/Valloric/YouCompleteMe/issues/36#issuecomment-15451411
749 function! g:UltiSnips_Complete()
750 call UltiSnips#ExpandSnippet()
751 if g:ulti_expand_res == 0
755 call UltiSnips#JumpForwards()
756 if g:ulti_jump_forwards_res == 0
763 au InsertEnter * exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=g:UltiSnips_Complete()<cr>"
764 let g:UltiSnipsListSnippets="<c-e>"
767 call unite#filters#matcher_default#use(['matcher_fuzzy'])
768 call unite#custom#profile('default', 'context', {
770 \ 'direction': 'botright'
773 nnoremap [unite] <Nop>
774 nmap <leader>u [unite]
775 nnoremap [unite]u :UniteResume<CR>
776 nnoremap <silent> [u :UnitePrevious<CR>
777 nnoremap <silent> ]u :UniteNext<CR>
780 " seems not respected
781 let g:unite_source_grep_max_candidates = 2000
783 " Use ag in unite grep source.
784 let g:unite_source_grep_command = 'ag'
785 let g:unite_source_grep_default_opts = '--smart-case --vimgrep --ignore ''.hg'' --ignore ''.svn'' --ignore ''.git'' --ignore ''.bzr'''
786 let g:unite_source_grep_recursive_opt = ''
788 nnoremap <silent> [unite]a :<C-u>Unite grep:.::
\12\17<CR>
789 nnoremap <silent> [unite]A :<C-u>Unite grep:.:-w:
\12\17<CR>
790 command! -nargs=+ Ag Unite grep:.::<args>
792 " unite-file_rec {{{3
794 " Use ag in unite rec source
795 let g:unite_source_rec_async_command = ['ag', '--follow', '--nocolor', '--nogroup', '-g', '']
797 nnoremap <silent> [unite]f :<C-u>Unite -start-insert file_rec/async<CR>
798 call unite#custom#source('file_rec/async', 'sorters', 'sorter_selecta')
801 call unite#custom#default_action('buffer', 'open')
802 nnoremap <silent> [unite]b :<C-u>Unite buffer:-<CR>
804 " unite-jumplist {{{3
805 nnoremap <silent> [unite]j :<C-u>Unite output:jumps:<CR>
808 let g:unite_source_menu_menus = {}
809 let g:unite_source_menu_menus.fugitive = { 'description' : 'fugitive menu'}
810 let g:unite_source_menu_menus.fugitive.command_candidates = {
811 \ 'Gstatus <Leader>gs' : 'Gstatus',
812 \ 'Gcommit -v <Leader>gc' : 'Gcommit -v',
816 nnoremap <silent> <leader>gg :<C-u>Unite menu:fugitive<CR>
818 let g:unite_source_history_yank_enable = 1
819 nnoremap <silent> [unite]p :<C-u>Unite history/yank<CR>
822 nnoremap <silent> <leader>p :YRShow<cr>
823 let g:yankring_history_dir = expand('$XDG_CACHE_HOME/vim')
824 let g:yankring_replace_n_pkey = ''
825 let g:yankring_replace_n_nkey = ''
827 " map Y to y$ for the yank ring
828 function! YRRunAfterMaps()
829 nnoremap Y :<C-U>YRYankCount 'y$'<CR>
833 let g:ycm_clangd_binary_path = 'clangd' " use clangd in path
834 let g:ycm_clangd_args = ['--clang-tidy']
835 let g:ycm_extra_conf_vim_data = ['getcwd()']
836 let g:ycm_add_preview_to_completeopt = 1
837 let g:ycm_complete_in_comments = 1
838 let g:ycm_complete_in_strings = 1
839 let g:ycm_autoclose_preview_window_after_insertion = 0
841 let g:ycm_language_server =
845 \ 'cmdline': [ 'haskell-language-server-wrapper', '--lsp' ],
846 \ 'filetypes': [ 'haskell', 'lhaskell' ]
850 " vim-easy-align {{{2
851 " start interactive EasyAlign in visual mode
852 vmap <Enter> <Esc>:echohl WarningMsg \| echo "EasyAlign mapped to
\16<leader>a now" \| echohl None<CR>
853 vmap <leader>a <Plug>(EasyAlign)
854 nmap <leader>a <Plug>(EasyAlign)
857 let g:gtest#highlight_failing_tests = 0
859 nnoremap <silent> <Leader>tt :GTestRun<CR>
860 nnoremap <Leader>tc :GTestCase<space>
861 nnoremap <Leader>tn :GTestName<space>
862 nnoremap <silent> <Leader>ta :GTestCase *<CR>:GTestName *<CR>:GTestRun<CR>
863 nnoremap <silent> <Leader>tu :GTestRunUnderCursor<CR>
866 let g:vim_json_syntax_conceal = 0
869 let g:sneak#streak = 1
870 let g:sneak#target_labels = "aoeuisnthdpylrcgfqjkxzmwvz" " dvorak
871 let g:sneak#use_ic_scs = 1 " follow 'ignorecase' and 'smartcase'
889 " Convenient command to see the difference between the current buffer and the
890 " file it was loaded from, thus the changes you made.
891 " Only define it when not defined already.
892 if !exists(":DiffOrig")
893 command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
894 \ | wincmd p | diffthis
898 function! SortLinesOpFunc(...)
901 nnoremap <silent> gs :<C-U>set operatorfunc=SortLinesOpFunc<CR>g@
902 vnoremap <silent> gs :sort<cr>
905 function! EditConfig(what, ext = '.vim')
906 let l:dir = split(&runtimepath,',')[0]
908 let l:file = expand($MYVIMRC)
909 elseif ! isdirectory(globpath(l:dir, a:what))
910 echoe a:what." is not valid!"
911 elseif empty(&filetype)
912 echoe 'filetype is empty!'
914 let l:file = l:dir.'/'.a:what.'/'.&filetype.a:ext
917 execute ':vsplit '.file
920 nmap <leader>ev :call EditConfig('vimrc')<CR>
921 nmap <leader>ef :call EditConfig('ftplugin')<CR>
922 nmap <leader>es :call EditConfig('syntax')<CR>
923 nmap <leader>ei :call EditConfig('indent')<CR>
924 nmap <leader>eu :call EditConfig('ultisnips', '.snippets')<CR>
927 " http://tex.stackexchange.com/a/52932
928 let g:myLangList=["en_gb","en_us","de","fr"]
930 function! ToggleSpell()
931 if !exists("b:myLang")
934 execute "setlocal spell!"
936 echo "setlocal spelllang=" g:myLangList[b:myLang]
940 function! SwitchSpell()
941 if !exists("b:myLang")
945 let b:myLang=b:myLang+1
946 if b:myLang>=len(g:myLangList) | let b:myLang=0 | endif
948 execute "setlocal spell spelllang=".get(g:myLangList, b:myLang)
949 echo "setlocal spelllang=" g:myLangList[b:myLang]
952 nnoremap <silent> coS :call SwitchSpell()<CR>
953 " fix spelling with first choice
954 nnoremap <Leader>f 1z=
956 " gitdir or home {{{2
958 " http://git.io/v3GAV
959 function! FindGitDirOrHome()
960 let filedir = expand('%:p:h')
961 if isdirectory(filedir)
962 let cmd = 'bash -c "(cd ' . filedir . '; git rev-parse --show-toplevel 2>/dev/null)"'
963 let gitdir = system(cmd)
964 if strlen(gitdir) == 0
974 command! Cdr execute('cd ' . FindGitDirOrHome())
976 command! LCdr execute('lcd ' . FindGitDirOrHome())
978 " vim:set et sw=2 ts=2 tw=78: