diff options
Diffstat (limited to 'vim/autoload')
-rw-r--r-- | vim/autoload/escape.vim | 13 | ||||
-rw-r--r-- | vim/autoload/map.vim | 5 | ||||
-rw-r--r-- | vim/autoload/path.vim | 10 | ||||
-rw-r--r-- | vim/autoload/plugin.vim | 5 | ||||
-rw-r--r-- | vim/autoload/reload.vim | 12 | ||||
-rw-r--r-- | vim/autoload/split.vim | 8 | ||||
-rw-r--r-- | vim/autoload/unescape.vim | 3 |
7 files changed, 56 insertions, 0 deletions
diff --git a/vim/autoload/escape.vim b/vim/autoload/escape.vim new file mode 100644 index 00000000..0fdfba99 --- /dev/null +++ b/vim/autoload/escape.vim @@ -0,0 +1,13 @@ +function! escape#Arg(arg) abort + return exists('*fnameescape') + \ ? fnameescape(a:arg) + \ : escape(a:arg, "\n\r\t".' *?[{`$\%#''"|!<') +endfunction + +function! escape#Item(item) abort + return escape(a:item, ',') +endfunction + +function! escape#Wild(string) abort + return escape(a:string, '\*?[{`''$~') +endfunction diff --git a/vim/autoload/map.vim b/vim/autoload/map.vim new file mode 100644 index 00000000..2630bcd3 --- /dev/null +++ b/vim/autoload/map.vim @@ -0,0 +1,5 @@ +function! map#(list, Func) abort + return has('patch-7.4.1989') + \ ? map(a:list, a:Func) + \ : map(a:list, string(a:Func).'(0, v:val)') +endfunction diff --git a/vim/autoload/path.vim b/vim/autoload/path.vim new file mode 100644 index 00000000..2506ad53 --- /dev/null +++ b/vim/autoload/path.vim @@ -0,0 +1,10 @@ +function! path#Create(name, ...) abort + if a:0 > 2 + echoerr 'Too many arguments' + endif + if isdirectory(a:name) + return 1 + endif + let prot = a:0 >= 1 ? a:1 : 0755 + return mkdir(a:name, 'p', prot) +endfunction diff --git a/vim/autoload/plugin.vim b/vim/autoload/plugin.vim new file mode 100644 index 00000000..b6f3d974 --- /dev/null +++ b/vim/autoload/plugin.vim @@ -0,0 +1,5 @@ +function! plugin#Ready(name) abort + return &loadplugins + \ && globpath(&runtimepath, 'plugin/'.a:name.'.vim') != '' +endfunction + diff --git a/vim/autoload/reload.vim b/vim/autoload/reload.vim new file mode 100644 index 00000000..558f24d6 --- /dev/null +++ b/vim/autoload/reload.vim @@ -0,0 +1,12 @@ +function! reload#FileType() abort + if exists('g:did_load_filetypes') + doautocmd filetypedetect BufRead + endif +endfunction + +function! reload#Vimrc() abort + noautocmd source $MYVIMRC + call reload#FileType() + redraw + echomsg fnamemodify($MYVIMRC, ':p:~').' reloaded' +endfunction diff --git a/vim/autoload/split.vim b/vim/autoload/split.vim new file mode 100644 index 00000000..92d7a133 --- /dev/null +++ b/vim/autoload/split.vim @@ -0,0 +1,8 @@ +function! split#Option(expr, ...) abort + if a:0 > 2 + echoerr 'Too many arguments' + endif + let keepempty = a:0 ? a:1 : 0 + let parts = split(a:expr, '\\\@<!,[, ]*', keepempty) + return map#(parts, function('unescape#Item')) +endfunction diff --git a/vim/autoload/unescape.vim b/vim/autoload/unescape.vim new file mode 100644 index 00000000..a809827d --- /dev/null +++ b/vim/autoload/unescape.vim @@ -0,0 +1,3 @@ +function! unescape#Item(key, val) abort + return substitute(a:val, '\\,', ',', 'g') +endfunction |