From b6bbb17e3f169bc98d261620bc5ebc9f96ef6f8f Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Mon, 24 Jun 2019 14:58:02 -0400 Subject: [PATCH] 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', @%) --- plugin/fugitive.vim | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/plugin/fugitive.vim b/plugin/fugitive.vim index 5a3ac6b..f36e444 100644 --- 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')}