2 if has('python3') | endif
8 set runtimepath ^=$XDG_CONFIG_HOME/vim
9 set runtimepath +=$XDG_CONFIG_HOME/vim/after
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'
74 " Plug 'valloric/youcompleteme' {{{2
75 Plug 'valloric/youcompleteme',
76 \{ 'do': './install.py --clangd-completer --clang-completer' }
77 let g:ycm_clangd_binary_path = 'clangd' " use clangd in path
78 let g:ycm_clangd_args = ['--clang-tidy']
79 let g:ycm_extra_conf_vim_data = ['getcwd()']
80 let g:ycm_add_preview_to_completeopt = 1
81 let g:ycm_complete_in_comments = 1
82 let g:ycm_complete_in_strings = 1
83 let g:ycm_autoclose_preview_window_after_insertion = 0
85 let g:ycm_language_server =
89 \ 'cmdline': [ 'haskell-language-server-wrapper', '--lsp' ],
90 \ 'filetypes': [ 'haskell', 'lhaskell' ]
95 Plug 'vim-scripts/mediawiki.vim'
96 Plug 'vim-scripts/replacewithregister'
97 Plug 'vim-scripts/yankring.vim'
101 Plug 'morhetz/gruvbox' " {{{2
102 let g:gruvbox_contrast_dark = 'hard'
103 let g:gruvbox_contrast_light = 'soft'
106 Plug 'arcticicestudio/nord-vim' " {{{2
108 let g:nord_italic = 1
109 let g:nord_italic_comments = 1
110 let g:nord_underline = 1
111 let g:nord_uniform_status_lines = 0
112 let g:nord_uniform_diff_background = 0
113 let g:nord_cursor_line_number_background = 0
114 let g:nord_bold_vertical_split_line = 0
120 Plug 'sirver/ultisnips' " {{{
121 Plug 'honza/vim-snippets'
123 let g:UltiSnipsEditSplit = 'vertical'
124 let g:UltiSnipsSnippetDirectories = [ expand("$XDG_CONFIG_HOME/vim/ultisnips") ]
126 let g:UltiSnipsSnippetDirectories = ["UltiSnips", "ultisnips"]
128 let g:UltiSnipsExpandTrigger = "<tab>"
129 let g:UltiSnipsJumpForwardTrigger = "<tab>"
130 let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
132 " UltiSnips completion function that tries to expand a snippet. If there's no
133 " snippet for expanding, it checks for completion window and if it's shown,
134 " selects first element. If there's no completion window it tries to jump to
135 " next placeholder. If there's no placeholder it just returns TAB key
136 " https://github.com/Valloric/YouCompleteMe/issues/36#issuecomment-15451411
137 function! g:UltiSnips_Complete()
138 call UltiSnips#ExpandSnippet()
139 if g:ulti_expand_res == 0
143 call UltiSnips#JumpForwards()
144 if g:ulti_jump_forwards_res == 0
151 au InsertEnter * exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=g:UltiSnips_Complete()<cr>"
152 let g:UltiSnipsListSnippets="<c-e>"
157 Plug 'kana/vim-textobj-user'
158 Plug 'julian/vim-textobj-variable-segment'
159 Plug 'sgur/vim-textobj-parameter'
160 Plug 'kana/vim-operator-user'
163 " Check LucHermites plugins: https://github.com/LucHermitte/lh-cpp
164 Plug 'imsnif/kdl.vim'
166 Plug 'puremourning/vimspector'
167 Plug 'ilyachur/cmake4vim'
168 Plug 'ilyachur/gtest-vim'
170 Plug 'git@github.com:/ram-z/vim-orgmode', { 'branch': 'dev' } " {{{2
171 Plug 'vim-scripts/syntaxrange'
173 let g:org_agenda_files = ['~/org/*.org']
175 Plug 'neovimhaskell/haskell-vim' " {{{2
176 let g:haskell_enable_quantification = 1 " to enable highlighting of `forall`
177 let g:haskell_enable_recursivedo = 1 " to enable highlighting of `mdo` and `rec`
178 let g:haskell_enable_arrowsyntax = 1 " to enable highlighting of `proc`
179 let g:haskell_enable_pattern_synonyms = 1 " to enable highlighting of `pattern`
180 let g:haskell_enable_typeroles = 1 " to enable highlighting of type roles
181 let g:haskell_enable_static_pointers = 1 " to enable highlighting of `static`
182 let g:haskell_backpack = 1 " to enable highlighting of backpack keywords
184 let g:haskell_indent_before_where = 2
187 Plug 'aklt/plantuml-syntax'
189 Plug 'mtth/scratch.vim' " {{{2
190 let g:scratch_no_mappings = 1
191 let g:scratch_autohide = 0
194 let g:man_hardwrap = 80
196 Plug 'vim-utils/vim-man' " {{{2
201 Plug 'jenterkin/vim-autosource' " {{{2
202 let g:autosource_hashdir = $XDG_CACHE_HOME . '/vim/vim-autosource'
203 let g:autosource_conf_names = ['.vimrc', '.vimrc.lua']
207 filetype plugin indent on
212 let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
213 let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
218 "TODO see how I can integrate this into a theme that customises upstream Nord
219 hi debugPC term=reverse ctermbg=8
222 " moving around, searching and patterns {{{2
223 set incsearch " show match for partly typed search command
224 set ignorecase " ignore case when using a search pattern
225 set smartcase " override 'ignorecase' when pattern has upper case characters
226 set hlsearch " highlight all matches for the last used search pattern
228 set nostartofline " don't move the cursor to the first non-blank char of a line
231 set path+=../include/
232 set path+=/usr/include/c++/*
234 " displaying text {{{2
235 set nowrap " long lines wrap
236 set linebreak " wrap long lines at a character in 'breakat'
237 set showbreak=↪ " show these chars for wrapped lines
238 set breakindent " preserve indentation in wrapped text
240 set lazyredraw " don't redraw while executing macros
242 set list " show chars defined in 'listchars'
243 set listchars=tab:❭\ " list of strings used for list mode
244 set listchars+=extends:❯,precedes:❮
245 set listchars+=nbsp:␣
246 " Only shown when not in insert mode
247 set listchars+=trail:·
250 au FileType qf setlocal listchars-=trail:·
251 au InsertEnter * set listchars-=trail:·
252 au InsertLeave * set listchars+=trail:·
255 set scrolloff=5 " number of screen lines to show around the cursor
256 set sidescroll=1 " number of collumns to scroll
257 set sidescrolloff=1 " don't scroll over the listchars
258 set display+=lastline " display as much as possible of last line
260 set fillchars=diff:⣿,vert:│
262 set nonumber " show the line number for each line
263 set norelativenumber " show the relative line number for each line
265 " syntax, highlighting and spelling {{{2
266 set synmaxcol=800 " don't highlight long lines
268 set dictionary=spell " list of dictionary files for keyword completion
272 " multiple windows {{{2
273 set laststatus=2 " 0, 1 or 2; when to use a status line for the last window
275 set previewheight=20 " default height for the preview window
279 " set splitbelow " a new window is put below of the current one
280 set splitright " a new window is put right of the current one
285 " using the mouse {{{2
286 set mouse=rnv " list of flags for using the mouse
288 set ttymouse=xterm " type of mouse
291 " messages and info {{{2
292 set showcmd " Show (partial) command in status line.
293 set ruler " show the cursor position all the time
294 set confirm " Ask what to do when closing unsaved documents
295 set shortmess= " reset option
296 set shortmess+=a " all abbreviations
297 set shortmess+=o " overwrite file-written message
298 set shortmess+=O " file-read message overrides previous
299 set shortmess+=t " truncate file message at start
300 set shortmess+=T " truncate other messages in the middle
301 set shortmess+=W " don't give 'written' or '[w]' when writing a file
302 set shortmess+=A " ignore swapfile warning
303 set shortmess+=I " no splash screen
304 set shortmess+=c " don't give |ins-completion-menu| messages
307 set backspace=indent,eol,start " allow backspacing over everything in insert mode
309 set showmatch " Show matching brackets.
311 set nojoinspaces " don't use two spaces after '.' when joining a line
312 set formatoptions+=j " Delete comment leader when joining lines
313 set formatoptions+=c " Autowrap comments using textwidth
314 set formatoptions+=r " Insert comment leader after hitting <Enter>
315 set formatoptions+=n " Recognize numbered lists
316 set formatoptions+=q " Allow formatting of comments with "gq".
317 set formatoptions+=l " do not wrap lines that have been longer when starting insert mode already
318 set formatoptions+=t " Auto-wrap text using textwidth
319 set formatoptions-=o " Do not insert comment leader after hitting o or O in normal mode
321 set nrformats-=octal " don't inc/dec octal numbers with ^[AX]
322 set nrformats+=unsigned " treat all numbers as unsigned
324 set complete=. " scan the current buffer ( 'wrapscan' is ignored)
325 set complete+=w " scan buffers from other windows
326 set complete+=b " scan other loaded buffers that are in the buffer list
327 set complete+=u " scan the unloaded buffers that are in the buffer list
328 set complete+=t " scan tags
329 set complete+=i " scan current and included files
330 set complete+=kspell " use the currently active spell checking |spell|
332 " whether to use a popup menu for Insert mode completion
333 set completeopt=longest,menuone,preview
335 " tabs and indent {{{2
336 set shiftwidth=4 " number of spaces used for each step of (auto)indent
337 set smarttab " a <Tab> in an indent inserts 'shiftwidth' spaces
338 set softtabstop=4 " if non-zero, number of spaces to insert for a <Tab>
339 set shiftround " round to 'shiftwidth' for "<<" and ">>"
340 set expandtab " expand <Tab> to spaces in Insert mode
343 set pastetoggle=<F11> " key sequence to toggle paste mode
346 set foldmethod=marker " folding type
347 set foldlevelstart=0 " value for 'foldlevel' when starting to edit a file
349 " open folds when jumping to line
352 set viewoptions=cursor " save cursor position
353 set viewoptions+=folds " save folds
356 set diffopt+=filler " show filler lines
357 set diffopt+=vertical " always vertical split
358 set diffopt+=context:10 " 10 lines context between changes
359 set diffopt+=internal
360 set diffopt+=algorithm:patience
362 " reading and writing files {{{2
363 set modeline " read modelines
364 set modelines=2 " only check first/last 2 lines
366 set writebackup " write a backup file before overwriting a file
367 set backup " keep a backup after owerwriting a file
368 set backupdir=$XDG_CACHE_HOME/vim/backup//
370 set backupskip+=.netrc " skip netrc
371 set backupskip+=/dev/shm/pass* " skip passwordstore files
373 set undofile " persistent undo history
374 set undolevels=10000 " moar undos
376 set undodir=$XDG_CACHE_HOME/vim/undo//
381 au BufWritePre .netrc setlocal noundofile
382 au BufWritePre /dev/shm/pass* setlocal noundofile
383 au BufWritePre /tmp/* setlocal noundofile
386 set autowrite " automatically write a file when leaving a modified buffer
387 set autoread " automatically read a file that has been modified
391 set directory=$XDG_CACHE_HOME/vim/swap//
393 " command line editing {{{2
394 set history=5000 " how many command lines are remembered
395 set wildmenu " command-line completion shows a list of matches
396 set wildmode=longest:full,full " specifies how command line completion works
397 set wildignorecase " ignore case when completing file names
399 set wildignore+=.hg,.git,.svn " Version control
400 set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
401 set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
402 set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
403 set wildignore+=*.spl " compiled spelling word lists
404 set wildignore+=*.sw? " Vim swap files
405 set wildignore+=*.luac " Lua byte code
406 set wildignore+=*.pyc " Python byte code
407 set wildignore+=*.orig " Merge resolution files
409 " running make and jumping to errors {{{2
410 set makeprg=make\ -w " print changing directories
412 set grepformat=%f:%l:%c:%m
413 set grepprg=ag\ --vimgrep\ $*
415 " language specific {{{2
416 set isfname-== " don't treat `=` as being part of filenames
419 set virtualedit+=block " let cursor move past last char in <C-V> mode
420 set virtualedit+=onemore " allow the cursor to move just past the end of the line
422 " viminfo defaults but save file in .cache
423 set viminfo='100,<50,s10,h,n$XDG_CACHE_HOME/vim/viminfo
425 " shada is the replacement format for viminfo
426 " this setting is probably not needed as it's most likely the default
427 " the default path is in XDG_DATA_HOME, which is fine
428 set shada='100,<50,s10,h
431 set viewdir=$XDG_CACHE_HOME/vim/view//
433 set sessionoptions+=unix,slash " damn windows and it's silly ways
436 " Resize splits when the window is resized {{{2
437 augroup resize_splits
439 autocmd VimResized * :tabdo wincmd =
442 " Only show cursorline in the current window and in normal mode {{{2
445 au WinLeave,InsertEnter * set nocursorline
446 au WinEnter,InsertLeave * set cursorline
449 " Treat buffers from stdin (e.g.: echo foo | vim -) as scratch {{{2
452 au StdinReadPost * :set buftype=nofile
455 " Jump to last known cursor position {{{2
458 " blacklist certain filetype
459 let blacklist = ['gitcommit']
460 autocmd BufReadPost *
461 \ if index(blacklist, &ft) < 0 && line("'\"") > 1 && line("'\"") <= line("$") |
462 \ exe "normal! g`\"" |
466 " Check for file modifications automatically {{{2
467 " (current buffer only)
468 " Use :NoAutoChecktime to disable it (uses b:autochecktime)
469 fun! MyAutoCheckTime()
470 " only check timestamp for normal files
471 if &buftype != '' | return | endif
472 if ! exists('b:autochecktime') || b:autochecktime
474 let b:autochecktime = 1
477 augroup MyAutoChecktime
479 au FocusGained,BufEnter,CursorHold,InsertEnter * call MyAutoCheckTime()
481 command! NoAutoChecktime let b:autochecktime=0
482 command! ToggleAutoChecktime let b:autochecktime=!get(b:, 'autochecktime', 0) | echom "b:autochecktime:" b:autochecktime
487 function! MakeWithOpt()
488 " TODO only do this if makeprg matches make
489 " if &makeprg =~ "make"
491 if exists("b:make_dir")
492 let l:make_dir = "-C ".b:make_dir
493 elseif exists("t:make_dir")
494 let l:make_dir = "-C ".t:make_dir
495 elseif exists("g:make_dir")
496 let l:make_dir = "-C ".g:make_dir
499 let l:make_targets = ""
500 if exists("g:make_targets")
501 let l:make_targets = g:make_targets
503 execute "Make ".l:make_dir." ".l:make_targets
505 nnoremap <silent> <leader>r :call MakeWithOpt()<cr>
508 nnoremap <silent> <Leader>/ :silent nohl<CR>
511 nnoremap <leader>[ :tabprev<cr>
512 nnoremap <leader>] :tabnext<cr>
514 " paste from selection
515 nnoremap <leader>p* :silent! set paste<CR>"*p:set nopaste<CR>
516 " paste from clipboard
517 nnoremap <leader>p+ :silent! set paste<CR>"+p:set nopaste<CR>
519 " strip trailing whitespace
520 function! StripWhitespace(line1, line2, ...) " {{{2
521 let s_report = &report
523 let pattern = a:0 ? a:1 : '\s\+$'
524 let oldview = winsaveview()
525 exe 'keepjumps keeppatterns '.a:line1.','.a:line2.'substitute/'.pattern.'//e'
526 if oldview != winsaveview()
529 call winrestview(oldview)
530 let &report = s_report
532 command! -range=% -nargs=0 -bar Untrail keepjumps call StripWhitespace(<line1>,<line2>)
533 nnoremap <silent> <leader>ww :Untrail<CR>
536 vnoremap <leader>S y:execute @@<cr>:echo 'Sourced selection.'<cr>
537 nnoremap <leader>S ^vg_y:execute @@<cr>:echo 'Sourced line.'<cr>
539 " jump to last cursor position
542 " Select (charwise) the contents of the current line, excluding indentation.
547 \ :syntax sync fromstart<cr>
548 \ :AirlineRefresh<cr>
549 \ :call popup_clear(1)<cr>
553 " nnoremap <leader>r :silent !ranger %:h<cr>:redraw!<cr>
554 " nnoremap <leader>R :silent !ranger<cr>:redraw!<cr>
561 " display the number of matches for the last search
562 nmap <Leader># :%s:<C-R>/::gn<CR>
564 " center cursor after search and open folds
568 " same when jumping around
571 nnoremap <c-o> <c-o>zzzv
572 nnoremap <c-i> <c-i>zzzv
574 " Not using the default mappings of 'To line from top/bottom'
580 " Heresy, emacs insert bindings
581 inoremap <C-A> <Esc>I
582 inoremap <C-E> <Esc>A
583 cnoremap <C-A> <Home>
586 " proper movement when lines are wrapped
587 noremap <silent><expr> j (v:count == 0 ? 'gj' : 'j')
588 noremap <silent><expr> k (v:count == 0 ? 'gk' : 'k')
594 noremap <Right> <NOP>
596 inoremap <Down> <NOP>
597 inoremap <Left> <NOP>
598 inoremap <Right> <NOP>
600 cnoremap <Down> <NOP>
601 cnoremap <Left> <NOP>
602 cnoremap <Right> <NOP>
604 cnoremap <C-J> <Down>
605 cnoremap <C-H> <Left>
606 cnoremap <C-L> <Right>
608 " close all folds open fold in cursor
611 map <F1> :ls<CR>:b<space>
613 " move between windows (skip previewwindow)
614 nnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
615 nnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
616 tnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
617 tnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
619 "xterm mouse with middleclick paste
620 nnoremap <MiddleMouse> i<MiddleMouse>
621 vnoremap <MiddleMouse> s<MiddleMouse>
623 " fix legacy vi inconsistency
628 " allow repeat operator on visual
629 vnoremap . :normal .<CR>
631 " add line without changing position or leaving mode
632 noremap <silent> <Leader>o :set paste<CR>m`o<ESC>``:set nopaste<CR>
633 noremap <silent> <Leader>O :set paste<CR>m`O<ESC>``:set nopaste<CR>
635 " Don't use Ex mode, use Q for formatting
638 " break undo sequence before removing word
639 inoremap <C-W> <C-G>u<C-W>
641 nnoremap coe :set <C-R>=&expandtab ? 'noexpandtab' : 'expandtab'<CR><CR>
642 nnoremap [oe :set expandtab<CR>
643 nnoremap ]oe :set noexpandtab<CR>
645 for idt in range(1,8)
646 exe 'nnoremap co'.idt.' :setlocal tabstop='.idt.' shiftwidth='.idt.' softtabstop='.idt.'<CR>'
649 " toggle auto format of text
650 nnoremap coa :set <C-R>=&formatoptions =~ "a" ? 'formatoptions-=a' : 'formatoptions+=a'<CR><CR>
651 nnoremap [oa :set formatoptions+=a<CR>
652 nnoremap ]oa :set formatoptions-=a<CR>
654 " space will toggle current fold in normal mode
655 nnoremap <leader><Space> za
656 " create folds around visual selection
657 vnoremap <leader><Space> zf
660 cabbrev w!! SudoWrite
662 " uppercase previous word
663 inoremap <C-C> <Esc>gUiwgi
665 " http://git.io/v3ZeU
666 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>
668 " plugins options {{{1
670 let g:checkattach_filebrowser = 'ranger'
671 let g:checkattach_once = 'y'
673 " close-another-window {{{2
674 nnoremap <silent> <C-W>c <NOP>
675 nnoremap <silent> <C-W>cc <C-W>c
676 nnoremap <silent> <C-W>ch :CloseLeftWindow<CR>
677 nnoremap <silent> <C-W>cl :CloseRightWindow<CR>
678 nnoremap <silent> <C-W>cj :CloseBelowWindow<CR>
679 nnoremap <silent> <C-W>ck :CloseAboveWindow<CR>
682 let delimitMate_expand_cr = 2
683 let g:delimitMate_expand_space = 1
686 nnoremap <silent> <Leader>ff :FSHere<CR>
687 nnoremap <silent> <Leader>fl :FSRight<CR>
688 nnoremap <silent> <Leader>fh :FSLeft<CR>
689 nnoremap <silent> <Leader>fj :FSBelow<CR>
690 nnoremap <silent> <Leader>fk :FSAbove<CR>
691 nnoremap <silent> <Leader>fL :FSSplitRight<CR>
692 nnoremap <silent> <Leader>fH :FSSplitLeft<CR>
693 nnoremap <silent> <Leader>fJ :FSSplitBelow<CR>
694 nnoremap <silent> <Leader>fK :FSSplitAbove<CR>
697 nmap <silent> <leader>dd :tab split \| Gdiff \| wincmd h<CR>
698 " delete fugitive buffers when closed
699 autocmd BufReadPost fugitive://* set bufhidden=delete
701 function! GitToggle()
702 let l:status_buffer = bufname('^fugitive:///*/.git{/worktrees/*,}//$')
703 if buflisted(l:status_buffer)
704 execute 'bdelete '.l:status_buffer
710 command! GitToggle :call GitToggle()
711 command! GToggle GitToggle
712 nnoremap <silent> <leader>gs :GitToggle<CR>
714 nnoremap <silent> <leader>gd :Gdiffsplit<CR>
715 nnoremap <silent> <leader>gc :echohl WarningMsg \| echo "use \<leader>gcc instead" \| echohl None<CR>
716 nnoremap <silent> <leader>gcc :tab G commit -v<CR>
717 nnoremap <silent> <leader>gca :tab G commit -v --amend<CR>
718 nnoremap <leader>gcf :tab G commit -v --fixup=
719 nnoremap <silent> <leader>gp :echohl WarningMsg \| echo "use \<leader>gpp instead" \| echohl None<CR>
720 nnoremap <silent> <leader>gpp :Git push \| copen<CR>
721 nnoremap <silent> <leader>gpf :Git push --force-with-lease \| copen<CR>
722 nnoremap <silent> <leader>gll :Git pull<CR>
723 nnoremap <silent> <leader>gru :Git rebase --interactive @{upstream}<CR>
724 nnoremap <silent> <leader>grp :Git rebase --interactive @{push}<CR>
725 nnoremap <silent> <leader>ga :Gwrite<cr>
726 nnoremap <silent> <leader>gb :G blame<cr>
728 augroup fugitive_gstatus
730 autocmd User FugitiveIndex setlocal winfixheight
731 autocmd User FugitiveIndex nmap <buffer> <leader><space> =
735 nnoremap <F7> :GundoToggle<CR>
736 let g:gundo_prefer_python3 = 1
739 let g:indent_guides_default_mapping = 0
740 let g:indent_guides_guide_size = 1
741 nmap <silent> cog <Plug>IndentGuidesToggle
742 nmap <silent> [og <Plug>IndentGuidesEnable
743 nmap <silent> ]og <Plug>IndentGuidesDisable
747 let g:pymode_rope_completion = 0
748 let g:pymode_rope = 0
750 let g:pymode_folding = 1
751 let g:pymode_lint_ignore = "E221,E266,E501"
752 let g:pymode_lint_cwindow = 0 " don't open cwindow when linting
753 let g:pymode_syntax_space_errors = 0 " don't bother me when I'm typing
756 " disable '[ mappings
758 let g:SignatureMap = {
759 \ 'GotoNextLineAlpha' : "",
760 \ 'GotoPrevLineAlpha' : "",
761 \ 'GotoNextSpotAlpha' : "",
762 \ 'GotoPrevSpotAlpha' : "",
766 let g:switch_mapping = "<Leader>s"
767 let g:switch_custom_definitions = [
772 nmap <silent> z] <Plug>(SpellRotateForward)
773 nmap <silent> z[ <Plug>(SpellRotateBackward)
774 vmap <silent> z] <Plug>(SpellRotateForwardV)
775 vmap <silent> z[ <Plug>(SpellRotateBackwardV)
778 let g:syntastic_enable_highlighting = 0
779 let g:syntastic_error_symbol='E'
780 let g:syntastic_style_error_symbol='S'
781 let g:syntastic_warning_symbol='W'
782 let g:syntastic_style_warning_symbol='S'
783 let g:syntastic_always_populate_loc_list=1
784 nmap <silent> <leader>y :SyntasticCheck<cr>
786 let g:syntastic_cpp_clang_tidy_post_args = "-p build*"
789 let g:syntastic_check_on_open=1
793 map <F5> :TagbarToggle<cr>
794 let g:tagbar_sort = 0
795 let g:tagbar_compact = 1
796 let g:tagbar_autoshowtag = 1
797 let g:tagbar_width = 25
798 let g:tagbar_iconchars = ['+', '-']
801 let g:tcomment_textobject_inlinecomment = 'gic'
802 let g:tcomment#filetype#guess = 0
803 "let g:tcomment#options = {'whitespace' : 'no'}
806 call unite#filters#matcher_default#use(['matcher_fuzzy'])
807 call unite#custom#profile('default', 'context', {
809 \ 'direction': 'botright'
812 nnoremap [unite] <Nop>
813 nmap <leader>u [unite]
814 nnoremap [unite]u :UniteResume<CR>
815 nnoremap <silent> [u :UnitePrevious<CR>
816 nnoremap <silent> ]u :UniteNext<CR>
819 " seems not respected
820 let g:unite_source_grep_max_candidates = 2000
822 " Use ag in unite grep source.
823 let g:unite_source_grep_command = 'ag'
824 let g:unite_source_grep_default_opts = '--smart-case --vimgrep --ignore ''.hg'' --ignore ''.svn'' --ignore ''.git'' --ignore ''.bzr'''
825 let g:unite_source_grep_recursive_opt = ''
827 nnoremap <silent> [unite]a :<C-u>Unite grep:.::
\12\17<CR>
828 nnoremap <silent> [unite]A :<C-u>Unite grep:.:-w:
\12\17<CR>
829 command! -nargs=+ Ag Unite grep:.::<args>
831 " unite-file_rec {{{3
833 " Use ag in unite rec source
834 let g:unite_source_rec_async_command = ['ag', '--follow', '--nocolor', '--nogroup', '-g', '']
836 nnoremap <silent> [unite]f :<C-u>Unite -start-insert file_rec/async<CR>
837 call unite#custom#source('file_rec/async', 'sorters', 'sorter_selecta')
840 call unite#custom#default_action('buffer', 'open')
841 nnoremap <silent> [unite]b :<C-u>Unite buffer:-<CR>
843 " unite-jumplist {{{3
844 nnoremap <silent> [unite]j :<C-u>Unite output:jumps:<CR>
847 let g:unite_source_menu_menus = {}
848 let g:unite_source_menu_menus.fugitive = { 'description' : 'fugitive menu'}
849 let g:unite_source_menu_menus.fugitive.command_candidates = {
850 \ 'Gstatus <Leader>gs' : 'Gstatus',
851 \ 'Gcommit -v <Leader>gc' : 'Gcommit -v',
855 nnoremap <silent> <leader>gg :<C-u>Unite menu:fugitive<CR>
857 let g:unite_source_history_yank_enable = 1
858 nnoremap <silent> [unite]p :<C-u>Unite history/yank<CR>
861 nnoremap <silent> <leader>p :YRShow<cr>
862 let g:yankring_history_dir = expand('$XDG_CACHE_HOME/vim')
863 let g:yankring_replace_n_pkey = ''
864 let g:yankring_replace_n_nkey = ''
866 " map Y to y$ for the yank ring
867 function! YRRunAfterMaps()
868 nnoremap Y :<C-U>YRYankCount 'y$'<CR>
871 " vim-easy-align {{{2
872 " start interactive EasyAlign in visual mode
873 vmap <Enter> <Esc>:echohl WarningMsg \| echo "EasyAlign mapped to
\16<leader>a now" \| echohl None<CR>
874 vmap <leader>a <Plug>(EasyAlign)
875 nmap <leader>a <Plug>(EasyAlign)
878 let g:gtest#highlight_failing_tests = 0
880 nnoremap <silent> <Leader>tt :GTestRun<CR>
881 nnoremap <Leader>tc :GTestCase<space>
882 nnoremap <Leader>tn :GTestName<space>
883 nnoremap <silent> <Leader>ta :GTestCase *<CR>:GTestName *<CR>:GTestRun<CR>
884 nnoremap <silent> <Leader>tu :GTestRunUnderCursor<CR>
887 let g:vim_json_syntax_conceal = 0
890 let g:sneak#streak = 1
891 let g:sneak#target_labels = "aoeuisnthdpylrcgfqjkxzmwvz" " dvorak
892 let g:sneak#use_ic_scs = 1 " follow 'ignorecase' and 'smartcase'
910 " Convenient command to see the difference between the current buffer and the
911 " file it was loaded from, thus the changes you made.
912 " Only define it when not defined already.
913 if !exists(":DiffOrig")
914 command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
915 \ | wincmd p | diffthis
919 function! SortLinesOpFunc(...)
922 nnoremap <silent> gs :<C-U>set operatorfunc=SortLinesOpFunc<CR>g@
923 vnoremap <silent> gs :sort<cr>
926 function! EditConfig(what, ext = '.vim')
927 let l:dir = split(&runtimepath,',')[0]
929 let l:file = expand($MYVIMRC)
930 elseif ! isdirectory(globpath(l:dir, a:what))
931 echoe a:what." is not valid!"
932 elseif empty(&filetype)
933 echoe 'filetype is empty!'
935 let l:file = l:dir.'/'.a:what.'/'.&filetype.a:ext
938 execute ':vsplit '.file
941 nmap <leader>ev :call EditConfig('vimrc')<CR>
942 nmap <leader>ef :call EditConfig('ftplugin')<CR>
943 nmap <leader>es :call EditConfig('syntax')<CR>
944 nmap <leader>ei :call EditConfig('indent')<CR>
945 nmap <leader>eu :call EditConfig('ultisnips', '.snippets')<CR>
948 " http://tex.stackexchange.com/a/52932
949 let g:myLangList=["en_gb","en_us","de","fr"]
951 function! ToggleSpell()
952 if !exists("b:myLang")
955 execute "setlocal spell!"
957 echo "setlocal spelllang=" g:myLangList[b:myLang]
961 function! SwitchSpell()
962 if !exists("b:myLang")
966 let b:myLang=b:myLang+1
967 if b:myLang>=len(g:myLangList) | let b:myLang=0 | endif
969 execute "setlocal spell spelllang=".get(g:myLangList, b:myLang)
970 echo "setlocal spelllang=" g:myLangList[b:myLang]
973 nnoremap <silent> coS :call SwitchSpell()<CR>
974 " fix spelling with first choice
975 nnoremap <Leader>f 1z=
977 " gitdir or home {{{2
979 " http://git.io/v3GAV
980 function! FindGitDirOrHome()
981 let filedir = expand('%:p:h')
982 if isdirectory(filedir)
983 let cmd = 'bash -c "(cd ' . filedir . '; git rev-parse --show-toplevel 2>/dev/null)"'
984 let gitdir = system(cmd)
985 if strlen(gitdir) == 0
995 command! Cdr execute('cd ' . FindGitDirOrHome())
997 command! LCdr execute('lcd ' . FindGitDirOrHome())
999 " vim:set et sw=2 ts=2 tw=78: