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'
17 Plug 'bling/vim-airline' " {{{2
18 let g:airline#extensions#whitespace#enabled = 1
19 let g:airline#extensions#tabline#enabled = 1
20 let g:airline#extensions#searchcount#enabled = 0
21 let g:airline_powerline_fonts = 1
23 let g:asyncrun_status = "stopped"
24 " let g:airline_section_error = airline#section#create_right(['%{g:asyncrun_status}'])
26 Plug 'raimondi/delimitmate' " {{{2
27 let delimitMate_expand_cr = 2
28 let g:delimitMate_expand_space = 1
30 Plug 'tpope/vim-surround' "{{{2
32 " Plug 'valloric/youcompleteme' {{{2
33 Plug 'valloric/youcompleteme',
34 \{ 'do': './install.py --clangd-completer --clang-completer' }
35 let g:ycm_clangd_binary_path = 'clangd' " use clangd in path
36 let g:ycm_clangd_args = ['--clang-tidy']
37 let g:ycm_extra_conf_vim_data = ['getcwd()']
38 let g:ycm_add_preview_to_completeopt = 1
39 let g:ycm_complete_in_comments = 1
40 let g:ycm_complete_in_strings = 1
41 let g:ycm_autoclose_preview_window_after_insertion = 0
43 let g:ycm_language_server =
47 \ 'cmdline': [ 'haskell-language-server-wrapper', '--lsp' ],
48 \ 'filetypes': [ 'haskell', 'lhaskell' ]
52 Plug 'svermeulen/vim-yoink' " {{{2
54 Plug 'arcticicestudio/nord-vim' " {{{2
57 let g:nord_italic_comments = 1
58 let g:nord_underline = 1
59 let g:nord_uniform_status_lines = 0
60 let g:nord_uniform_diff_background = 0
61 let g:nord_cursor_line_number_background = 0
62 let g:nord_bold_vertical_split_line = 0
64 Plug 'sirver/ultisnips' " replaced by lua-snip {{{2
65 Plug 'honza/vim-snippets'
66 let g:UltiSnipsEditSplit = 'vertical'
67 let g:UltiSnipsSnippetDirectories = [ expand("$XDG_CONFIG_HOME/vim/ultisnips") ]
69 let g:UltiSnipsSnippetDirectories = ["UltiSnips", "ultisnips"]
71 let g:UltiSnipsExpandTrigger = "<tab>"
72 let g:UltiSnipsJumpForwardTrigger = "<tab>"
73 let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
75 " UltiSnips completion function that tries to expand a snippet. If there's no
76 " snippet for expanding, it checks for completion window and if it's shown,
77 " selects first element. If there's no completion window it tries to jump to
78 " next placeholder. If there's no placeholder it just returns TAB key
79 " https://github.com/Valloric/YouCompleteMe/issues/36#issuecomment-15451411
80 function! g:UltiSnips_Complete()
81 call UltiSnips#ExpandSnippet()
82 if g:ulti_expand_res == 0
86 call UltiSnips#JumpForwards()
87 if g:ulti_jump_forwards_res == 0
94 au InsertEnter * exec "inoremap <silent> " . g:UltiSnipsExpandTrigger . " <C-R>=g:UltiSnips_Complete()<cr>"
95 let g:UltiSnipsListSnippets="<c-e>"
97 Plug 'vim-utils/vim-man' " replaced by builtin {{{2
100 Plug 'airblade/vim-gitgutter' " replaced by gitsigns {{{
101 " prefer other signs such as ycm diags
102 let g:gitgutter_sign_priority = 1
103 " don't clobber other signs
104 let g:gitgutter_sign_allow_clobber = 0
106 Plug 'justinmk/vim-sneak' " replaced by leap {{{2
107 let g:sneak#streak = 1
108 let g:sneak#target_labels = "aoeuisnthdpylrcgfqjkxzmwvz" " dvorak
109 let g:sneak#use_ic_scs = 1 " follow 'ignorecase' and 'smartcase'
125 Plug 'shougo/unite.vim' " replaced by telescope {{{2
126 function! UniteSetup()
127 call unite#filters#matcher_default#use(['matcher_fuzzy'])
128 call unite#custom#profile('default', 'context', {
130 \ 'direction': 'botright'
133 nnoremap [unite] <Nop>
134 nmap <leader>u [unite]
135 nnoremap [unite]u :UniteResume<CR>
136 nnoremap <silent> [u :UnitePrevious<CR>
137 nnoremap <silent> ]u :UniteNext<CR>
140 " seems not respected
141 let g:unite_source_grep_max_candidates = 2000
143 " Use ag in unite grep source.
144 let g:unite_source_grep_command = 'ag'
145 let g:unite_source_grep_default_opts = '--smart-case --vimgrep --ignore ''.hg'' --ignore ''.svn'' --ignore ''.git'' --ignore ''.bzr'''
146 let g:unite_source_grep_recursive_opt = ''
148 nnoremap <silent> [unite]a :<C-u>Unite grep:.::
\12\17<CR>
149 nnoremap <silent> [unite]A :<C-u>Unite grep:.:-w:
\12\17<CR>
150 command! -nargs=+ Ag Unite grep:.::<args>
152 " unite-file_rec {{{3
154 " Use ag in unite rec source
155 let g:unite_source_rec_async_command = ['ag', '--follow', '--nocolor', '--nogroup', '-g', '']
157 nnoremap <silent> [unite]f :<C-u>Unite -start-insert file_rec/async<CR>
160 call unite#custom#default_action('buffer', 'open')
161 nnoremap <silent> [unite]b :<C-u>Unite buffer:-<CR>
163 " unite-jumplist {{{3
164 nnoremap <silent> [unite]j :<C-u>Unite output:jumps:<CR>
167 let g:unite_source_menu_menus = {}
168 let g:unite_source_menu_menus.fugitive = { 'description' : 'fugitive menu'}
169 let g:unite_source_menu_menus.fugitive.command_candidates = {
170 \ 'Gstatus <Leader>gs' : 'Gstatus',
171 \ 'Gcommit -v <Leader>gc' : 'Gcommit -v',
175 nnoremap <silent> <leader>gg :<C-u>Unite menu:fugitive<CR>
177 let g:unite_source_history_yank_enable = 1
178 nnoremap <silent> [unite]p :<C-u>Unite history/yank<CR>
181 autocmd VimEnter * ++once call UniteSetup()
184 Plug 'shougo/vimproc.vim', {'do': 'make'} " {{{2
186 Plug 'tomtom/tcomment_vim' " replaced by comment.nvim {{{2
187 let g:tcomment_textobject_inlinecomment = 'gic'
188 let g:tcomment#filetype#guess = 0
189 "let g:tcomment#options = {'whitespace' : 'no'}
192 Plug 'morhetz/gruvbox' " {{{2
193 let g:gruvbox_contrast_dark = 'hard'
194 let g:gruvbox_contrast_light = 'soft'
197 Plug 'puremourning/vimspector' " replaced by lsp {{{2
198 let g:vimspector_enable_mappings = 'HUMAN'
200 Plug 'vim-scripts/syntaxrange' " replaced by treesitter {{{2
204 Plug 'alepez/vim-gtest'
206 Plug 'andrewradev/sideways.vim' " {{{2
207 nnoremap <silent> ,h :SidewaysLeft<CR>:delmarks z<CR>
208 nnoremap <silent> ,l :SidewaysRight<CR>:delmarks z<CR>
210 Plug 'andrewradev/switch.vim'
211 Plug 'chrisbra/checkattach'
212 Plug 'derekwyatt/vim-fswitch'
214 Plug 'firef0x/pkgbuild.vim'
215 Plug 'junegunn/vim-easy-align'
216 Plug 'klen/python-mode'
217 Plug 'kshenoy/vim-signature'
218 Plug 'majutsushi/tagbar'
219 Plug 'octol/vim-cpp-enhanced-highlight'
220 Plug 'sgeb/vim-diff-fold'
221 Plug 'skywind3000/asyncrun.vim' " {{{2
222 command! -bang -nargs=* -complete=file Make AsyncRun -save=2 -program=make @ <args>
223 let g:asyncrun_open = 10
226 Plug 'thinca/vim-qfreplace'
227 Plug 'tpope/vim-abolish'
228 Plug 'tpope/vim-characterize'
229 Plug 'tpope/vim-endwise'
230 Plug 'tpope/vim-eunuch'
231 Plug 'tpope/vim-fugitive'
232 Plug 'tpope/vim-repeat'
233 Plug 'tpope/vim-scriptease'
234 Plug 'tpope/vim-speeddating'
235 Plug 'tpope/vim-unimpaired'
236 Plug 'tweekmonster/spellrotate.vim'
237 Plug 'vim-scripts/mediawiki.vim'
238 Plug 'vim-scripts/replacewithregister'
242 Plug 'kana/vim-textobj-user'
243 Plug 'julian/vim-textobj-variable-segment'
244 Plug 'sgur/vim-textobj-parameter'
245 Plug 'kana/vim-operator-user'
248 " Check LucHermites plugins: https://github.com/LucHermitte/lh-cpp
249 Plug 'imsnif/kdl.vim'
251 Plug 'ilyachur/cmake4vim'
252 Plug 'ilyachur/gtest-vim'
254 Plug 'junegunn/vim-peekaboo' "{{{2
255 " issue with having it at the bottom is that it doesn't leave much
256 let g:peekaboo_window = 'bo 16new'
257 let g:peekaboo_compact = 1
258 let g:peekaboo_delay = 500
261 Plug 'vim-scripts/ansiesc.vim' "{{{2
262 nmap corwp <Plug>RestoreWinPosn
263 nmap coswp <Plug>SaveWinPosn
266 Plug 'neovimhaskell/haskell-vim' " {{{2
267 let g:haskell_enable_quantification = 1 " to enable highlighting of `forall`
268 let g:haskell_enable_recursivedo = 1 " to enable highlighting of `mdo` and `rec`
269 let g:haskell_enable_arrowsyntax = 1 " to enable highlighting of `proc`
270 let g:haskell_enable_pattern_synonyms = 1 " to enable highlighting of `pattern`
271 let g:haskell_enable_typeroles = 1 " to enable highlighting of type roles
272 let g:haskell_enable_static_pointers = 1 " to enable highlighting of `static`
273 let g:haskell_backpack = 1 " to enable highlighting of backpack keywords
275 let g:haskell_indent_before_where = 2
278 Plug 'aklt/plantuml-syntax'
280 Plug 'mtth/scratch.vim' " {{{2
281 let g:scratch_no_mappings = 1
282 let g:scratch_autohide = 0
285 Plug 'jenterkin/vim-autosource' " {{{2
286 let g:autosource_hashdir = $XDG_CACHE_HOME . '/vim/vim-autosource'
287 let g:autosource_conf_names = ['.vimrc', '.vimrc.lua']
292 filetype plugin indent on
297 let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
298 let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
303 "TODO see how I can integrate this into a theme that customises upstream Nord
304 hi debugPC term=reverse ctermbg=8
307 " moving around, searching and patterns {{{2
308 set incsearch " show match for partly typed search command
309 set ignorecase " ignore case when using a search pattern
310 set smartcase " override 'ignorecase' when pattern has upper case characters
311 set hlsearch " highlight all matches for the last used search pattern
313 set nostartofline " don't move the cursor to the first non-blank char of a line
316 set path+=../include/
317 set path+=/usr/include/c++/*
319 " displaying text {{{2
320 set nowrap " long lines wrap
321 set linebreak " wrap long lines at a character in 'breakat'
322 set showbreak=↪ " show these chars for wrapped lines
323 set breakindent " preserve indentation in wrapped text
325 set list " show chars defined in 'listchars'
326 set listchars=tab:❭\ " list of strings used for list mode
327 set listchars+=extends:❯,precedes:❮
328 set listchars+=nbsp:␣
329 " Only shown when not in insert mode
330 set listchars+=trail:·
333 au FileType qf setlocal listchars-=trail:·
334 au InsertEnter * set listchars-=trail:·
335 au InsertLeave * set listchars+=trail:·
338 set scrolloff=5 " number of screen lines to show around the cursor
339 set sidescroll=1 " number of collumns to scroll
340 set sidescrolloff=1 " don't scroll over the listchars
341 set display+=lastline " display as much as possible of last line
343 set fillchars=diff:⣿,vert:│
345 set nonumber " show the line number for each line
346 set norelativenumber " show the relative line number for each line
348 " syntax, highlighting and spelling {{{2
349 set synmaxcol=800 " don't highlight long lines
351 set dictionary=spell " list of dictionary files for keyword completion
355 " multiple windows {{{2
356 set laststatus=2 " 0, 1 or 2; when to use a status line for the last window
358 set previewheight=20 " default height for the preview window
362 " set splitbelow " a new window is put below of the current one
363 set splitright " a new window is put right of the current one
368 " using the mouse {{{2
369 set mouse=rnv " list of flags for using the mouse
371 set ttymouse=xterm " type of mouse
374 " messages and info {{{2
375 set showcmd " Show (partial) command in status line.
376 set ruler " show the cursor position all the time
377 set confirm " Ask what to do when closing unsaved documents
378 set shortmess+=a " all abbreviations
379 set shortmess+=o " overwrite file-written message
380 set shortmess+=O " file-read message overrides previous
381 set shortmess+=t " truncate file message at start
382 set shortmess+=T " truncate other messages in the middle
383 set shortmess+=W " don't give 'written' or '[w]' when writing a file
384 set shortmess+=A " ignore swapfile warning
385 set shortmess+=I " no splash screen
386 set shortmess+=F " don't give the file info when editing a file
387 set shortmess+=c " don't give |ins-completion-menu| messages
390 set backspace=indent,eol,start " allow backspacing over everything in insert mode
392 set showmatch " Show matching brackets.
394 set nojoinspaces " don't use two spaces after '.' when joining a line
395 set formatoptions+=j " Delete comment leader when joining lines
396 set formatoptions+=c " Autowrap comments using textwidth
397 set formatoptions+=r " Insert comment leader after hitting <Enter>
398 set formatoptions+=n " Recognize numbered lists
399 set formatoptions+=q " Allow formatting of comments with "gq".
400 set formatoptions+=l " do not wrap lines that have been longer when starting insert mode already
401 set formatoptions+=t " Auto-wrap text using textwidth
402 set formatoptions-=o " Do not insert comment leader after hitting o or O in normal mode
404 set nrformats-=octal " don't inc/dec octal numbers with ^[AX]
405 set nrformats+=unsigned " treat all numbers as unsigned
407 set complete=. " scan the current buffer ( 'wrapscan' is ignored)
408 set complete+=w " scan buffers from other windows
409 set complete+=b " scan other loaded buffers that are in the buffer list
410 set complete+=u " scan the unloaded buffers that are in the buffer list
411 set complete+=t " scan tags
412 set complete+=i " scan current and included files
413 set complete+=kspell " use the currently active spell checking |spell|
415 " whether to use a popup menu for Insert mode completion
416 set completeopt=longest,menuone,preview
418 " tabs and indent {{{2
419 set shiftwidth=4 " number of spaces used for each step of (auto)indent
420 set smarttab " a <Tab> in an indent inserts 'shiftwidth' spaces
421 set softtabstop=4 " if non-zero, number of spaces to insert for a <Tab>
422 set shiftround " round to 'shiftwidth' for "<<" and ">>"
423 set expandtab " expand <Tab> to spaces in Insert mode
426 set pastetoggle=<F11> " key sequence to toggle paste mode
429 set foldmethod=marker " folding type
430 set foldlevelstart=0 " value for 'foldlevel' when starting to edit a file
432 " open folds when jumping to line
435 set viewoptions=cursor " save cursor position
436 set viewoptions+=folds " save folds
439 set diffopt+=filler " show filler lines
440 set diffopt+=vertical " always vertical split
441 set diffopt+=context:10 " 10 lines context between changes
442 set diffopt+=internal
443 set diffopt+=algorithm:patience
445 " reading and writing files {{{2
446 set modeline " read modelines
447 set modelines=2 " only check first/last 2 lines
449 set writebackup " write a backup file before overwriting a file
450 set backup " keep a backup after owerwriting a file
451 set backupdir=$XDG_CACHE_HOME/vim/backup//
453 set backupskip+=.netrc " skip netrc
454 set backupskip+=/dev/shm/pass* " skip passwordstore files
456 set undofile " persistent undo history
457 set undolevels=10000 " moar undos
459 set undodir=$XDG_CACHE_HOME/vim/undo//
464 au BufWritePre .netrc setlocal noundofile
465 au BufWritePre /dev/shm/pass* setlocal noundofile
466 au BufWritePre /tmp/* setlocal noundofile
469 set autowrite " automatically write a file when leaving a modified buffer
470 set autoread " automatically read a file that has been modified
474 set directory=$XDG_CACHE_HOME/vim/swap//
476 " command line editing {{{2
477 set history=5000 " how many command lines are remembered
478 set wildmenu " command-line completion shows a list of matches
479 set wildmode=longest:full,full " specifies how command line completion works
480 set wildignorecase " ignore case when completing file names
482 set wildignore+=.hg,.git,.svn " Version control
483 set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
484 set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
485 set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
486 set wildignore+=*.spl " compiled spelling word lists
487 set wildignore+=*.sw? " Vim swap files
488 set wildignore+=*.luac " Lua byte code
489 set wildignore+=*.pyc " Python byte code
490 set wildignore+=*.orig " Merge resolution files
492 " running make and jumping to errors {{{2
493 set makeprg=make\ -w " print changing directories
495 set grepformat=%f:%l:%c:%m
496 set grepprg=ag\ --vimgrep\ $*
498 " language specific {{{2
499 set isfname-== " don't treat `=` as being part of filenames
502 set virtualedit+=block " let cursor move past last char in <C-V> mode
503 set virtualedit+=onemore " allow the cursor to move just past the end of the line
505 " viminfo defaults but save file in .cache
506 set viminfo='100,<50,s10,h,n$XDG_CACHE_HOME/vim/viminfo
508 " shada is the replacement format for viminfo
509 " this setting is probably not needed as it's most likely the default
510 " the default path is in XDG_DATA_HOME, which is fine
511 set shada='100,<50,s10,h
514 set viewdir=$XDG_CACHE_HOME/vim/view//
516 set sessionoptions+=unix,slash " damn windows and it's silly ways
519 " Resize splits when the window is resized {{{2
520 augroup resize_splits
522 autocmd VimResized * :tabdo wincmd =
525 " Only show cursorline in the current window and in normal mode {{{2
528 au WinLeave,InsertEnter * set nocursorline
529 au WinEnter,InsertLeave * set cursorline
532 " Treat buffers from stdin (e.g.: echo foo | vim -) as scratch {{{2
535 au StdinReadPost * :set buftype=nofile
538 " Jump to last known cursor position {{{2
541 " blacklist certain filetype
542 let blacklist = ['gitcommit']
543 autocmd BufReadPost *
544 \ if index(blacklist, &ft) < 0 && line("'\"") > 1 && line("'\"") <= line("$") |
545 \ exe "normal! g`\"" |
549 " Check for file modifications automatically {{{2
550 " (current buffer only)
551 " Use :NoAutoChecktime to disable it (uses b:autochecktime)
552 fun! MyAutoCheckTime()
553 " only check timestamp for normal files
554 if &buftype != '' | return | endif
555 if ! exists('b:autochecktime') || b:autochecktime
557 let b:autochecktime = 1
560 augroup MyAutoChecktime
562 au FocusGained,BufEnter,CursorHold,InsertEnter * call MyAutoCheckTime()
564 command! NoAutoChecktime let b:autochecktime=0
565 command! ToggleAutoChecktime let b:autochecktime=!get(b:, 'autochecktime', 0) | echom "b:autochecktime:" b:autochecktime
570 function! MakeWithOpt()
571 " TODO only do this if makeprg matches make
572 " if &makeprg =~ "make"
574 if exists("b:make_dir")
575 let l:make_dir = "-C ".b:make_dir
576 elseif exists("t:make_dir")
577 let l:make_dir = "-C ".t:make_dir
578 elseif exists("g:make_dir")
579 let l:make_dir = "-C ".g:make_dir
582 let l:make_targets = ""
583 if exists("g:make_targets")
584 let l:make_targets = g:make_targets
586 execute "Make ".l:make_dir." ".l:make_targets
588 nnoremap <silent> <leader>r :call MakeWithOpt()<cr>
591 nnoremap <silent> <Leader>/ :silent nohl<CR>
594 nnoremap <leader>[ :tabprev<cr>
595 nnoremap <leader>] :tabnext<cr>
597 " paste from selection
598 nnoremap <leader>p* :silent! set paste<CR>"*p:set nopaste<CR>
599 " paste from clipboard
600 nnoremap <leader>p+ :silent! set paste<CR>"+p:set nopaste<CR>
602 " strip trailing whitespace
603 function! StripWhitespace(line1, line2, ...) " {{{2
604 let s_report = &report
606 let pattern = a:0 ? a:1 : '\s\+$'
607 let oldview = winsaveview()
608 exe 'keepjumps keeppatterns '.a:line1.','.a:line2.'substitute/'.pattern.'//e'
609 if oldview != winsaveview()
612 call winrestview(oldview)
613 let &report = s_report
615 command! -range=% -nargs=0 -bar Untrail keepjumps call StripWhitespace(<line1>,<line2>)
616 nnoremap <silent> <leader>ww :Untrail<CR>
619 vnoremap <leader>S y:execute @@<cr>:echo 'Sourced selection.'<cr>
620 nnoremap <leader>S ^vg_y:execute @@<cr>:echo 'Sourced line.'<cr>
622 " jump to last cursor position
625 " Select (charwise) the contents of the current line, excluding indentation.
630 \ :syntax sync fromstart<cr>
631 \ :AirlineRefresh<cr>
632 \ :call popup_clear(1)<cr>
636 " nnoremap <leader>r :silent !ranger %:h<cr>:redraw!<cr>
637 " nnoremap <leader>R :silent !ranger<cr>:redraw!<cr>
639 " display the number of matches for the last search
640 nmap <Leader># :%s:<C-R>/::gn<CR>
642 " center cursor after search and open folds
646 " same when jumping around
649 nnoremap <c-o> <c-o>zzzv
650 nnoremap <c-i> <c-i>zzzv
652 " Not using the default mappings of 'To line from top/bottom'
658 " Heresy, emacs insert bindings
659 inoremap <C-A> <Esc>I
660 inoremap <C-E> <Esc>A
661 cnoremap <C-A> <Home>
664 " proper movement when lines are wrapped
665 noremap <silent><expr> j (v:count == 0 ? 'gj' : 'j')
666 noremap <silent><expr> k (v:count == 0 ? 'gk' : 'k')
672 noremap <Right> <NOP>
674 inoremap <Down> <NOP>
675 inoremap <Left> <NOP>
676 inoremap <Right> <NOP>
678 cnoremap <Down> <NOP>
679 cnoremap <Left> <NOP>
680 cnoremap <Right> <NOP>
682 cnoremap <C-J> <Down>
683 cnoremap <C-H> <Left>
684 cnoremap <C-L> <Right>
686 " close all folds open fold in cursor
689 map <F1> :ls<CR>:b<space>
691 " move between windows (skip previewwindow)
692 nnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
693 nnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
694 tnoremap <silent> <C-L> <C-W>w<C-W>:if &previewwindow \| wincmd w \| endif<CR>
695 tnoremap <silent> <C-H> <C-W>W<C-W>:if &previewwindow \| wincmd W \| endif<CR>
697 "xterm mouse with middleclick paste
698 nnoremap <MiddleMouse> i<MiddleMouse>
699 vnoremap <MiddleMouse> s<MiddleMouse>
701 " fix legacy vi inconsistency
706 " allow repeat operator on visual
707 vnoremap . :normal .<CR>
709 " add line without changing position or leaving mode
710 noremap <silent> <Leader>o :set paste<CR>m`o<ESC>``:set nopaste<CR>
711 noremap <silent> <Leader>O :set paste<CR>m`O<ESC>``:set nopaste<CR>
713 " Don't use Ex mode, use Q for formatting
716 " break undo sequence before removing word
717 inoremap <C-W> <C-G>u<C-W>
719 nnoremap coe :set <C-R>=&expandtab ? 'noexpandtab' : 'expandtab'<CR><CR>
720 nnoremap [oe :set expandtab<CR>
721 nnoremap ]oe :set noexpandtab<CR>
723 for idt in range(1,8)
724 exe 'nnoremap co'.idt.' :setlocal tabstop='.idt.' shiftwidth='.idt.' softtabstop='.idt.'<CR>'
727 " toggle auto format of text
728 nnoremap coa :set <C-R>=&formatoptions =~ "a" ? 'formatoptions-=a' : 'formatoptions+=a'<CR><CR>
729 nnoremap [oa :set formatoptions+=a<CR>
730 nnoremap ]oa :set formatoptions-=a<CR>
732 " space will toggle current fold in normal mode
733 nnoremap <leader><Space> za
734 " create folds around visual selection
735 vnoremap <leader><Space> zf
738 cabbrev w!! SudoWrite
740 " uppercase previous word
741 inoremap <C-C> <Esc>gUiwgi
743 " http://git.io/v3ZeU
744 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>
746 " plugins options {{{1
748 let g:checkattach_filebrowser = 'ranger'
749 let g:checkattach_once = 'y'
751 " close-another-window {{{2
752 nnoremap <silent> <C-W>c <NOP>
753 nnoremap <silent> <C-W>cc <C-W>c
754 nnoremap <silent> <C-W>ch :CloseLeftWindow<CR>
755 nnoremap <silent> <C-W>cl :CloseRightWindow<CR>
756 nnoremap <silent> <C-W>cj :CloseBelowWindow<CR>
757 nnoremap <silent> <C-W>ck :CloseAboveWindow<CR>
761 nnoremap <silent> <Leader>ff :FSHere<CR>
762 nnoremap <silent> <Leader>fl :FSRight<CR>
763 nnoremap <silent> <Leader>fh :FSLeft<CR>
764 nnoremap <silent> <Leader>fj :FSBelow<CR>
765 nnoremap <silent> <Leader>fk :FSAbove<CR>
766 nnoremap <silent> <Leader>fL :FSSplitRight<CR>
767 nnoremap <silent> <Leader>fH :FSSplitLeft<CR>
768 nnoremap <silent> <Leader>fJ :FSSplitBelow<CR>
769 nnoremap <silent> <Leader>fK :FSSplitAbove<CR>
772 nmap <silent> <leader>dd :tab split \| Gdiff \| wincmd h<CR>
773 " delete fugitive buffers when closed
774 autocmd BufReadPost fugitive://* set bufhidden=delete
776 function! GitToggle()
777 let l:status_buffer = bufname('^fugitive:///*/.git{/worktrees/*,}//$')
778 if buflisted(l:status_buffer)
779 execute 'bdelete '.l:status_buffer
782 if !empty(FugitiveGitDir())
783 " only resize status if Git was sucessful
788 command! GitToggle :call GitToggle()
789 command! GToggle GitToggle
790 nnoremap <silent> <leader>gs :GitToggle<CR>
792 nnoremap <silent> <leader>gd :Gdiffsplit<CR>
793 nnoremap <silent> <leader>gc :echohl WarningMsg \| echo "use \<leader>gcc instead" \| echohl None<CR>
794 nnoremap <silent> <leader>gcc :tab G commit -v<CR>
795 nnoremap <silent> <leader>gca :tab G commit -v --amend<CR>
796 nnoremap <leader>gcf :tab G commit -v --fixup=
797 nnoremap <silent> <leader>gp :echohl WarningMsg \| echo "use \<leader>gpp instead" \| echohl None<CR>
798 nnoremap <silent> <leader>gpp :Git push \| copen<CR>
799 nnoremap <silent> <leader>gpf :Git push --force-with-lease \| copen<CR>
800 nnoremap <silent> <leader>gll :Git pull<CR>
801 nnoremap <silent> <leader>gru :Git rebase --interactive @{upstream}<CR>
802 nnoremap <silent> <leader>grp :Git rebase --interactive @{push}<CR>
803 nnoremap <silent> <leader>ga :Gwrite<cr>
804 nnoremap <silent> <leader>gb :G blame<cr>
806 augroup fugitive_gstatus
808 autocmd User FugitiveIndex setlocal winfixheight
809 autocmd User FugitiveIndex nmap <buffer> <leader><space> =
813 nnoremap <F7> :GundoToggle<CR>
814 let g:gundo_prefer_python3 = 1
817 let g:indent_guides_default_mapping = 0
818 let g:indent_guides_guide_size = 1
819 nmap <silent> cog <Plug>IndentGuidesToggle
820 nmap <silent> [og <Plug>IndentGuidesEnable
821 nmap <silent> ]og <Plug>IndentGuidesDisable
825 let g:pymode_rope_completion = 0
826 let g:pymode_rope = 0
828 let g:pymode_folding = 1
829 let g:pymode_lint_ignore = "E221,E266,E501"
830 let g:pymode_lint_cwindow = 0 " don't open cwindow when linting
831 let g:pymode_syntax_space_errors = 0 " don't bother me when I'm typing
834 " disable '[ mappings
836 let g:SignatureMap = {
837 \ 'GotoNextLineAlpha' : "",
838 \ 'GotoPrevLineAlpha' : "",
839 \ 'GotoNextSpotAlpha' : "",
840 \ 'GotoPrevSpotAlpha' : "",
844 let g:switch_mapping = "<Leader>s"
845 let g:switch_custom_definitions = [
850 nmap <silent> z] <Plug>(SpellRotateForward)
851 nmap <silent> z[ <Plug>(SpellRotateBackward)
852 vmap <silent> z] <Plug>(SpellRotateForwardV)
853 vmap <silent> z[ <Plug>(SpellRotateBackwardV)
856 let g:syntastic_enable_highlighting = 0
857 let g:syntastic_error_symbol='E'
858 let g:syntastic_style_error_symbol='S'
859 let g:syntastic_warning_symbol='W'
860 let g:syntastic_style_warning_symbol='S'
861 let g:syntastic_always_populate_loc_list=1
862 nmap <silent> <leader>y :SyntasticCheck<cr>
864 let g:syntastic_cpp_clang_tidy_post_args = "-p build*"
867 let g:syntastic_check_on_open=1
871 map <F5> :TagbarToggle<cr>
872 let g:tagbar_sort = 0
873 let g:tagbar_compact = 1
874 let g:tagbar_autoshowtag = 1
875 let g:tagbar_width = 25
876 let g:tagbar_iconchars = ['+', '-']
878 " vim-easy-align {{{2
879 " start interactive EasyAlign in visual mode
880 vmap <Enter> <Esc>:echohl WarningMsg \| echo "EasyAlign mapped to
\16<leader>a now" \| echohl None<CR>
881 vmap <leader>a <Plug>(EasyAlign)
882 nmap <leader>a <Plug>(EasyAlign)
885 let g:gtest#highlight_failing_tests = 0
887 nnoremap <silent> <Leader>tt :GTestRun<CR>
888 nnoremap <Leader>tc :GTestCase<space>
889 nnoremap <Leader>tn :GTestName<space>
890 nnoremap <silent> <Leader>ta :GTestCase *<CR>:GTestName *<CR>:GTestRun<CR>
891 nnoremap <silent> <Leader>tu :GTestRunUnderCursor<CR>
894 let g:vim_json_syntax_conceal = 0
898 " Convenient command to see the difference between the current buffer and the
899 " file it was loaded from, thus the changes you made.
900 " Only define it when not defined already.
901 if !exists(":DiffOrig")
902 command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
903 \ | wincmd p | diffthis
907 function! SortLinesOpFunc(...)
910 nnoremap <silent> gs :<C-U>set operatorfunc=SortLinesOpFunc<CR>g@
911 vnoremap <silent> gs :sort<cr>
914 function! EditConfig(what, ext = '.vim')
915 let l:dir = split(&runtimepath,',')[0]
917 let l:file = expand($MYVIMRC)
918 elseif ! isdirectory(globpath(l:dir, a:what))
919 echoe a:what." is not valid!"
920 elseif empty(&filetype)
921 echoe 'filetype is empty!'
923 let l:file = l:dir.'/'.a:what.'/'.&filetype.a:ext
926 execute ':vsplit '.file
929 nmap <leader>ev :call EditConfig('vimrc')<CR>
930 nmap <leader>ef :call EditConfig('ftplugin')<CR>
931 nmap <leader>es :call EditConfig('syntax')<CR>
932 nmap <leader>ei :call EditConfig('indent')<CR>
933 nmap <leader>eu :call EditConfig('ultisnips', '.snippets')<CR>
936 " http://tex.stackexchange.com/a/52932
937 let g:myLangList=["en_gb","en_us","de","fr"]
939 function! ToggleSpell()
940 if !exists("b:myLang")
943 execute "setlocal spell!"
945 echo "setlocal spelllang=" g:myLangList[b:myLang]
949 function! SwitchSpell()
950 if !exists("b:myLang")
954 let b:myLang=b:myLang+1
955 if b:myLang>=len(g:myLangList) | let b:myLang=0 | endif
957 execute "setlocal spell spelllang=".get(g:myLangList, b:myLang)
958 echo "setlocal spelllang=" g:myLangList[b:myLang]
961 nnoremap <silent> coS :call SwitchSpell()<CR>
963 " gitdir or home {{{2
965 " http://git.io/v3GAV
966 function! FindGitDirOrHome()
967 let filedir = expand('%:p:h')
968 if isdirectory(filedir)
969 let cmd = 'bash -c "(cd ' . filedir . '; git rev-parse --show-toplevel 2>/dev/null)"'
970 let gitdir = system(cmd)
971 if strlen(gitdir) == 0
981 command! Cdr execute('cd ' . FindGitDirOrHome())
983 command! LCdr execute('lcd ' . FindGitDirOrHome())
985 " vim:set et sw=2 ts=2 tw=78: