1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-24 09:40:06 +08:00
SpaceVim/test/lua/api/file.vader
2021-08-14 14:20:03 +08:00

36 lines
2.0 KiB
Plaintext

Execute ( SpaceVim lua api: file.fticon(ft) ):
let file = SpaceVim#api#import('file')
let cmp = SpaceVim#api#import('vim#compatible')
lua spacevim_file = require('spacevim.api').import('file')
AssertEqual cmp.luaeval('spacevim_file.fticon("foo.md")'), file.fticon('foo.md')
AssertEqual cmp.luaeval('spacevim_file.fticon("foo.mdxx")'), file.fticon('foo.mdxx')
Execute ( SpaceVim lua api: file.unify_path(path, ...) ):
let file = SpaceVim#api#import('file')
let cmp = SpaceVim#api#import('vim#compatible')
lua spacevim_file = require('spacevim.api').import('file')
AssertEqual cmp.luaeval('spacevim_file.unify_path(".SpaceVim.d/init.vim", ":p")'),
\ file.unify_path(".SpaceVim.d/init.vim", ":p")
AssertEqual cmp.luaeval('spacevim_file.unify_path("~/.SpaceVim.d/", ":p")'),
\ file.unify_path("~/.SpaceVim.d/", ":p")
AssertEqual cmp.luaeval('spacevim_file.unify_path("autoload", ":p")'),
\ file.unify_path("autoload", ":p")
Execute ( SpaceVim lua api: file.path_to_fname(path) ):
let file = SpaceVim#api#import('file')
let cmp = SpaceVim#api#import('vim#compatible')
lua spacevim_file = require('spacevim.api').import('file')
AssertEqual cmp.luaeval('spacevim_file.path_to_fname(".SpaceVim.d/init.vim")'),
\ file.path_to_fname('.SpaceVim.d/init.vim')
Execute ( SpaceVim lua api: file.findfile(what, where, ...) ):
let file = SpaceVim#api#import('file')
let cmp = SpaceVim#api#import('vim#compatible')
lua spacevim_file = require('spacevim.api').import('file')
lua if vim.fn == nil then fn = require('spacevim').fn else fn = vim.fn end
AssertEqual cmp.luaeval('spacevim_file.finddir("doc/", fn.fnamemodify("bundle/dein.vim/autoload/dein.vim", ":p:."))'),
\ file.finddir("doc/", fnamemodify("bundle/dein.vim/autoload/dein.vim", ":p:."))
AssertEqual cmp.luaeval('spacevim_file.unify_path(spacevim_file.findfile("vimrc", "bundle/dein.vim/autoload/dein.vim"), ":.")'),
\ file.unify_path(file.findfile("vimrc", "bundle/dein.vim/autoload/dein.vim"), ":.")
lua spacevim_file = nil