v0.0.1
This commit is contained in:
39
autoload/tui/core/layer.vim
Normal file
39
autoload/tui/core/layer.vim
Normal file
@ -0,0 +1,39 @@
|
||||
vim9script
|
||||
|
||||
export def Init(layer_home: string = v:none)
|
||||
if !tui#core#cached#Has("tui.layer.home")
|
||||
var tui_layer_home = layer_home
|
||||
if empty(layer_home) || empty(split(layer_home))
|
||||
tui_layer_home = expand(tui#core#cached.Get("tui.home") .. "/layers")
|
||||
endif
|
||||
tui#core#cached#Set('tui.layer.home', tui_layer_home)
|
||||
|
||||
command! -nargs=1 -bar TuiLayer call tui#core#layer#Load(<q-args>)
|
||||
Load0(tui_layer_home)
|
||||
endif
|
||||
enddef
|
||||
|
||||
export def Load(layer_id: string)
|
||||
const tui_layer_home = tui#core#cached#Get("tui.layer.home")
|
||||
const layer_path = expand(tui_layer_home .. "/" .. substitute(layer_id, '\.', '/', 'g'))
|
||||
Load0(layer_path)
|
||||
enddef
|
||||
|
||||
def Load0(layer_path: string)
|
||||
if filereadable(layer_path)
|
||||
execute('source ' .. layer_path)
|
||||
elseif filereadable(layer_path .. '.vim')
|
||||
execute('source ' .. layer_path .. '.vim')
|
||||
elseif isdirectory(layer_path)
|
||||
if filereadable(expand(layer_path .. '/init.vim'))
|
||||
execute('source ' .. expand(layer_path .. '/init.vim'))
|
||||
else
|
||||
for sub_file in split(glob(layer_path .. "/*.vim"), '\n')
|
||||
if filereadable(sub_file)
|
||||
execute("source " .. sub_file)
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
endif
|
||||
enddef
|
||||
|
Reference in New Issue
Block a user