aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-12-04 15:04:10 +1300
committerTom Ryder <tom@sanctum.geek.nz>2018-12-04 15:07:43 +1300
commitd2894162a1e6d1315a91d0e48677a6eb47ccaf7d (patch)
tree075732dd8e701300e2ca7ea8f1bc144a6515a48d
parentUse :help for 'keywordprg', junk tag binding (diff)
downloaddotfiles-d2894162a1e6d1315a91d0e48677a6eb47ccaf7d.tar.gz
dotfiles-d2894162a1e6d1315a91d0e48677a6eb47ccaf7d.zip
Use "stub .vimrc" method to dodge vim-tiny
-rw-r--r--Makefile3
-rw-r--r--vim/vimrc224
-rw-r--r--vim/vimrc.stub.vim4
3 files changed, 113 insertions, 118 deletions
diff --git a/Makefile b/Makefile
index 882982c6..2629ec55 100644
--- a/Makefile
+++ b/Makefile
@@ -517,7 +517,7 @@ install-urxvt: urxvt/ext/select
VIM = vim
VIMDIR = $(HOME)/.vim
-VIMRC = $(HOME)/.vimrc
+VIMRC = $(HOME)/.vim/vimrc
install-vim: install-vim-after \
install-vim-autoload \
@@ -582,6 +582,7 @@ install-vim-compiler:
cp -p -- vim/compiler/*.vim $(VIMDIR)/compiler
install-vim-config: install-vim-cache
+ cp -p -- vim/vimrc.stub.vim $(HOME)/.vimrc
cp -p -- vim/vimrc $(VIMRC)
if [ -e /etc/debian_version ] ; then \
cp -p -- vim/system/debian.vim $(VIMDIR)/system.vim ; \
diff --git a/vim/vimrc b/vim/vimrc
index 0e489226..f5ffec73 100644
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -1,20 +1,5 @@
" Tom Ryder (tejr)'s vimrc: <https://sanctum.geek.nz/cgit/dotfiles.git>
-"
-" This file is designed to load on any build of Vim version 7.0 or newer,
-" including tiny builds without +eval.
-
-" Require at least Vim 7.0 (released 2006-05-08); otherwise, self-suppress as
-" much of this config as possible
-if v:version < 700
- if has('win32') || has('win64')
- set runtimepath-=~/vimfiles
- set runtimepath-=~/vimfiles/after
- else
- set runtimepath-=~/.vim
- set runtimepath-=~/.vim/after
- endif
- finish
-endif
+" Requires Vim 7.0 or newer with +eval.
" Undo anything the operating system's vimrc may have broken
runtime system.vim
@@ -38,8 +23,14 @@ if has('syntax')
silent! colorscheme sahara
endif
- " If not sahara, then default with dark background
- if !exists('g:colors_name')
+ " If my colorscheme loaded, turn on subtle 'cursorline' coloring
+ if exists('g:colors_name') && g:colors_name ==# 'sahara'
+ if exists('+cursorline')
+ set cursorline
+ endif
+
+ " If it didn't load, default to default scheme with dark background
+ else
set background=dark
endif
@@ -58,22 +49,22 @@ set backspace+=start " The start of current insertion
" Try to keep backups in one system-appropriate dir
set backup
-set backupdir^=~/.vim/cache/backup
if has('win32') || has('win64')
- set backupdir-=~/.vim/cache/backup
set backupdir^=~/vimfiles/cache/backup
+else
+ set backupdir^=~/.vim/cache/backup
endif
" Add some paths not to back up
-set backupskip^=/dev/shm/* " Shared memory RAM disk
-set backupskip^=/var/tmp/* " Debian's $TMPDIR for sudoedit(8)
-if !has('unix')
- set backupskip-=/dev/shm/*
- set backupskip-=/var/tmp/*
+if has('unix')
+ set backupskip^=/dev/shm/* " Shared memory RAM disk
+ set backupskip^=/var/tmp/* " Debian's $TMPDIR for sudoedit(8)
endif
-" Indent wrapped lines
-silent! set breakindent
+" Indent wrapped lines if supported
+if exists('+breakindent')
+ set breakindent
+endif
" Clear default 'comments' value, let the filetype handle it
set comments=
@@ -87,18 +78,11 @@ endif
" Give me a prompt instead of just rejecting risky :write, :saveas
set confirm
-" Only turn on 'cursorline' if my colorscheme loaded
-if exists('+cursorline')
- if exists('g:colors_name') && g:colors_name ==# 'sahara'
- set cursorline
- endif
-endif
-
" Try to keep swapfiles in one system-appropriate dir
-set directory^=~/.vim/cache/swap//
if has('win32') || has('win64')
- set directory-=~/.vim/cache/swap//
set directory^=~/vimfiles/cache/swap//
+else
+ set directory^=~/.vim/cache/swap//
endif
" Use UTF-8 if we can and env LANG didn't tell us not to
@@ -107,8 +91,10 @@ if has('multi_byte') && !exists('$LANG') && &encoding ==# 'latin1'
endif
" Don't wait for a key after Escape in insert mode
-" In vim-tiny but not NeoVim, so just suppress errors
-silent! set noesckeys
+" Not in NeoVim
+if exists('+esckeys')
+ set noesckeys
+endif
" Fold based on indent, but only when I ask
if has('folding')
@@ -117,7 +103,9 @@ if has('folding')
endif
" Delete comment leaders when joining lines, if supported
-silent! set formatoptions+=j
+if v:version > 703 || v:version == 703 && has('patch541')
+ set formatoptions+=j
+endif
" If available, use GNU grep niceties for searching
if system('grep --version') =~# '^grep (GNU grep)'
@@ -137,9 +125,7 @@ set history=2000
" Highlight completed searches; clear on reload
set hlsearch
-if 1
- nohlsearch
-endif
+nohlsearch
" Don't assume I'm editing C; let the filetype set this
set include=
@@ -163,11 +149,11 @@ set lazyredraw
set linebreak
" Define extra 'list' display characters
-set listchars+=extends:> " Unwrapped text to screen right
-set listchars+=precedes:< " Unwrapped text to screen left
-set listchars+=tab:>- " Tab characters, preserve width
-set listchars+=trail:_ " Trailing spaces
-silent! set listchars+=nbsp:+ " Non-breaking spaces
+set listchars+=extends:> " Unwrapped text to screen right
+set listchars+=precedes:< " Unwrapped text to screen left
+set listchars+=tab:>- " Tab characters, preserve width
+set listchars+=trail:_ " Trailing spaces
+set listchars+=nbsp:+ " Non-breaking spaces
" Don't allow setting options via buffer content
set nomodeline
@@ -205,7 +191,9 @@ set splitright " Right of the current window, not left
set timeoutlen=3000
" No terminal mouse, even if we could
-silent! set ttymouse=
+if exists('+ttymouse')
+ set ttymouse=
+endif
" Keep undo files, hopefully in a dedicated directory
if has('persistent_undo')
@@ -218,9 +206,11 @@ if has('persistent_undo')
endif
" Wildmenu settings; see also plugin/wildignore.vim
-set wildmenu " Use wildmenu
-set wildmode=list:longest " Tab press completes and lists
-silent! set wildignorecase " Case insensitive, if supported
+set wildmenu " Use wildmenu
+set wildmode=list:longest " Tab press completes and lists
+if exists('+wildignorecase')
+ set wildignorecase " Case insensitive, if supported
+endif
" Let me move beyond buffer text in visual block mode
if exists('+virtualedit')
@@ -273,164 +263,164 @@ nnoremap ]l :lnext<CR>
nmap [<Space> <Plug>(PutBlankLinesAbove)
nmap ]<Space> <Plug>(PutBlankLinesBelow)
-" Normal leader maps; use <Bslash> not <Leader> for vim-tiny
+" Normal leader maps; use <Leader> not <Leader> for vim-tiny
" \a toggles 'formatoptions' 'a' flag using a plugin
-nnoremap <Bslash>a :<C-U>ToggleFlagLocal formatoptions a<CR>
+nnoremap <Leader>a :<C-U>ToggleFlagLocal formatoptions a<CR>
" \b toggles copy-pasteable linebreak settings
-nmap <Bslash>b <Plug>(CopyLinebreakToggle)
+nmap <Leader>b <Plug>(CopyLinebreakToggle)
" \c toggles 'cursorline'; no visual mode map as it doesn't work
-nnoremap <Bslash>c :<C-U>setlocal cursorline! cursorline?<CR>
+nnoremap <Leader>c :<C-U>setlocal cursorline! cursorline?<CR>
" \C toggles 'cursorcolumn'; works in visual mode
-nnoremap <Bslash>C :<C-U>setlocal cursorcolumn! cursorcolumn?<CR>
-xnoremap <Bslash>C :<C-U>setlocal cursorcolumn! cursorcolumn?<CR>gv
+nnoremap <Leader>C :<C-U>setlocal cursorcolumn! cursorcolumn?<CR>
+xnoremap <Leader>C :<C-U>setlocal cursorcolumn! cursorcolumn?<CR>gv
" \d inserts the local date (POSIX date)
-nnoremap <Bslash>d :read !date<CR>
+nnoremap <Leader>d :read !date<CR>
" \D inserts the UTC date (POSIX date)
-nnoremap <Bslash>D :read !date -u<CR>
+nnoremap <Leader>D :read !date -u<CR>
" \e forces a buffer to be editable
-nnoremap <Bslash>e :<C-U>setlocal modifiable noreadonly<CR>
+nnoremap <Leader>e :<C-U>setlocal modifiable noreadonly<CR>
" \f shows the current 'formatoptions' at a glance
-nnoremap <Bslash>f :<C-U>setlocal formatoptions?<CR>
+nnoremap <Leader>f :<C-U>setlocal formatoptions?<CR>
" \F reloads filetype plugins
-nnoremap <Bslash>F :<C-U>doautocmd filetypedetect BufRead<CR>
+nnoremap <Leader>F :<C-U>doautocmd filetypedetect BufRead<CR>
" \g changes directory to the current file's location
-nnoremap <Bslash>g :<C-U>cd %:h<CR>:pwd<CR>
+nnoremap <Leader>g :<C-U>cd %:h<CR>:pwd<CR>
" \h toggles highlighting search results
-nnoremap <Bslash>h :<C-U>set hlsearch! hlsearch?<CR>
+nnoremap <Leader>h :<C-U>set hlsearch! hlsearch?<CR>
" \H shows command history
-nnoremap <Bslash>H :<C-U>history :<CR>
+nnoremap <Leader>H :<C-U>history :<CR>
" \i toggles showing matches as I enter my pattern
-nnoremap <Bslash>i :<C-U>set incsearch! incsearch?<CR>
+nnoremap <Leader>i :<C-U>set incsearch! incsearch?<CR>
" \j jumps to buffers (jetpack)
-nnoremap <Bslash>j :<C-U>buffers<CR>:buffer<Space>
+nnoremap <Leader>j :<C-U>buffers<CR>:buffer<Space>
" \k shows my marks
-nnoremap <Bslash>k :<C-U>marks<CR>
+nnoremap <Leader>k :<C-U>marks<CR>
" \l toggles showing tab, end-of-line, and trailing whitespace
-nnoremap <Bslash>l :<C-U>setlocal list! list?<CR>
-xnoremap <Bslash>l :<C-U>setlocal list! list?<CR>gv
+nnoremap <Leader>l :<C-U>setlocal list! list?<CR>
+xnoremap <Leader>l :<C-U>setlocal list! list?<CR>gv
" \m shows normal maps
-nnoremap <Bslash>m :<C-U>map<CR>
+nnoremap <Leader>m :<C-U>map<CR>
" \M shows buffer-local normal maps
-nnoremap <Bslash>M :<C-U>map <buffer><CR>
+nnoremap <Leader>M :<C-U>map <buffer><CR>
" \n toggles line number display
-nnoremap <Bslash>n :<C-U>setlocal number! number?<CR>
-xnoremap <Bslash>n :<C-U>setlocal number! number?<CR>gv
+nnoremap <Leader>n :<C-U>setlocal number! number?<CR>
+xnoremap <Leader>n :<C-U>setlocal number! number?<CR>gv
" \N toggles position display in bottom right
-nnoremap <Bslash>N :<C-U>set ruler! ruler?<CR>
-xnoremap <Bslash>N :<C-U>set ruler! ruler?<CR>gv
+nnoremap <Leader>N :<C-U>set ruler! ruler?<CR>
+xnoremap <Leader>N :<C-U>set ruler! ruler?<CR>gv
" \o opens a line below in paste mode
-nmap <Bslash>o <Plug>(PasteOpenBelow)
+nmap <Leader>o <Plug>(PasteOpenBelow)
" \O opens a line above in paste mode
-nmap <Bslash>O <Plug>(PasteOpenAbove)
+nmap <Leader>O <Plug>(PasteOpenAbove)
" \p toggles paste mode
-nnoremap <Bslash>p :<C-U>set paste! paste?<CR>
+nnoremap <Leader>p :<C-U>set paste! paste?<CR>
" \q formats the current paragraph
-nnoremap <Bslash>q gqap
+nnoremap <Leader>q gqap
" \r acts as a replacement operator
-nmap <Bslash>r <Plug>(ReplaceOperator)
-xmap <Bslash>r <Plug>(ReplaceOperator)
+nmap <Leader>r <Plug>(ReplaceOperator)
+xmap <Leader>r <Plug>(ReplaceOperator)
" \R reloads ~/.vimrc
-nnoremap <Bslash>R :<C-U>source $MYVIMRC<CR>
+nnoremap <Leader>R :<C-U>source $MYVIMRC<CR>
" \s toggles spell checking
-nnoremap <Bslash>s :<C-U>setlocal spell! spell?<CR>
+nnoremap <Leader>s :<C-U>setlocal spell! spell?<CR>
" \t shows current filetype
-nnoremap <Bslash>t :<C-U>setlocal filetype?<CR>
+nnoremap <Leader>t :<C-U>setlocal filetype?<CR>
" \T clears filetype
-nnoremap <Bslash>T :<C-U>setlocal filetype=<CR>
+nnoremap <Leader>T :<C-U>setlocal filetype=<CR>
" \u sets US English spelling (compare \z)
-nnoremap <Bslash>u :<C-U>setlocal spelllang=en_us<CR>
+nnoremap <Leader>u :<C-U>setlocal spelllang=en_us<CR>
" \v shows all global variables
-nnoremap <Bslash>v :<C-U>let g: v:<CR>
+nnoremap <Leader>v :<C-U>let g: v:<CR>
" \V shows all local variables
-nnoremap <Bslash>V :<C-U>let b: t: w:<CR>
+nnoremap <Leader>V :<C-U>let b: t: w:<CR>
" \w toggles wrapping
-nnoremap <Bslash>w :<C-U>setlocal wrap! wrap?<CR>
-xnoremap <Bslash>w :<C-U>setlocal wrap! wrap?<CR>gv
+nnoremap <Leader>w :<C-U>setlocal wrap! wrap?<CR>
+xnoremap <Leader>w :<C-U>setlocal wrap! wrap?<CR>gv
" \x strips trailing whitespace via a custom plugin
-nmap <Bslash>x :StripTrailingWhitespace<CR>
-xmap <Bslash>x :StripTrailingWhitespace<CR>
+nmap <Leader>x :StripTrailingWhitespace<CR>
+xmap <Leader>x :StripTrailingWhitespace<CR>
" \X squeezes repeated blank lines via a custom plugin
-nmap <Bslash>X :SqueezeRepeatBlanks<CR>
-xmap <Bslash>X :SqueezeRepeatBlanks<CR>
+nmap <Leader>X :SqueezeRepeatBlanks<CR>
+xmap <Leader>X :SqueezeRepeatBlanks<CR>
" \y shows all registers
-nnoremap <Bslash>y :<C-U>registers<CR>
+nnoremap <Leader>y :<C-U>registers<CR>
" \z sets NZ English spelling (compare \u)
-nnoremap <Bslash>z :<C-U>setlocal spelllang=en_nz<CR>
+nnoremap <Leader>z :<C-U>setlocal spelllang=en_nz<CR>
" \= runs the whole buffer through =, preserving position
-nnoremap <Bslash>= :<C-U>call vimrc#Anchor('1G=G')<CR>
+nnoremap <Leader>= :<C-U>call vimrc#Anchor('1G=G')<CR>
" \+ runs the whole buffer through gq, preserving position
-nnoremap <Bslash>+ :<C-U>call vimrc#Anchor('1GgqG')<CR>
+nnoremap <Leader>+ :<C-U>call vimrc#Anchor('1GgqG')<CR>
" \. runs the configured make program into the location list
-nnoremap <Bslash>. :<C-U>lmake!<CR>
+nnoremap <Leader>. :<C-U>lmake!<CR>
" \< and \> adjust indent of last edit; good for pasting
-nnoremap <Bslash><lt> :<C-U>'[,']<lt><CR>
-nnoremap <Bslash>> :<C-U>'[,']><CR>
+nnoremap <Leader><lt> :<C-U>'[,']<lt><CR>
+nnoremap <Leader>> :<C-U>'[,']><CR>
" \_ uses last changed or yanked text as a characterwise object
-onoremap <Bslash>_ :<C-U>normal! `[v`]<CR>
+onoremap <Leader>_ :<C-U>normal! `[v`]<CR>
" \% uses entire buffer as a linewise object
-onoremap <Bslash>% :<C-U>normal! 1GVG<CR>
+onoremap <Leader>% :<C-U>normal! 1GVG<CR>
" \{ and \} move to lines with non-space chars before current column
-nmap <Bslash>{ <Plug>(VerticalRegionUpNormal)
-nmap <Bslash>} <Plug>(VerticalRegionDownNormal)
-omap <Bslash>{ <Plug>(VerticalRegionUpOperator)
-omap <Bslash>} <Plug>(VerticalRegionDownOperator)
-xmap <Bslash>{ <Plug>(VerticalRegionUpVisual)
-xmap <Bslash>} <Plug>(VerticalRegionDownVisual)
+nmap <Leader>{ <Plug>(VerticalRegionUpNormal)
+nmap <Leader>} <Plug>(VerticalRegionDownNormal)
+omap <Leader>{ <Plug>(VerticalRegionUpOperator)
+omap <Leader>} <Plug>(VerticalRegionDownOperator)
+xmap <Leader>{ <Plug>(VerticalRegionUpVisual)
+xmap <Leader>} <Plug>(VerticalRegionDownVisual)
" \/ types :vimgrep for me ready to enter a search pattern
-nnoremap <Bslash>/ :<C-U>vimgrep /\c/ **<S-Left><S-Left><Right>
+nnoremap <Leader>/ :<C-U>vimgrep /\c/ **<S-Left><S-Left><Right>
" \? types :helpgrep for me ready to enter a search pattern
-nnoremap <Bslash>? :<C-U>helpgrep \c<S-Left>
+nnoremap <Leader>? :<C-U>helpgrep \c<S-Left>
" \DEL deletes the current buffer
-nnoremap <Bslash><Delete> :bdelete<CR>
+nnoremap <Leader><Delete> :bdelete<CR>
" \INS edits a new buffer
-nnoremap <Bslash><Insert> :<C-U>enew<CR>
+nnoremap <Leader><Insert> :<C-U>enew<CR>
" Execution mappings; each of these clobbers register z
" \@ executes line in normal mode
-nnoremap <Bslash>@ ^"zyg_@z
+nnoremap <Leader>@ ^"zyg_@z
" \: executes line in command mode
-nnoremap <Bslash>: ^"zyg_:<C-R>z<CR>
+nnoremap <Leader>: ^"zyg_:<C-R>z<CR>
" \! executes line with 'shell'
-nnoremap <Bslash>! ^"zyg_:!<C-R>z<CR>
+nnoremap <Leader>! ^"zyg_:!<C-R>z<CR>
" Source any .vim files from ~/.vim/config
runtime! config/*.vim
diff --git a/vim/vimrc.stub.vim b/vim/vimrc.stub.vim
new file mode 100644
index 00000000..51ca436a
--- /dev/null
+++ b/vim/vimrc.stub.vim
@@ -0,0 +1,4 @@
+" If we have Vim version >=7, and (implicitly) +eval, source real vimrc
+if v:version >= 700
+ runtime vimrc
+endif