98712c27 |
"" My |vimrc|
" A |'textwidth'| of 79 is used throughout.
""" Comments
|
2ac92c80 |
" Comments are written in Vim's help |notation|, see |help-writing|. They can
" be highlighted with https://git.rcrnstn.net/rcrnstn/vim-unobtrusive-comment.
|
98712c27 |
|
2ac92c80 |
" Section headings are not written in the help |notation|, but are instead
" indicated with multiple contiguous comment characters. They can form folds
" with https://git.rcrnstn.net/rcrnstn/vim-unobtrusive-fold.
|
98712c27 |
""" Compatibility
" This vimrc should work with all configurations of Vim. Manually tested with:
" - Features: tiny, huge (Debian `apt-get install vim-{tiny,gtk3}`)
|
2ac92c80 |
" - Locales: C, UTF-8 (`LC_ALL=C{,.UFT-8}`)
" - Colors: 1, 2, 8, 16, 256, termguicolors (`--cmd "set {t_Co=$colors,tgc}"`)
" - UI: TUI, GUI (`{,g}vim`)
|
1d7666bb |
" - Terminals: GUI, VTE, Linux, tmux with the correct `Ss` `terminal-override`
|
2ac92c80 |
" - Platforms: Unix-like
|
98712c27 |
""" Features
" |:version| says "tiny" features are always present and are therefore used in
|
2ac92c80 |
" favor other features whenever possible. "Tiny" features include:
|
98712c27 |
" - |+multi_byte|
" - |+mouse|
" - |+tag_binary|
" - |+user_commands|
" - |+autocmd|
" - |+localmap|
|
2ac92c80 |
" Note that trying to set (run-time, but not compile-time) unsupported options
" is silently ignored, and so can be done without checking for support first
" (which is good, since that requires |+eval|). Everything between |:if| and
" |:endif| is also silently ignored if |+eval| is not available.
|
98712c27 |
""" Encoding
" |'encoding'| is hard-coded to `utf-8`. However, only characters present in
" Code Page 437 should be used in the interface, to ensure font support on most
" terminals (in particular, the Linux console). See
|
2ac92c80 |
" - https://en.wikipedia.org/wiki/Code_page_437
|
98712c27 |
" - https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/tty/vt/cp437.uni
" - `man showconsolefont`
|
c5975eec |
""" Re-sourcing
" |setglobal| is used where appropriate so that buffer/window-local options are
" not overridden when re-sourcing.
|
98712c27 |
|
2ac92c80 |
" A `vimrc` |augroup| is cleared and used for all |autocmd|s. At the time of
" writing, |augroup| messes up the highlighting of |autocmd|s within it, so the
" `vimrc` group name is added to every |autocmd| instead (the addition of the
" group of course makes the highlighting misinterpret it as the
|
98712c27 |
" `vimAutoEventList` and the events instead get the erroneous
|
2ac92c80 |
" `VimAutoCmdSfxList` highlighting... file a bug?). This can be checked with
" `:g/autocmd`.
|
c5975eec |
""" Mappings
" Don't make any built-in mappings do something completely different! Another
" Vimmer should never be surprised by what happens, unless it is pleasantly
|
2ac92c80 |
" surprised because the functionality is extended in useful and obvious ways.
" This includes mappings from popular plugins, for which the defaults should be
" kept as far as possible.
|
c5975eec |
" |<Leader>| is hard-coded to <Space> so that mappings work without |+eval|.
" Setting |mapleader| to a different value after the mappings have been defined
" does not change the mappings, so it is not possible to "hot-swap" it for pair
" programming anyway.
|
98712c27 |
"" Options
|
c5975eec |
" TODO: Use |setglobal| for more things? Note that for options with a non-empty
" default local value, `setglobal` does nothing useful.
|
98712c27 |
""" Reset
" set all&
""" Encoding
" Force Vim's internal encoding to a Unicode encoding.
set encoding=utf-8
""" Buffers
" Allow switching away from unsaved buffers.
set hidden
""" Clipboard
" Integrate with any graphical environment's clipboard.
set clipboard^=unnamedplus
""" Editing
set backspace=indent,eol,start
set virtualedit=block
""" Windows
" Put newly opened windows below and to the right.
set splitbelow
set splitright
""" Interface clutter
set noruler
set showcmd
set shortmess+=I
set guioptions=cf
""" Interface characters
" If |'t_Co'| is empty (or set to 1) the default behavior of |'fillchars'|
|
c5975eec |
" `stl:`/`stlnc:` (`=`/`^`) will be used regardless of its setting. Other good
" choices for |'listchars'| `fold:` is ` ` and `tab:` is: `→ `, `――>`, `├──`,
" `──┤`, `├─┤`.
|
98712c27 |
set list
set linebreak
set breakindent
set breakindentopt=sbr,shift:2
set fillchars=stl:_,stlnc:_,vert:│,fold:─,diff:\ |
set listchars=tab:├\ ┤,trail:•,extends:›,precedes:‹,nbsp:·
set showbreak=»\ |
""" Colors
|
989ff5eb |
set background=dark
|
98712c27 |
if has('gui_running')
set t_Co=16777216
endif
|
2ac92c80 |
if 16 <= &t_Co && &t_Co <= 256 && !&termguicolors
|
98712c27 |
set t_Co=16
endif
""" Title
set title
set titlestring=vim:%{fnamemodify(getcwd(),':~:t:s?^$?/?')}%(:%<%{pathshorten(expand('%:~:.'))}%)
""" Tabs
set expandtab
set shiftround
set shiftwidth=4
set softtabstop=-1
""" Mouse
set mouse=a
""" Command-line
set wildmenu
set wildmode=longest:full,full
|
2ac92c80 |
set wildignore=_*,.git,.cache,.vagrant,.ansible,.npm,node_modules,__pycache__,.venv,*.egg-info,pipx,snap
|
1d7666bb |
if has('patch-8.2.4325')
" See http://ftp.vim.org/pub/vim/patches/8.2/8.2.4325.
set wildoptions+=pum
endif
|
98712c27 |
""" Search
set incsearch
set shortmess-=S
""" Timing
set lazyredraw
set notimeout
set ttimeout
set ttimeoutlen=100
""" Diffs
set diffopt+=vertical
set diffopt+=foldcolumn:0
|
1d7666bb |
if has('patch-8.1.0360')
" See http://ftp.vim.org/pub/vim/patches/8.1/8.1.0360.
set diffopt+=internal
set diffopt+=algorithm:histogram
set diffopt+=indent-heuristic
endif
|
98712c27 |
""" Formatting
" See |auto-format|, |format-comments|, and |fo-table|.
set textwidth=79
|
2ac92c80 |
set winwidth=80
|
98712c27 |
" set colorcolumn=+1
set autoindent
set nojoinspaces
set formatoptions-=t
|
c5975eec |
set formatoptions+=q
|
98712c27 |
set formatoptions+=n
|
c5975eec |
set formatoptions+=j
|
98712c27 |
set nowrap
|
c5975eec |
""" Comments
set commentstring=
|
98712c27 |
""" Folds
set foldlevelstart=999
set foldtext=substitute(getline(v:foldstart),'\\t',repeat('\ ',&ts),'g').'\ '
""" Spelling
set spell
|
1d7666bb |
set spelllang=en_us
|
2ac92c80 |
" `thesaurus/en_us.txt` downloaded from URL documented in |'thesaurus'|:
" https://github.com/vim/vim/issues/629#issuecomment-443293282.
set thesaurus=~/.vim/thesaurus/en_us.txt
|
98712c27 |
""" Views
set viewoptions-=options
set viewoptions+=slash
set viewoptions+=unix
|
2ac92c80 |
""" Files
set swapfile
set writebackup
set undofile
set directory=~/.cache/vim/swap//
set backupdir=~/.cache/vim/backup//
set undodir=~/.cache/vim/undo//
set viewdir=~/.cache/vim/view//
set viminfofile=~/.cache/vim/viminfo
|
98712c27 |
"" Mappings
""" Escape
" Overwrites the default |i_CTRL-C|, |v_CTRL-C|. See
" https://vim.fandom.com/wiki/Avoid_the_escape_key.
inoremap <C-C> <Esc>
xnoremap <C-C> <Esc>
""" Windows
nnoremap <C-H> <C-W>h
nnoremap <C-J> <C-W>j
nnoremap <C-K> <C-W>k
nnoremap <C-L> <C-W>l
tnoremap <C-H> <C-W>h
tnoremap <C-J> <C-W>j
tnoremap <C-K> <C-W>k
tnoremap <C-L> <C-W>l
|
1d7666bb |
""" Buffers
|
2ac92c80 |
nnoremap <Space><Space>bb :ls<CR>:b<Space>
nnoremap <Space><Space>bs :ls<CR>:sb<Space>
nnoremap <Space><Space>bv :ls<CR>:vertical sb<Space>
|
1d7666bb |
|
98712c27 |
""" `$MYVIMRC`
|
2ac92c80 |
nnoremap <silent> <Space><Space>ve :edit $MYVIMRC<CR>
nnoremap <silent> <Space><Space>vs :source $MYVIMRC<CR>
|
98712c27 |
|
1d7666bb |
""" Help
|
c5975eec |
nnoremap <silent> gK :helpgrep \<<C-R><C-W>\><CR>
|
1d7666bb |
xnoremap <silent> gK y:helpgrep <C-R>"<CR>
""" Run
|
98712c27 |
|
1d7666bb |
" File.
|
09ed5bdd |
nnoremap <silent> <Space><Space>% :!%:p:S \| less -FR<CR>
nnoremap <silent> <Space><Space># :!#:p:S \| less -FR<CR>
|
98712c27 |
|
1d7666bb |
" Command.
|
2ac92c80 |
nnoremap <Space><Space>! :new \| .!
|
98712c27 |
|
1d7666bb |
""" Make
|
98712c27 |
" TODO: |dispatch| provides default mappings, try to emulate them?
|
2ac92c80 |
" TODO: Should these be <silent> as well?
|
09ed5bdd |
nnoremap <Space><Space>m% :!make %:r:S \| less -FR<CR>
nnoremap <Space><Space>m# :!make #:r:S \| less -FR<CR>
nnoremap <Space><Space>mm :!make \| less -FR<CR>
nnoremap <Space><Space>ma :!make all \| less -FR<CR>
nnoremap <Space><Space>mt :!make test \| less -FR<CR>
nnoremap <Space><Space>md :!make debug \| less -FR<CR>
|
98712c27 |
if has('quickfix')
|
2ac92c80 |
nnoremap <Space><Space>m% :silent make! %:r:S \| redraw!<CR>
nnoremap <Space><Space>m# :silent make! #:r:S \| redraw!<CR>
nnoremap <Space><Space>mm :silent make! \| redraw!<CR>
nnoremap <Space><Space>ma :silent make! all \| redraw!<CR>
nnoremap <Space><Space>mt :silent make! test \| redraw!<CR>
|
98712c27 |
endif
if has('terminal')
|
2ac92c80 |
nnoremap <Space><Space>md :terminal make debug<CR>
|
98712c27 |
endif
""" Improve default mappings
"""" Disable unconditional quit from Normal mode
" As warned about in |zz| these may be typed accidentally when Caps Lock is
" enabled and lose data. Redefining them is a bit hostile towards other users,
" but deemed worth it.
nnoremap <silent> ZZ :quit<CR>
nnoremap <silent> ZQ :quit<CR>
|
c5975eec |
"""" Yank to end of line, not entire line
|
1d7666bb |
" As suggested in |Y|. Analogous with |D| does `d$` and |C| does `c$`.
|
98712c27 |
nnoremap Y y$
"""" Don't include newline in Visual mode `$`.
xnoremap $ $h
"""" Visual mode paste doesn't clobber unnamed register
xnoremap p pgvy
"""" Visually select last pasted text
|
c5975eec |
" TODO: Make a text object as well?
|
1d7666bb |
" Analogous with how |gv| visually selects last visually selected text. Default
" to always using ordinary Visual mode. Linewise and blockwise with |+eval|
" support.
|
98712c27 |
nnoremap gp `[v`]
if has('eval')
nnoremap <expr> gp '`[' . getregtype()[0] . '`]'
endif
"""" Restrict Visual mode substitutions to the selected text
xnoremap <Space>s :s/\%V
""" Mouse
" As suggested in |scroll-mouse-wheel|, scroll only one line.
noremap <MouseUp> <C-E>
noremap <MouseDown> <C-Y>
|
c5975eec |
" Toggle folds.
noremap <RightMouse> <LeftMouse>za
|
98712c27 |
""" Command-line
" Take already written text into account when searching history.
cnoremap <C-P> <Up>
cnoremap <C-N> <Down>
""" Macros
" Repeat the macro in register `q` on current line, lines covered by visual
" selection, or line covered by text object.
nnoremap QQ @q
xnoremap <silent> Q :normal! @q<CR>
nnoremap <silent> Q :set operatorfunc=<SID>Q<CR>g@
if has('eval')
function! s:Q(...) abort
'[,']normal! @q
endfunction
endif
|
1d7666bb |
""" Diffs
" Current file.
|
09ed5bdd |
nnoremap <silent> <Space><Space>dd :w !diff --color=always -u %:S - \| less -FR<CR>
|
1d7666bb |
" Analogous with |dp| |do| in Normal mode.
nnoremap <silent> <Space>dpp :.diffput<CR>
nnoremap <silent> <Space>doo :.diffget<CR>
xnoremap <silent> <Space>dp :diffput<CR>
xnoremap <silent> <Space>do :diffget<CR>
nnoremap <silent> <Space>dp :set operatorfunc=<SID>diffput<CR>g@
nnoremap <silent> <Space>do :set operatorfunc=<SID>diffget<CR>g@
if has('eval')
function! s:diffput(...) abort
'[,']diffput
endfunction
function! s:diffget(...) abort
'[,']diffget
endfunction
endif
|
98712c27 |
""" Formatting
" Format comment (only). NOTE that this requires a `gc` comment text object
" plugin.
nmap gQ gqgc
nmap gW gwgc
""" Folds
" Focus current fold.
nnoremap zV zMzv
" Focus next/previous fold. Overwrites default move to start/end of
" next/previous fold.
|
2ac92c80 |
nnoremap <silent> zj m<zjzvm>gvzc'>zv
nnoremap <silent> zk zvzckVzvV:<C-R>=prevnonblank(line('.'))<CR><CR>zvzcVoVzv
|
98712c27 |
" Open/close nested folds recursively. Overwrites default open/close fold under
" cursor recursively.
nnoremap <silent> zO zvzczO
nnoremap <silent> zC zvzcV:foldclose!<CR>zvzc
""" Spelling
" Correct last misspelled word with first suggestion without moving the cursor.
" See also |compl-spelling|.
nnoremap z? [s1z=<C-O>
inoremap <C-L> <C-G>u<Esc>[s1z=`]a<C-G>u
""" Visual mode operators
" Allows for visual selection of text objects that share a name with an
" operator.
nnoremap <silent> <Space>v :set operatorfunc=<SID>v<CR>g@
nnoremap <silent> <Space>V :set operatorfunc=<SID>V<CR>g@
nnoremap <silent> <Space><C-V> :set operatorfunc=<SID>CV<CR>g@
if has('eval')
function! s:v(...) abort
execute 'normal!' '`[v`]'
endfunction
function! s:V(...) abort
execute 'normal!' '`[V`]'
endfunction
function! s:CV(...) abort
execute 'normal!' "`[\<C-V>`]"
endfunction
endif
|
c5975eec |
"" Auto commands
|
98712c27 |
" Make sure to not define any |autocmd|s before this!
augroup vimrc
autocmd!
augroup END
|
c5975eec |
""" Open the QuickFix/Location list window
|
98712c27 |
" See
" - https://github.com/tpope/vim-dispatch/issues/145
" - https://github.com/tpope/vim-dispatch/issues/254
" - https://github.com/tpope/vim-dispatch/issues/310
|
c5975eec |
" autocmd vimrc QuickFixCmdPost *{make,{,vim}grep}* nested botright cwindow
" autocmd vimrc QuickFixCmdPost *l{make,{,vim}grep}* nested botright lwindow
|
98712c27 |
|
c5975eec |
""" Highlight all searches
|
98712c27 |
" |'incsearch'| only highlights the first match.
|
c5975eec |
autocmd vimrc CmdlineEnter /,\? let s:hlsearch = &hlsearch | set hlsearch
autocmd vimrc CmdlineLeave /,\? let &hlsearch = s:hlsearch
|
98712c27 |
""" Save/load view
" As suggested in |:loadview|, load auto-saved view when opening buffer. Better
" than |last-position-jump|, |restore-cursor|.
|
c5975eec |
autocmd vimrc BufWinEnter *
|
98712c27 |
\ if !empty(expand('<afile>')) && empty(&buftype) |
\ loadview |
\ endif |
|
c5975eec |
autocmd vimrc BufWinLeave *
|
98712c27 |
\ if !empty(expand('<afile>')) && empty(&buftype) |
\ mkview |
\ endif |
|
09ed5bdd |
""" Don't show extra things in special buffers
|
989ff5eb |
" TODO: This needs to be moved to after the plugins for it to work in e.g.
" fugitive?
|
09ed5bdd |
autocmd vimrc WinEnter,TerminalWinOpen *
\ if &buftype !=# '' |
\ silent setlocal nolist nospell |
\ endif
|
98712c27 |
"" Colors
|
989ff5eb |
" See |cterm-colors|, |gui-colors|.
|
98712c27 |
""" Overrides
|
989ff5eb |
" Transparent background, greyscale interface. Sensible errors/warnings,
" spellchecking, diffs, comments, and todos. See |:hi-normal| and
" |:hi-normal-cterm|.
|
98712c27 |
if !has('gui_running')
|
09ed5bdd |
autocmd vimrc VimEnter,ColorScheme *
|
98712c27 |
\ highlight! Normal guibg=NONE |
endif
" TODO: Look at all in |'highlight'|.
|
09ed5bdd |
autocmd vimrc VimEnter,ColorScheme *
|
989ff5eb |
\ highlight! Normal term=NONE cterm=NONE gui=NONE ctermbg=NONE ctermfg=White |
\ highlight! Comment term=NONE cterm=NONE gui=NONE ctermbg=NONE guibg=NONE ctermfg=Grey |
\ highlight! Todo term=bold cterm=bold gui=bold ctermbg=NONE guibg=NONE ctermfg=White |
\ highlight! LineNr term=NONE cterm=NONE gui=NONE ctermbg=NONE guibg=NONE ctermfg=Grey guifg=Grey |
\ highlight! FoldColumn term=NONE cterm=NONE gui=NONE ctermbg=NONE guibg=NONE ctermfg=Grey guifg=Grey |
\ highlight! SignColumn term=NONE cterm=NONE gui=NONE ctermbg=NONE guibg=NONE ctermfg=Grey guifg=Grey |
\ highlight! VertSplit term=NONE cterm=NONE gui=NONE ctermbg=NONE guibg=NONE ctermfg=Grey guifg=Grey |
\ highlight! StatusLine term=NONE cterm=NONE gui=NONE ctermbg=NONE guibg=NONE ctermfg=White guifg=White |
\ highlight! StatusLineNC term=NONE cterm=NONE gui=NONE ctermbg=NONE guibg=NONE ctermfg=Grey guifg=Grey |
\ highlight! StatusLineTerm term=NONE cterm=NONE gui=NONE ctermbg=NONE guibg=NONE ctermfg=White guifg=White |
\ highlight! StatusLineTermNC term=NONE cterm=NONE gui=NONE ctermbg=NONE guibg=NONE ctermfg=Grey guifg=Grey |
\ highlight! TabLine term=NONE cterm=NONE gui=NONE ctermbg=NONE guibg=NONE ctermfg=Grey guifg=Grey |
\ highlight! TabLineFill term=NONE cterm=NONE gui=NONE ctermbg=NONE guibg=NONE ctermfg=Grey guifg=Grey |
\ highlight! TabLineSel term=NONE cterm=NONE gui=NONE ctermbg=NONE guibg=NONE ctermfg=White guifg=White |
\ highlight! EndOfBuffer term=NONE cterm=NONE gui=NONE ctermbg=NONE guibg=NONE ctermfg=Black guifg=Black |
\ highlight! Error term=NONE cterm=NONE gui=NONE ctermbg=NONE guibg=NONE ctermfg=DarkRed guifg=Red |
\ highlight! ErrorMsg term=NONE cterm=NONE gui=NONE ctermbg=NONE guibg=NONE ctermfg=DarkRed guifg=Red |
\ highlight! WarningMsg term=NONE cterm=NONE gui=NONE ctermbg=NONE guibg=NONE ctermfg=DarkRed guifg=Red |
\ highlight! SpellBad term=NONE cterm=NONE gui=NONE ctermbg=NONE guibg=NONE ctermfg=LightRed guifg=LightRed |
\ highlight! SpellLocal term=NONE cterm=NONE gui=NONE ctermbg=NONE guibg=NONE ctermfg=LightRed guifg=LightRed |
\ highlight! SpellRare term=NONE cterm=NONE gui=NONE ctermbg=NONE guibg=NONE ctermfg=LightRed guifg=LightRed |
\ highlight! SpellCap term=NONE cterm=NONE gui=NONE ctermbg=NONE guibg=NONE ctermfg=LightRed guifg=LightRed |
\ highlight! DiffAdd term=NONE cterm=NONE gui=NONE ctermbg=DarkGreen guibg=Green ctermfg=Black guifg=Black |
\ highlight! DiffDelete term=NONE cterm=NONE gui=NONE ctermbg=DarkRed guibg=Red ctermfg=Black guifg=Black |
\ highlight! DiffChange term=NONE cterm=NONE gui=NONE ctermbg=DarkBlue guibg=Blue ctermfg=Black guifg=Black |
\ highlight! DiffText term=NONE cterm=NONE gui=NONE ctermbg=DarkYellow guibg=Yellow ctermfg=Black guifg=Black |
\ highlight! diffAdded term=NONE cterm=NONE gui=NONE ctermbg=NONE guibg=NONE ctermfg=DarkGreen guifg=Green |
\ highlight! diffRemoved term=NONE cterm=NONE gui=NONE ctermbg=NONE guibg=NONE ctermfg=DarkRed guifg=Red |
""" |'listchars'|
|
09ed5bdd |
autocmd vimrc VimEnter,ColorScheme *
|
989ff5eb |
\ highlight! link SpecialKey Special |
\ highlight! link NonText Special |
|
2ac92c80 |
|
989ff5eb |
""" Folds
|
09ed5bdd |
autocmd vimrc VimEnter,ColorScheme *
|
98712c27 |
\ highlight! link Folded Comment |
|
989ff5eb |
""" Vim comments
|
09ed5bdd |
autocmd vimrc VimEnter,ColorScheme *
|
98712c27 |
\ highlight! link vimCommentString vimComment |
\ highlight! link vimCommentTitle vimComment |
"" Plugins
if has('eval')
|
c5975eec |
""" GitAdd
" https://git.rcrnstn.net/rcrnstn/vim-gitadd
|
98712c27 |
|
c5975eec |
" Make sure to not enable |:syntax| and |:filetype| until all plugins that
" interact with them have been added! See |:packadd|.
command! -bar -bang -nargs=+ GitAdd call s:GitAdd(<q-bang>, <f-args>)
function! s:GitAdd(bang, url, ...) abort
|
98712c27 |
let name = split(a:url, '/')[-1]
|
c5975eec |
let dir = split(&packpath, ',')[0] . '/pack/gitadd/opt/' . name
|
98712c27 |
if !isdirectory(dir)
|
c5975eec |
silent execute '!git clone --recurse-submodules' join(a:000) a:url dir
|
98712c27 |
if isdirectory(dir . '/doc')
execute 'helptags' dir . '/doc'
endif
endif
if empty(a:bang)
|
c5975eec |
execute 'packadd!' name
|
98712c27 |
endif
endfunction
|
c5975eec |
""" File type
|
98712c27 |
|
c5975eec |
"""" Built-in `vim`
|
98712c27 |
|
1d7666bb |
" See |ft-vim-indent|.
|
98712c27 |
let g:vim_indent_cont = 0
|
c5975eec |
"""" Built-in `sh`
|
1d7666bb |
" See |ft-sh-syntax|.
let g:is_posix = 1
|
c5975eec |
"""" Built-in `man`
|
98712c27 |
|
1d7666bb |
" See |ft-man-plugin|.
|
98712c27 |
let g:ft_man_folding_enable = 1
runtime ftplugin/man.vim
|
c5975eec |
setglobal keywordprg=:Man
|
98712c27 |
|
c5975eec |
"""" `sheerun/vim-polyglot`
GitAdd https://github.com/sheerun/vim-polyglot
|
98712c27 |
|
1d7666bb |
let g:vim_markdown_no_default_key_mappings = 1
|
98712c27 |
let g:polyglot_disabled = [
\ 'sensible',
\ 'autoindent',
\ ]
|
c5975eec |
"""" `tpope/vim-sleuth`
GitAdd https://github.com/tpope/vim-sleuth
|
98712c27 |
|
c5975eec |
"""" `tpope/vim-apathy`
GitAdd https://github.com/tpope/vim-apathy
|
98712c27 |
|
c5975eec |
"""" `tpope/vim-scriptease`
GitAdd https://github.com/tpope/vim-scriptease
|
98712c27 |
|
c5975eec |
"""" `jyscao/vim-greprtpscr`
|
09ed5bdd |
GitAdd! https://github.com/jyscao/vim-greprtpscr
|
1d7666bb |
|
c5975eec |
"""" `vimwiki/vimwiki`
" GitAdd https://github.com/vimwiki/vimwiki
|
98712c27 |
" let g:vimwiki_list = [{
" \ 'path': '~/notes/',
" \ 'syntax': 'markdown',
" \ 'ext': '.md',
" \ }]
|
c5975eec |
""" Normal mode
|
98712c27 |
|
c5975eec |
"""" Built-in `matchit`
|
98712c27 |
packadd! matchit
|
c5975eec |
"""" `tpope/vim-unimpaired`
GitAdd https://github.com/tpope/vim-unimpaired
|
98712c27 |
|
c5975eec |
"""" `tpope/vim-repeat`
GitAdd https://github.com/tpope/vim-repeat
|
98712c27 |
|
c5975eec |
"""" `tpope/vim-characterize`
GitAdd https://github.com/tpope/vim-characterize
|
98712c27 |
|
c5975eec |
"""" `haya14busa/vim-asterisk`
GitAdd https://github.com/haya14busa/vim-asterisk
|
98712c27 |
" As suggested by |asterisk-key-mappings|, except the mappings that don't
" move the cursor set |'hlsearch'|.
map * <Plug>(asterisk-*)
map # <Plug>(asterisk-#)
map g* <Plug>(asterisk-g*)
map g# <Plug>(asterisk-g#)
map <silent> z* <Plug>(asterisk-z*): set hlsearch<CR>
map <silent> z# <Plug>(asterisk-z#): set hlsearch<CR>
map <silent> zg* <Plug>(asterisk-gz*):set hlsearch<CR>
map <silent> zg# <Plug>(asterisk-gz#):set hlsearch<CR>
|
c5975eec |
"""" `AndrewRadev/splitjoin.vim`
GitAdd https://github.com/AndrewRadev/splitjoin.vim
|
1d7666bb |
|
c5975eec |
"""" `AndrewRadev/switch.vim`
GitAdd https://github.com/AndrewRadev/switch.vim
|
1d7666bb |
let g:switch_custom_definitions = [{
\ '\<0\>': '1',
\ '\<1\>': '0',
\ '\(\w*\)TRUE\(\w*\)': '\1FALSE\2',
\ '\(\w*\)True\(\w*\)': '\1False\2',
\ '\(\w*\)true\(\w*\)': '\1false\2',
\ '\(\w*\)FALSE\(\w*\)': '\1TRUE\2',
\ '\(\w*\)False\(\w*\)': '\1True\2',
\ '\(\w*\)false\(\w*\)': '\1true\2',
\ }]
|
c5975eec |
""" Insert mode
|
98712c27 |
|
c5975eec |
"""" `tpope/vim-endwise`
GitAdd https://github.com/tpope/vim-endwise
|
98712c27 |
|
c5975eec |
"""" `jiangmiao/auto-pairs`
GitAdd https://github.com/jiangmiao/auto-pairs
|
1d7666bb |
" Don't jump around too much. See |autopairs-options|.
let g:AutoPairsCenterLine = 0
let g:AutoPairsMultilineClose = 0
|
c5975eec |
""" Command-line mode
|
98712c27 |
|
c5975eec |
"""" `tpope/vim-rsi`
GitAdd https://github.com/tpope/vim-rsi
|
98712c27 |
|
c5975eec |
"""" `tpope/vim-abolish`
GitAdd https://github.com/tpope/vim-abolish
|
98712c27 |
|
c5975eec |
""" Operators
|
98712c27 |
|
c5975eec |
"""" `tpope/vim-surround`
GitAdd https://github.com/tpope/vim-surround
|
98712c27 |
|
c5975eec |
"""" `tpope/vim-commentary`
GitAdd https://github.com/tpope/vim-commentary
|
98712c27 |
|
c5975eec |
"""" `tommcdo/vim-lion`
GitAdd https://github.com/tommcdo/vim-lion
|
98712c27 |
|
1d7666bb |
let g:lion_squeeze_spaces = 1
|
c5975eec |
"""" `tommcdo/vim-nowchangethat`
GitAdd https://github.com/tommcdo/vim-nowchangethat
|
1d7666bb |
|
c5975eec |
""" Motions / text objects
" TODO: Check that none of the later ones are not already defined by
" `targets.vim`.
|
98712c27 |
|
c5975eec |
"""" `wellle/targets.vim`
GitAdd https://github.com/wellle/targets.vim
|
98712c27 |
|
c5975eec |
"""" `bkad/CamelCaseMotion`
GitAdd https://github.com/bkad/CamelCaseMotion
|
1d7666bb |
let g:camelcasemotion_key = '<Space>'
|
c5975eec |
"""" `tommcdo/vim-exchange`
GitAdd https://github.com/tommcdo/vim-exchange
"""" `qstrahl/vim-dentures`
|
2ac92c80 |
" TODO: I'm not happy with this, replace.
|
c5975eec |
GitAdd https://github.com/qstrahl/vim-dentures
|
1d7666bb |
|
c5975eec |
"""" `kana/vim-textobj-user`
GitAdd https://github.com/kana/vim-textobj-user
|
98712c27 |
|
c5975eec |
" All later plugins in the "Motions / text objects" category depend on this
" plugin. See https://github.com/kana/vim-textobj-user/wiki.
|
98712c27 |
|
c5975eec |
"""" `kana/vim-textobj-entire`
GitAdd https://github.com/kana/vim-textobj-entire
|
1d7666bb |
|
c5975eec |
"""" `kana/vim-textobj-line`
GitAdd https://github.com/kana/vim-textobj-line
|
98712c27 |
|
1d7666bb |
" As suggested in |textobj-line-default-key-mappings|, except `{a,i}l` is
" taken by `targets` "last", so we use uppercase `{a,i}L`.
let g:textobj_line_no_default_key_mappings = 1
omap aL <Plug>(textobj-line-a)
omap iL <Plug>(textobj-line-i)
xmap aL <Plug>(textobj-line-a)
xmap iL <Plug>(textobj-line-i)
|
c5975eec |
"""" `kana/vim-textobj-fold`
GitAdd https://github.com/kana/vim-textobj-fold
"""" `kana/vim-textobj-syntax`
GitAdd https://github.com/kana/vim-textobj-syntax
|
98712c27 |
|
c5975eec |
"""" `kana/vim-textobj-function`
GitAdd https://github.com/kana/vim-textobj-function
|
1d7666bb |
|
c5975eec |
"""" `idbrii/textobj-word-column.vim`
GitAdd https://github.com/idbrii/textobj-word-column.vim
|
98712c27 |
|
c5975eec |
"""" `adriaanzon/vim-textobj-matchit`
GitAdd https://github.com/adriaanzon/vim-textobj-matchit
|
98712c27 |
|
c5975eec |
"""" `rhysd/vim-textobj-continuous-line`
GitAdd https://github.com/rhysd/vim-textobj-continuous-line
"""" `rsrchboy/vim-textobj-heredocs`
GitAdd https://github.com/rsrchboy/vim-textobj-heredocs
""" Colors
"""" `gruvbox-community/gruvbox`
GitAdd https://github.com/gruvbox-community/gruvbox
|
98712c27 |
let g:gruvbox_contrast_dark = 'hard'
let g:gruvbox_invert_selection = 0
" Earlier settings indicate whether we want a color scheme not based on
" terminal colors. '|termguicolors|' is reset further down if not supported.
if &t_Co >= 256
set termguicolors
colorscheme gruvbox
endif
|
c5975eec |
""" Windows
|
98712c27 |
|
c5975eec |
"""" `moll/vim-bbye`
GitAdd https://github.com/moll/vim-bbye
|
98712c27 |
|
c5975eec |
""" Folds
|
98712c27 |
|
c5975eec |
"""" `rcrnstn/vim-unobtrusive-fold`
GitAdd https://git.rcrnstn.net/rcrnstn/vim-unobtrusive-fold
|
98712c27 |
|
2ac92c80 |
" As suggested in |unobtrusive_fold#text()|.
set foldtext=unobtrusive_fold#text()
" As suggested in |unobtrusive-fold-example|.
autocmd vimrc FileType * UnobtrusiveFoldComment
autocmd vimrc FileType markdown UnobtrusiveFoldChar #
|
c5975eec |
""" Undo
|
1d7666bb |
|
c5975eec |
"""" `mbbill/undotree`
GitAdd https://github.com/mbbill/undotree
|
98712c27 |
|
2ac92c80 |
nnoremap <silent> <Space><Space>u :UndotreeToggle<CR>
|
98712c27 |
|
c5975eec |
" let g:undotree_HighlightChangedText = 0
" let g:undotree_DiffCommand = 'diff -u'
""" QuickFix
"""" Built-in `cfilter`
|
98712c27 |
packadd! cfilter
|
c5975eec |
""" Modelines
"""" `ypcrts/securemodelines`
GitAdd https://github.com/ypcrts/securemodelines
|
1d7666bb |
|
c5975eec |
""" Environment interaction
|
1d7666bb |
|
c5975eec |
"""" Built-in `netrw`
|
98712c27 |
|
c5975eec |
" Netrw versions (roughly) 162h to 170 break `gx`. Never download the remote
" file to a temporary. See
" - https://github.com/vim/vim/issues/1386
" - https://github.com/vim/vim/issues/4738
" - https://github.com/vim/vim/pull/7188
let g:netrw_nogx = 1
nnoremap <silent> gx :call netrw#BrowseX(netrw#GX(), 0)<CR>
xnoremap <silent> gx y:call netrw#BrowseX(@", 0)<CR>
"""" `ctrlpvim/ctrlp.vim`
GitAdd https://github.com/ctrlpvim/ctrlp.vim
|
98712c27 |
|
1d7666bb |
let g:ctrlp_working_path_mode = ''
let g:ctrlp_match_current_file = 1
|
c5975eec |
let g:ctrlp_follow_symlinks = 2
|
1d7666bb |
let g:ctrlp_show_hidden = 1
|
98712c27 |
let g:ctrlp_status_func = ''
let g:ctrlp_line_prefix = ''
|
1d7666bb |
let g:ctrlp_use_caching = 0
|
c5975eec |
let g:ctrlp_use_readdir = 0 " Respect 'wildignore'.
let g:ctrlp_max_files = 0 " Default 10000.
|
1d7666bb |
let g:ctrlp_max_depth = 40 " Default 40.
|
c5975eec |
" let g:ctrlp_user_command_async = 1
|
98712c27 |
if has('unix')
|
c5975eec |
" TODO: Set `grepprg` to something similar, that skips things in
" 'wildignore'.
|
2ac92c80 |
let g:ctrlp_user_command = 'find' .
\ (g:ctrlp_follow_symlinks ? ' -L' : '') .
\ ' %s' .
\ ' -maxdepth ' . g:ctrlp_max_depth .
\ ' \( -false' .
\ (g:ctrlp_show_hidden ? '' : ' -o -name ".*"') .
\ ' ' .
\ join(map(split(&wildignore, ','), '"-o -name " . shellescape(v:val)')) .
\ ' \) -prune -o' .
\ ' -type f' .
\ ' 2> /dev/null' .
\ (g:ctrlp_max_files ? ' | head -n ' . g:ctrlp_max_files : '')
|
c5975eec |
" \ ' -exec grep -Il . {} +' .
|
2ac92c80 |
" \ ' \(' .
" \ (g:ctrlp_follow_symlinks == 2 ? ' -o -type l' : '') .
" \ ' \)' .
|
98712c27 |
endif
|
c5975eec |
"""" `tpope/vim-fugitive`
GitAdd https://github.com/tpope/vim-fugitive
|
98712c27 |
|
1d7666bb |
autocmd vimrc FileType fugitiveblame call fugitive#MapJumps()
|
c5975eec |
"""" `tommcdo/vim-fugitive-blame-ext`
GitAdd https://github.com/tommcdo/vim-fugitive-blame-ext
|
1d7666bb |
|
2ac92c80 |
"""" `iberianpig/tig-explorer.vim`
" GitAdd https://github.com/iberianpig/tig-explorer.vim
|
c5975eec |
"""" `tpope/vim-dispatch`
GitAdd https://github.com/tpope/vim-dispatch
|
98712c27 |
|
2ac92c80 |
" TODO: Stick to the default mappings.
nnoremap <Space><Space>m% :Make %:r:S<CR>
nnoremap <Space><Space>m# :Make #:r:S<CR>
nnoremap <Space><Space>mm :Make<CR>
nnoremap <Space><Space>ma :Make all<CR>
nnoremap <Space><Space>mt :Make test<CR>
|
98712c27 |
|
c5975eec |
"""" `tpope/vim-eunuch`
GitAdd https://github.com/tpope/vim-eunuch
|
98712c27 |
|
c5975eec |
"""" `tpope/vim-projectionist`
GitAdd https://github.com/tpope/vim-projectionist
|
1d7666bb |
|
c5975eec |
""" Debugging
|
98712c27 |
|
c5975eec |
"""" `puremourning/vimspector`
" GitAdd https://github.com/puremourning/vimspector
|
98712c27 |
" Debug Adapter Protocol (DAP) client. See
" https://microsoft.github.io/debug-adapter-protocol/.
|
c5975eec |
"""" `vim-vdebug/vdebug`
" GitAdd https://github.com/vim-vdebug/vdebug
|
98712c27 |
" Common DeBugGer Protocol (DBGP) client. See
" https://en.wikipedia.org/wiki/DBGp.
|
2ac92c80 |
endif "" has('eval')
|
98712c27 |
|
c5975eec |
"" Syntax and file type
|
98712c27 |
if has('eval')
syntax enable
filetype plugin indent on
endif
"" File type overrides
autocmd vimrc FileType vim
|
c5975eec |
\ setlocal keywordprg=:help formatoptions-=r
|
98712c27 |
autocmd vimrc FileType c,cpp
\ setlocal commentstring=//\ %s
|
2ac92c80 |
autocmd vimrc FileType dot
\ setlocal commentstring=//\ %s
autocmd vimrc FileType markdown
\ setlocal complete+=kspell
|
09ed5bdd |
autocmd vimrc FileType man
\ setlocal nolist nospell
|
2ac92c80 |
|
c5975eec |
" As suggested in |ft-syntax-omni|, use syntax completion if no other
" completion has been defined.
autocmd vimrc FileType *
|
2ac92c80 |
\ if &omnifunc ==# '' |
|
c5975eec |
\ setlocal omnifunc=syntaxcomplete#Complete |
\ endif |
|
98712c27 |
"" Terminal overrides
" See |terminal-options|.
""" Cursor
" See |termcap-cursor-shape|, `:helpgrep t_SH`, and "Parameterized Strings" in
" `terminfo(5)`.
if has('cursorshape')
set noshowmode
let &t_vi = ''
let &t_ve = "\<Esc>[?25h"
" if $TERM =~? '^xterm\(-\|$\)'
" See
" - https://vt100.net/docs/vt510-rm/DECSCUSR
" - http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
let &t_EI = "\<Esc>[1 q"
let &t_SI = "\<Esc>[5 q"
let &t_SR = "\<Esc>[3 q"
let &t_SH = "\<Esc>[%p1%d q"
" endif
if $TERM =~? '^linux\(-\|$\)'
" See
" - https://www.kernel.org/doc/Documentation/admin-guide/vga-softcursor.rst
let &t_EI = "\<Esc>[?8c"
let &t_SI = "\<Esc>[?2c"
let &t_SR = "\<Esc>[?2c"
let &t_SH = "\<Esc>[?%?%p1%{3}%<%t%{8}%e%{2}%;%dc"
endif
endif
""" True-color
" See |xterm-true-color|.
if has('termguicolors')
" See https://github.com/termstandard/colors#truecolor-detection.
if empty($COLORTERM) && !has('vcon')
set notermguicolors
endif
" These are the defaults if `$TERM` is `xterm`.
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
" Terminal window does not have transparent background when 'termguicolors'
" is used. See http://ftp.vim.org/pub/vim/patches/8.2/8.2.3516.
if !has('patch-8.2.3516')
let s:termguicolors = &termguicolors
autocmd vimrc TerminalOpen,WinEnter *
\ let s:newtermguicolors =
\ s:termguicolors &&
\ empty(filter(range(1, bufnr('$')),
\ 'getbufvar(v:val, "&buftype") ==# "terminal"'
\ )) |
\ if s:newtermguicolors != &termguicolors |
\ execute 'set' (s:newtermguicolors ? '' : 'no') . 'termguicolors' |
\ endif |
endif
endif
|