aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-06-09 16:07:24 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-06-09 16:17:33 +1200
commit3713dc2b6dc6f75db1ee6118d40cdb534cef6ce4 (patch)
tree9a8950e726623ac6aace59a3041def54b4c427c9
parentAmend comment on viminfo file (diff)
downloaddotfiles-3713dc2b6dc6f75db1ee6118d40cdb534cef6ce4.tar.gz
dotfiles-3713dc2b6dc6f75db1ee6118d40cdb534cef6ce4.zip
Save &runtimepath split in a variable for later
-rw-r--r--vim/vimrc21
1 files changed, 11 insertions, 10 deletions
diff --git a/vim/vimrc b/vim/vimrc
index fb5fe383..b1d8faf7 100644
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -58,8 +58,9 @@
"
" Vim, I love you, but you are so weird.
"
-if !exists('$MYVIM') && &runtimepath !=# ''
- let $MYVIM = split(&runtimepath, '\\\@<!,[, ]*')[0]
+let runtimepath = split(&runtimepath, '\\\@<!,[, ]*')
+if !exists('$MYVIM') && len(runtimepath) > 0
+ let $MYVIM = runtimepath[0]
endif
" We need to check the MYVIM environment variable's value to ensure it's not
@@ -86,6 +87,14 @@ elseif v:version < 702 && $MYVIM =~# '\\'
let $MYVIM = ''
endif
+" If the MYVIM environment variable was set outside Vim, it may not correspond
+" to the first element of the default &runtimepath. If this is the case,
+" we'll slot it in, having already checked it for troublesome characters.
+"
+if $MYVIM !=# runtimepath[0]
+ set runtimepath^=$MYVIM
+endif
+
" We're going to be creating a few directories, and the code to do so in
" a compatible way is surprisingly verbose, because we need to check the
" mkdir() function is actually available, and also whether the directory
@@ -121,14 +130,6 @@ if $MYVIM !=# ''
EnsureDir $MYVIM
endif
-" If the MYVIM environment variable was set outside Vim, it may not correspond
-" to the first element of the default &runtimepath. If this is the case,
-" we'll slot it in, having already checked it for troublesome characters.
-"
-if $MYVIM !=# s:SplitOption(&runtimepath)[0]
- set runtimepath^=$MYVIM
-endif
-
" Create a 'vimrc' automatic command hook group, if it already exists, and
" clear away any automatic command hooks already defined within it if it does,
" so that we don't end up collecting multiple copies of the hooks configured