From cd0b47f7690fabaf4dfce522c70411d785f6aa42 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Tue, 9 May 2017 21:55:01 +0800 Subject: [PATCH] Add layers docs --- autoload/SpaceVim/layers.vim | 34 ++++++++++++++++++++++++++++ autoload/SpaceVim/layers/default.vim | 1 + docs/documentation.md | 3 +++ ftplugin/SpaceVimLayerManager.vim | 20 ++++++++++++++++ 4 files changed, 58 insertions(+) create mode 100644 ftplugin/SpaceVimLayerManager.vim diff --git a/autoload/SpaceVim/layers.vim b/autoload/SpaceVim/layers.vim index 8f159c341..328f6fbdc 100644 --- a/autoload/SpaceVim/layers.vim +++ b/autoload/SpaceVim/layers.vim @@ -6,6 +6,9 @@ "" " Load the {layer} you want. For all the layers SpaceVim supports, see @section(layers). function! SpaceVim#layers#load(layer, ...) abort + if a:layer == '-l' + call s:list_layers() + endif if index(g:spacevim_plugin_groups, a:layer) == -1 call add(g:spacevim_plugin_groups, a:layer) endif @@ -16,4 +19,35 @@ function! SpaceVim#layers#load(layer, ...) abort endif endfunction +function! s:list_layers() abort + tabnew SpaceVimLayers + nnoremap q :q + setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline nospell + setf SpaceVimLayerManager + nnoremap q :bd + 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' + let website = 'https://spacevim.org/layers/' . name + call add(rst, name . repeat(' ', 25 - len(name)) . status . repeat(' ', 10) . website) + endif + endfor + return rst +endfunction + + + " vim:set et sw=2: diff --git a/autoload/SpaceVim/layers/default.vim b/autoload/SpaceVim/layers/default.vim index 7e5eb822a..ab3903b3e 100644 --- a/autoload/SpaceVim/layers/default.vim +++ b/autoload/SpaceVim/layers/default.vim @@ -16,6 +16,7 @@ function! SpaceVim#layers#default#config() abort " help mappings call SpaceVim#mapping#space#def('nnoremap', ['h', 'I'], 'call SpaceVim#issue#report()', 'Reporting an issue of SpaceVim', 1) call SpaceVim#mapping#space#def('nnoremap', ['h', 'i'], 'UniteWithCursorWord help', 'get help with the symbol at point', 1) + call SpaceVim#mapping#space#def('nnoremap', ['h', 'l'], 'SPLayer -l', 'lists all the layers available in SpaceVim', 1) call SpaceVim#mapping#space#def('nnoremap', ['h', 'm'], 'Unite manpage', 'search available man pages', 1) call SpaceVim#mapping#space#def('nnoremap', ['h', 'k'], 'LeaderGuide "[KEYs]"', 'show top-level bindings with mapping guide', 1) call SpaceVim#mapping#space#def('nnoremap', ['h', '[SPC]'], 'Unite help -input=SpaceVim', 'unite-SpaceVim-help', 1) diff --git a/docs/documentation.md b/docs/documentation.md index 6bb9390f3..c3941da93 100644 --- a/docs/documentation.md +++ b/docs/documentation.md @@ -349,6 +349,9 @@ SPC h I | Open SpaceVim GitHub issue page with pre-filled information #### Available layers +All layers can be easily discovered via `:SPLayer -l` accessible with `SPC h l`. + + ##### Available packages in Spacemacs ##### New packages from ELPA repositories diff --git a/ftplugin/SpaceVimLayerManager.vim b/ftplugin/SpaceVimLayerManager.vim new file mode 100644 index 000000000..0c5f2f6ca --- /dev/null +++ b/ftplugin/SpaceVimLayerManager.vim @@ -0,0 +1,20 @@ +if exists('g:_SpaceVimLayerManager_ftplugin') + finish +else + let g:_SpaceVimLayerManager_ftplugin = 1 +endif +function! SpaceVimLayerManager#statusline(...) + if &ft ==# 'SpaceVimLayerManager' + call airline#extensions#apply_left_override('SpaceVimLayers', '') + " Alternatively, set the various w:airline_section variables + "let w:airline_section_a = 'SpaceVimPluginManager' + "let w:airline_section_b = '' + "let w:airline_section_c = '' + "let w:airline_render_left = 1 + "let w:airline_render_right = 0 + endif +endfunction +try + call airline#add_statusline_func('SpaceVimLayerManager#statusline') +catch +endtry