aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-06-06 21:52:49 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-06-06 21:52:49 +1200
commitd239db9de00077955adbdc7b4ec35271fad37e13 (patch)
treede09644eed2e66058a9b7a14e3d76e276fa7ac95
parentActually correct 'runtimepath' dissection code (diff)
downloaddotfiles-d239db9de00077955adbdc7b4ec35271fad37e13.tar.gz
dotfiles-d239db9de00077955adbdc7b4ec35271fad37e13.zip
Switch to regex-based &runtimepath split
-rw-r--r--vim/autoload/.vimrc.vim.un~bin16468 -> 96333 bytes
-rw-r--r--vim/autoload/vimrc.vim72
-rw-r--r--vim/autoload/vimrc.vim~44
3 files changed, 20 insertions, 96 deletions
diff --git a/vim/autoload/.vimrc.vim.un~ b/vim/autoload/.vimrc.vim.un~
index f8d8689d..9ad13933 100644
--- a/vim/autoload/.vimrc.vim.un~
+++ b/vim/autoload/.vimrc.vim.un~
Binary files differ
diff --git a/vim/autoload/vimrc.vim b/vim/autoload/vimrc.vim
index 5280baf6..6ac53c14 100644
--- a/vim/autoload/vimrc.vim
+++ b/vim/autoload/vimrc.vim
@@ -1,11 +1,11 @@
-" Escape a text value for inclusion in an option value
+" Escape a text value for :execute-based :set inclusion in an option
function! vimrc#EscapeSet(string) abort
return escape(a:string, '\ |"')
endfunction
" Escape a text value for inclusion as an element in a comma-separated list
-" option value. Yes, the comma being the sole inner escaped character here is
-" correct. No, we don't escape backslash itself. Yes, that means it's
+" option. Yes, the comma being the sole inner escaped character here is
+" correct. No, we shouldn't escape backslash itself. Yes, that means it's
" impossible to have the literal string '\,' in a part.
function! vimrc#EscapeSetPart(string) abort
return vimrc#EscapeSet(escape(a:string, ','))
@@ -18,66 +18,12 @@ function! vimrc#PluginReady(filename) abort
endfunction
" Split a comma-separated option string into its constituent parts, imitating
-" copy_option_part() in the Vim sources. No, I'm not going to use some insane
-" regular expression. Who do you think I am, Tim Pope?
-function! vimrc#SplitOption(str) abort
-
- " Specify escaping and separating characters
- let esc = '\'
- let sep = ','
-
- " Get string and its length into local variable
- let str = a:str
- let len = strlen(str)
-
- " Prepare list of parts and a variable to hold each part as it's built
- let parts = []
- let part = ''
-
- " Start the index
- let idx = 0
-
- " Iterate through string; we use a while loop because we might be skipping
- " over characters
- while idx < len
-
- " Get the character at this index
- let char = str[idx]
-
- " Examine this character and possibly the one following it
- if char ==# esc && str[idx+1] ==# sep
-
- " If this is the escape character *and* the following character is the
- " separator character, add the separator character to the part, and skip
- " to the character after that for the next iteration. Note that if the
- " following character is *not* the separator character, that means we add
- " the escape character literally. This is deliberate, and is exactly
- " what Vim does!
- let part .= sep
- let idx += 2
-
- elseif char ==# sep
-
- " If this is the separator character, we can add the list part we've
- " built (even if it's blank) to the list of parts, and start a new one
- call add(parts, part)
- let part = ''
- let idx += 1
-
- else
-
- " Just add this character literally, there's nothing special about it
- let part .= char
- let idx += 1
-
- endif
-
- endwhile
-
- " Pass the list of collected string parts to the caller. It might be empty,
- " or contain zero-length strings; neither are error conditions.
- return parts
-
+" copy_option_part() in the Vim sources. This isn't perfect, but it should be
+" more than good enough. A separator can be defined as: a comma that is not
+" preceded by a backslash, and which is followed by any number of spaces
+" and/or further commas.
+function! vimrc#SplitOption(string) abort
+ return split(a:string, '\\\@<!,[, ]*')
endfunction
" Convenience version function check that should work with 7.0 or newer;
diff --git a/vim/autoload/vimrc.vim~ b/vim/autoload/vimrc.vim~
index 3bf6b41c..90ff13f1 100644
--- a/vim/autoload/vimrc.vim~
+++ b/vim/autoload/vimrc.vim~
@@ -1,12 +1,13 @@
-" Escape a text value for inclusion in an option value
+" Escape a text value for :execute-based :set inclusion in an option
function! vimrc#EscapeSet(string) abort
return escape(a:string, '\ |"')
endfunction
" Escape a text value for inclusion as an element in a comma-separated list
-" option value. Yes, the comma being the sole inner escaped character here is
-" correct. If you escape existing backslashes, you'll break it.
-function! vimrc#EscapeSetList(string) abort
+" option. Yes, the comma being the sole inner escaped character here is
+" correct. No, we shouldn't escape backslash itself. Yes, that means it's
+" impossible to have the literal string '\,' in a part.
+function! vimrc#EscapeSetPart(string) abort
return vimrc#EscapeSet(escape(a:string, ','))
endfunction
@@ -16,36 +17,13 @@ function! vimrc#PluginReady(filename) abort
\ && &loadplugins
endfunction
+" Split a comma-separated option string into its constituent parts, imitating
+" copy_option_part() in the Vim sources. This isn't perfect, but it should be
+" more than good enough. A separator can be defined as: a comma that is not
+" preceded by a backslash, and which is followed by any number of spaces
+" and/or further commas.
function! vimrc#SplitOption(str) abort
-
- let esc = '\'
- let sep = ','
-
- let str = a:str
- let len = strlen(str)
-
- let parts = []
- let part = ''
- let idx = 0
-
- while idx < len
-
- let char = str[idx]
- if char ==# esc && str[idx+1] ==# sep
- let part .= sep
- let idx += 1
- elseif char ==# sep
- call add(list, part)
- let part = ''
- else
- let part .= char
- endif
- let idx += 1
-
- endwhile
-
- return parts
-
+ return split(a:str, '\\\@<!,[, ]*')
endfunction
" Convenience version function check that should work with 7.0 or newer;