aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-06-14 16:55:17 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-06-14 16:55:17 +1200
commit31b1e63a908ed07eac6353f510f791aa179f67ae (patch)
treebdc7b7ea9befbfe25f3d8809eca535b35100c5fe
parentTwo-space markdown files (diff)
downloaddotfiles-31b1e63a908ed07eac6353f510f791aa179f67ae.tar.gz
dotfiles-31b1e63a908ed07eac6353f510f791aa179f67ae.zip
Refactor &runtimepath split a bit more
-rw-r--r--vim/vimrc26
1 files changed, 16 insertions, 10 deletions
diff --git a/vim/vimrc b/vim/vimrc
index f07f4cbe..0b52a2f9 100644
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -87,20 +87,26 @@ scriptencoding utf-8
" string, due to the way that split() works by default without its third
" parameter {keepempty} set to false.
"
-" Once we have the path element, we have to remove the escaping for periods,
-" specifically remove up to one backslash before all periods. We don't,
-" however, have to deal with escaped backslashes, or any other character; you
-" can read the source code for the ad-hoc tokenizer in copy_option_part() in
-" src/misc2.c in Vim's source code and test it with some values of your own if
-" you want to understand why.
+" Once we have the path elements, we have to remove the escaping for periods,
+" specifically remove up to one backslash before all periods. We do that with
+" a map() over substitute(), string-eval style to accommodate older Vim before
+" Funcref variables were added.
+"
+" We don't, however, have to deal with escaped backslashes, or any other
+" character; you can read the source code for the ad-hoc tokenizer in
+" copy_option_part() in src/misc2.c in Vim's source code and test it with some
+" values of your own if you want to understand why.
+"
+" I'll factor this out into a global function if I ever need it anywhere else.
"
" Vim, I love you, but you are really weird.
"
+let runtimepath = map(
+ \ split(&runtimepath, '\\\@<!,[, ]*'),
+ \ "substitute(v:val, '\\\\,', '', 'g')"
+ \ )
if !exists('$MYVIM')
- let $MYVIM = substitute(
- \ split(&runtimepath, '\\\@<!,[, ]*')[0],
- \ '\\,', '', 'g'
- \ )
+ let $MYVIM = runtimepath[0]
endif
" Having either imported or defined a value for the MYVIM environment