aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-05-25 02:33:19 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-05-25 02:33:19 +1200
commit7f0279b0bc1728d8faf084d36d3fb6c82f55ba8f (patch)
tree7802d6330c449aba782278ed7fb4a6828f6797d6
parentMerge branch 'release/v4.46.0' (diff)
parentBump VERSION (diff)
downloaddotfiles-7f0279b0bc1728d8faf084d36d3fb6c82f55ba8f.tar.gz
dotfiles-7f0279b0bc1728d8faf084d36d3fb6c82f55ba8f.zip
Merge branch 'release/v4.47.0'v4.47.0
* release/v4.47.0: Bump VERSION Use ternary logic for 'softtabstop' setting Add filename pattern without period for viminfo Adjust 'viminfo' setting logic, add new env var Move leader definitions Avoid some overkill Lots of refactoring, mostly of comments Simplify \= and \+ maps to remove autoload Switch to more robust $MYVIM definition Simplify 'encoding' checks Save a different path for 'viminfo' file Adjust order of .vimrc
-rw-r--r--VERSION4
-rw-r--r--vim/autoload/vimrc.vim6
-rw-r--r--vim/filetype.vim1
-rw-r--r--vim/vimrc113
4 files changed, 59 insertions, 65 deletions
diff --git a/VERSION b/VERSION
index 16728dbe..b4299a6c 100644
--- a/VERSION
+++ b/VERSION
@@ -1,2 +1,2 @@
-tejr dotfiles v4.46.0
-Fri May 24 04:42:10 UTC 2019
+tejr dotfiles v4.47.0
+Fri May 24 14:33:19 UTC 2019
diff --git a/vim/autoload/vimrc.vim b/vim/autoload/vimrc.vim
deleted file mode 100644
index 1af59c07..00000000
--- a/vim/autoload/vimrc.vim
+++ /dev/null
@@ -1,6 +0,0 @@
-" Run some normal-mode keystrokes without jumping around
-function! vimrc#Anchor(keys) abort
- let view = winsaveview()
- execute 'normal! '.a:keys
- call winrestview(view)
-endfunction
diff --git a/vim/filetype.vim b/vim/filetype.vim
index c5f67db0..8d0251b4 100644
--- a/vim/filetype.vim
+++ b/vim/filetype.vim
@@ -418,6 +418,7 @@ augroup filetypedetect
" .viminfo files
autocmd BufNewFile,BufRead
\ .viminfo
+ \,viminfo
\ setfiletype viminfo
" .wgetrc files
autocmd BufNewFile,BufRead
diff --git a/vim/vimrc b/vim/vimrc
index 740066dd..7bbc1ab1 100644
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -1,13 +1,10 @@
" Tom Ryder (tejr)'s vimrc: <https://sanctum.geek.nz/cgit/dotfiles.git>
" Requires Vim 7.0 or newer with +eval.
-" Set an environment variable for the user runtime directory
+" Set an environment variable for the user runtime directory, if not already
+" set; use the first element of &runtimepath, rather like 'spellfile'
if !exists('$MYVIM')
- let $MYVIM = expand(
- \ has('win32') || has('win64')
- \ ? '~/vimfiles'
- \ : '~/.vim'
- \ )
+ let $MYVIM = expand(split(&runtimepath, ',')[0])
endif
" The all-important default indent settings; filetypes to tweak
@@ -15,35 +12,31 @@ set autoindent " Use indent of previous line on new lines
set expandtab " Use spaces instead of tabs
set shiftwidth=4 " Indent with four spaces
-" The number of spaces the Tab key should insert should follow 'shiftwidth';
-" if Vim is new enough (v7.3.693), use a negative value to automate this,
-" otherwise just use its present value
-if v:version > 703
- \ || v:version == 703 && has('patch693')
- set softtabstop=-1
-else
- let &softtabstop = &shiftwidth
-endif
+" Make insert mode tab key add the same number of spaces as 'shiftwidth', use
+" negative value to do this if Vim new enough to support it
+let &softtabstop =
+ \ v:version > 703 || v:version == 703 && has('patch693')
+ \ ? -1
+ \ : &shiftwidth
+
+" Restore insert mode 'backspace' limits to the stringent Vim default, if a
+" system vimrc or Neovim has messed with it
+set backspace=
-" Try to keep backups in one system-appropriate directory, including full
-" encoded path in filename (trailing double slash) if supported (v8.1.251)
+" Keep backup files in dedicated directory
set backup
-if has('patch-8.1.251')
+if has('patch-8.1.251') " Can keep full path in filename
set backupdir^=$MYVIM/cache/backup//
else
set backupdir^=$MYVIM/cache/backup
endif
-" Restore insert mode 'backspace' limits to the stringent Vim default, if a
-" system vimrc or Neovim's heretical defaults has messed with it
-set backspace=
-
" Add some *nix paths not to back up
-" /dev/shm: Shared memory RAM disk
-" /usr/tmp: Hard-coded path for `sudo -e` 1/2
-" /var/tmp: Hard-coded path for `sudo -e` 2/2
if has('unix')
- set backupskip^=/dev/shm/*,/usr/tmp/*,/var/tmp/*
+ set backupskip& " Reset to avoid duplicates (Vim bug?)
+ set backupskip+=/dev/shm/* " Shared memory RAM disk
+ set backupskip+=/usr/tmp/* " Hard-coded path for `sudo -e` 1/2
+ set backupskip+=/var/tmp/* " Hard-coded path for `sudo -e` 2/2
endif
" Indent wrapped lines if supported (v7.4.338)
@@ -56,9 +49,8 @@ set comments=
set commentstring=
" Add completion options
-" longest: Insert longest common substring
-" menuone: Show the menu even if only one match
-set completeopt+=longest,menuone
+set completeopt+=longest " Insert longest common substring
+set completeopt+=menuone " Show the menu even if only one match
" Give me a prompt instead of just rejecting risky :write, :saveas
set confirm
@@ -66,14 +58,11 @@ set confirm
" Sentence objects are separated by two spaces
set cpoptions+=J
-" Try to keep swap files in one system-appropriate directory, including full
-" encoded path in filename (trailing double slash)
+" Keep swap files in dedicated directory, named with full path
set directory^=$MYVIM/cache/swap//
-" Use UTF-8 if we can and $LANG doesn't tell us not to
-if has('multi_byte')
- \ && !exists('$LANG')
- \ && &encoding ==# 'latin1'
+" If the environment didn't set an encoding, use UTF-8, not ASCII
+if !exists('$LANG')
set encoding=utf-8
endif
@@ -87,13 +76,13 @@ endif
set foldlevelstart=99
set foldmethod=indent
-" Delete comment leaders when joining lines, if supported (v7.3.541)
+" Delete comment leaders when joining lines, if supported
if v:version > 703
\ || v:version == 703 && has('patch541')
set formatoptions+=j
endif
-" Don't break a single space after a period, if supported (v8.1.728)
+" Don't break a single space after a period, if supported
if has('patch-8.1.728')
set formatoptions+=p
endif
@@ -131,12 +120,14 @@ set lazyredraw
set linebreak
" Define extra 'list' display characters
-" extends: Unwrapped text to screen right
-" nbsp: Non-breaking spaces
-" precedes: Unwrapped text to screen left
-" tab: Tab characters, preserve width
-" trail: Trailing spaces
-set listchars+=extends:>,nbsp:+,precedes:<,tab:>-,trail:-
+if has('nvim') " Neovim adds duplicates otherwise
+ set listchars&vi
+endif
+set listchars+=tab:>- " Tab characters, preserve width
+set listchars+=trail:- " Trailing spaces
+set listchars+=extends:> " Unwrapped text to screen right
+set listchars+=precedes:< " Unwrapped text to screen left
+set listchars+=nbsp:+ " Non-breaking spaces
" Don't allow setting options via buffer content
set nomodeline
@@ -151,7 +142,7 @@ set path-=/usr/include
" has switched it on
set noruler
-" Remove Debian's 'runtimepath' nonsense if present
+" Remove Debian's 'runtimepath' addenda if present
set runtimepath-=/var/lib/vim/addons
set runtimepath-=/var/lib/vim/addons/after
@@ -177,20 +168,27 @@ if &term =~# '^putty'
set ttyfast
endif
-" No terminal mouse, even if we could; the manual says to set 't_RV', but
-" doing that doesn't seem to prevent 'ttyfast' from being set; check for
-" option existence as this is not an option in Neovim
-if exists('+ttymouse')
+" Don't use terminal mouse support, even if it would work; the manual says to
+" set 't_RV' to do this, but that doesn't seem to work
+if exists('+ttymouse') " No such option in Neovim
set ttymouse=
endif
-" Try to keep persistent undo files in one system-appropriate directory
-" (v7.2.438), including full encoded path in filename (trailing double slash)
-if has('persistent_undo')
+" Keep persistent undo files in dedicated directory, named with full path
+if has('persistent_undo') " v7.2.438
set undofile
set undodir^=$MYVIM/cache/undo//
endif
+" Keep the viminfo file in the home Vim directory, mostly to stop history
+" getting clobbered when something runs Vim without using this vimrc
+let $VIMINFO = $MYVIM.'/viminfo'
+if exists('+viminfofile') " Use new option method if we can (v8.1.716)
+ let &viminfofile = $VIMINFO
+else " Resort to clunkier method with 'viminfo' option flag
+ execute 'set viminfo+=n'.escape($VIMINFO, '\ ')
+endif
+
" Let me move beyond buffer text in visual block mode
set virtualedit+=block
@@ -226,7 +224,6 @@ endif
set wildmode=list:longest " Tab press completes and lists
" Load filetype settings, plugins, and maps
-let maplocalleader = ','
filetype plugin indent on
" Use syntax highlighting
@@ -240,9 +237,7 @@ try
colorscheme sahara
set cursorline
catch
- if &background != 'dark' " Avoid reloading syntax files unnecessarily
- set background=dark
- endif
+ set background=dark
endtry
" Remap normal space to scroll down a page
@@ -292,6 +287,10 @@ nnoremap ]l :lnext<CR>
nmap [<Space> <Plug>(PutBlankLinesAbove)
nmap ]<Space> <Plug>(PutBlankLinesBelow)
+" Set leader keys
+let mapleader = '\'
+let maplocalleader = ','
+
" \a toggles 'formatoptions' 'a' flag using a plugin
nnoremap <Leader>a :<C-U>ToggleFlagLocal formatoptions a<CR>
@@ -415,9 +414,9 @@ nnoremap <Leader>y :<C-U>registers<CR>
nnoremap <Leader>z :<C-U>setlocal spelllang=en_nz<CR>
" \= runs the whole buffer through =, preserving position
-nnoremap <Leader>= :<C-U>call vimrc#Anchor('1G=G')<CR>
+nnoremap <Leader>= m`1G=G``
" \+ runs the whole buffer through gq, preserving position
-nnoremap <Leader>+ :<C-U>call vimrc#Anchor('1GgqG')<CR>
+nnoremap <Leader>+ m`1GgqG``
" \. runs the configured make program into the location list
nnoremap <Leader>. :<C-U>lmake!<CR>