aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2022-06-30 01:43:10 +1200
committerTom Ryder <tom@sanctum.geek.nz>2022-07-10 22:08:50 +1200
commita01b0d7f23a31352e25d42e44ea3d55f8952cab1 (patch)
tree4a7583f0cf93a4fea2236e9e268a72f74a645905
parentTranslate autoload/xdg.vim to vim9script (diff)
downloaddotfiles-a01b0d7f23a31352e25d42e44ea3d55f8952cab1.tar.gz
dotfiles-a01b0d7f23a31352e25d42e44ea3d55f8952cab1.zip
Translate autoload/option.vim to vim9script
-rw-r--r--vim/autoload/option.vim30
1 files changed, 14 insertions, 16 deletions
diff --git a/vim/autoload/option.vim b/vim/autoload/option.vim
index 49fbf1a4..82999ba1 100644
--- a/vim/autoload/option.vim
+++ b/vim/autoload/option.vim
@@ -1,17 +1,15 @@
-" Split a comma-separated option value into parts, accounting for escaped
-" commas and leading whitespace as Vim itself does internally
-"
-function! option#Split(expr, ...) abort
- if a:0 > 1
- echoerr 'Too many arguments'
- endif
- let keepempty = a:0 ? a:1 : 0
- let parts = split(a:expr, '\\\@<!,[, ]*', keepempty)
- return map(copy(parts), 'substitute(v:val, ''\\,'', '','', ''g'')')
-endfunction
+vim9script
-" Escape the right-hand side of a :set option value
-"
-function! option#Escape(expr) abort
- return escape(a:expr, ' |"\')
-endfunction
+# Split a comma-separated option value into parts, accounting for escaped
+# commas and leading whitespace as Vim itself does internally
+#
+export def Split(expr: string, keepempty: bool = v:true): list<string>
+ const parts = split(expr, '\\\@<!,[, ]*', keepempty)
+ return map(copy(parts), (_, val) => substitute(val, '\,', ',', 'g'))
+enddef
+
+# Escape the right-hand side of a :set option value
+#
+export def Escape(expr: string): string
+ return escape(expr, ' |"\')
+enddef