1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-04 01:10:06 +08:00
SpaceVim/autoload/SpaceVim/layers.vim

62 lines
1.7 KiB
VimL
Raw Normal View History

2017-01-18 20:52:19 +08:00
""
" @section Layers, layers
" SpaceVim support such layers:
""
" Load the {layer} you want. For all the layers SpaceVim supports, see @section(layers).
2017-03-08 20:39:25 +08:00
function! SpaceVim#layers#load(layer, ...) abort
2017-05-09 21:55:01 +08:00
if a:layer == '-l'
call s:list_layers()
endif
2017-03-06 23:26:26 +08:00
if index(g:spacevim_plugin_groups, a:layer) == -1
call add(g:spacevim_plugin_groups, a:layer)
endif
2017-03-08 20:39:25 +08:00
if a:0 > 1
for l in a:000
call SpaceVim#layers#load(l)
endfor
endif
2017-01-18 20:52:19 +08:00
endfunction
2017-03-06 23:26:26 +08:00
2017-05-09 21:55:01 +08:00
function! s:list_layers() abort
tabnew SpaceVimLayers
nnoremap <buffer> q :q<cr>
setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline nospell
setf SpaceVimLayerManager
nnoremap <silent> <buffer> q :bd<CR>
let info = [
\ 'SpaceVim layers:',
\ '',
\ ]
call setline(1,info + s:find_layers())
setl nomodifiable
endfunction
function! s:find_layers() abort
let layers = SpaceVim#util#globpath(&rtp, "autoload/SpaceVim/layers/**/*.vim")
let pattern = '/autoload/SpaceVim/layers/'
let rst = []
for layer in layers
if layer =~# pattern
let name = layer[matchend(layer, pattern):-5]
let status = index(g:spacevim_plugin_groups, substitute(name, '/', '#','g')) ? 'loaded' : 'not loaded'
if filereadable(expand('~/.SpaceVim/docs/layers/' . name . '.md'))
let website = 'https://spacevim.org/layers/' . name
else
let website = 'no exists'
endif
if status == 'loaded'
call add(rst, '+ ' . name . ':' . repeat(' ', 25 - len(name)) . status . repeat(' ', 10) . website)
else
call add(rst, '- ' . name . ':' . repeat(' ', 25 - len(name)) . status . repeat(' ', 10) . website)
endif
2017-05-09 21:55:01 +08:00
endif
endfor
return rst
endfunction
2017-03-06 23:26:26 +08:00
" vim:set et sw=2: