mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-03 00:20:05 +08:00
Update file api
This commit is contained in:
parent
f687f841fd
commit
6036899300
@ -9,6 +9,9 @@ endfunction
|
||||
let s:json['json_encode'] = function('s:json_encode')
|
||||
|
||||
function! s:json_decode(json) abort
|
||||
if empty(a:json) && type(a:json) == type('')
|
||||
return ''
|
||||
endif
|
||||
" TODO
|
||||
" support old vim version
|
||||
return json_decode(a:json)
|
||||
|
@ -151,6 +151,30 @@ endfunction
|
||||
|
||||
let s:file['fticon'] = function('s:filetypeIcon')
|
||||
|
||||
function! s:write(msg, fname) abort
|
||||
let flags = filewritable(a:fname) ? 'a' : ''
|
||||
call writefile([a:msg], a:fname, flags)
|
||||
endfunction
|
||||
|
||||
let s:file['write'] = function('s:write')
|
||||
|
||||
function! s:override(msg, fname) abort
|
||||
let flags = filewritable(a:fname) ? 'b' : ''
|
||||
call writefile([a:msg], a:fname, flags)
|
||||
endfunction
|
||||
|
||||
let s:file['override'] = function('s:override')
|
||||
|
||||
function! s:read(fname) abort
|
||||
if filereadable(a:fname)
|
||||
return readfile(a:fname, '')
|
||||
else
|
||||
return ''
|
||||
endif
|
||||
endfunction
|
||||
|
||||
let s:file['read'] = function('s:read')
|
||||
|
||||
function! SpaceVim#api#file#get() abort
|
||||
return deepcopy(s:file)
|
||||
endfunction
|
||||
|
Loading…
Reference in New Issue
Block a user