1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-24 06:30:03 +08:00
SpaceVim/test/api/file.vader
2021-08-21 13:21:11 +08:00

31 lines
1.9 KiB
Plaintext

Execute ( SpaceVim api: file.fticon ):
scriptencoding utf-8
let g:spacevim_filetype_icons = {}
let file = SpaceVim#api#import('file')
AssertEqual file.fticon('foo.md'), ''
Execute ( SpaceVim api: file.unify_path ):
let path = fnamemodify('.SpaceVim.d/init.vim', ':p')
AssertEqual file.unify_path(path, ':p'), fnamemodify('.SpaceVim.d/init.vim', ':p:gs?[\\/]?/?')
let path = '~/.SpaceVim.d/'
AssertEqual file.unify_path(path, ':p')[-1:], '/'
let path = 'autoload'
AssertEqual file.unify_path(path, ':p')[-1:], '/'
Execute ( SpaceVim api: file.findfile ):
let path = fnamemodify('.SpaceVim.d/init.vim', ':p')
" @bug vim-7.4.629, echo findfile('README.md', 'vimrc') return empty string
AssertEqual file.unify_path(file.findfile('README.md', fnamemodify(path, ':p')), ':.'), '.SpaceVim.d/README.md'
AssertEqual map(file.findfile('README.md', fnamemodify(path, ':p'), 0), 'file.unify_path(v:val, ":.")'), ['.SpaceVim.d/README.md', 'README.md']
AssertEqual file.unify_path(file.findfile('README.md', fnamemodify(path, ':p'), 1), ':.'), '.SpaceVim.d/README.md'
AssertEqual file.unify_path(file.findfile('README.md', fnamemodify(path, ':p'), -1), ':.'), 'README.md'
AssertEqual file.unify_path(file.findfile('README.md', fnamemodify(path, ':p'), -2), ':.'), '.SpaceVim.d/README.md'
let path = fnamemodify('bundle/dein.vim/autoload/dein.vim', ':p')
AssertEqual file.unify_path(file.finddir('doc/', fnamemodify(path, ':p')), ':.'), 'bundle/dein.vim/doc/'
AssertEqual map(file.finddir('doc/', fnamemodify(path, ':p'), 0), 'file.unify_path(v:val, ":.")'), ['bundle/dein.vim/doc/', 'doc/']
AssertEqual file.unify_path(file.finddir('doc/', fnamemodify(path, ':p'), -1), ':.'), 'doc/'
let path2 = fnamemodify('ginit.vim', ':p')
" find the file in same directory
AssertEqual file.unify_path(file.findfile('vimrc', fnamemodify(path, ':p'), -1), ':.'), 'vimrc'
unlet file path