基础插件管理
This commit is contained in:
22
autoload/tui/util/path.vim
Normal file
22
autoload/tui/util/path.vim
Normal file
@ -0,0 +1,22 @@
|
||||
vim9script
|
||||
|
||||
import autoload "tui/util/osinfo.vim"
|
||||
|
||||
export def GetFileSeparator(): string
|
||||
return osinfo.GetFileSeparator()
|
||||
enddef
|
||||
|
||||
export def Normalize(path: string): string
|
||||
assert_true(!empty(path) && !empty(split(path)))
|
||||
|
||||
const path_joined = join(filter(split(path, '[/\\]'), '!empty(split(v:val))'), GetFileSeparator())
|
||||
return expand(match(path, '^[/\\]') != -1 ? (GetFileSeparator() .. path_joined) : path_joined)
|
||||
enddef
|
||||
|
||||
export def Join(parent: string, ...subs: list<string>): string
|
||||
assert_true(!empty(parent) && !empty(split(parent)))
|
||||
|
||||
const path_joined = join(extend([parent], subs), GetFileSeparator())
|
||||
return Normalize(path_joined)
|
||||
enddef
|
||||
|
Reference in New Issue
Block a user