commit b6bbb17e3f169bc98d261620bc5ebc9f96ef6f8f (tree)
parent 9dcf1d7d81587c45bd08ac8d42f58c06770129fb
Author: Tim Pope <code@tpope.net>
Date: Mon, 24 Jun 2019 14:58:02 -0400
Expose IO functions as object
This is a new interface to a slightly older API for performing standard
VimL IO functions against URLs (or any other URLs, the interface is
generic). Example wrapper function:
function! IO(fn, ...) abort
let file = a:fn ==# 'writefile' ? a:2 : a:1
let obj = get(g:, 'io_' . matchstr(file, '^\a\a\+'), {})
return call(get(obj, a:fn, a:fn), a:000)
endfunction
echo IO('filereadable', @%)
Diffstat:
1 file changed, 17 insertions(+), 0 deletions(-)
diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim
@@ -336,3 +336,20 @@ augroup fugitive
autocmd User ProjectionistDetect call s:ProjectionistDetect()
augroup END
+
+let g:io_fugitive = {
+ \ 'simplify': function('fugitive#simplify'),
+ \ 'resolve': function('fugitive#resolve'),
+ \ 'getftime': function('fugitive#getftime'),
+ \ 'getfsize': function('fugitive#getfsize'),
+ \ 'getftype': function('fugitive#getftype'),
+ \ 'filereadable': function('fugitive#filereadable'),
+ \ 'filewritable': function('fugitive#filewritable'),
+ \ 'isdirectory': function('fugitive#isdirectory'),
+ \ 'getfperm': function('fugitive#getfperm'),
+ \ 'setfperm': function('fugitive#setfperm'),
+ \ 'readfile': function('fugitive#readfile'),
+ \ 'writefile': function('fugitive#writefile'),
+ \ 'glob': function('fugitive#glob'),
+ \ 'delete': function('fugitive#delete'),
+ \ 'Real': function('FugitiveReal')}