From 816e319cf7466c8d873184c84c06d28c0de9a66e Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Sat, 11 Mar 2017 20:43:42 +0800 Subject: [PATCH] Add doc for spacevim-api --- autoload/SpaceVim.vim | 2 +- autoload/SpaceVim/api.vim | 11 +++++++++++ autoload/SpaceVim/api/cmdlinemenu.vim | 10 ++++++++++ doc/SpaceVim.txt | 25 ++++++++++++++++++++++++- 4 files changed, 46 insertions(+), 2 deletions(-) diff --git a/autoload/SpaceVim.vim b/autoload/SpaceVim.vim index 277683ea7..2c9648bd8 100644 --- a/autoload/SpaceVim.vim +++ b/autoload/SpaceVim.vim @@ -10,7 +10,7 @@ " @section Introduction, intro " @stylized spacevim " @library -" @order intro version dicts functions exceptions layers faq +" @order intro version dicts functions exceptions layers api faq " SpaceVim is a bundle of custom settings and plugins with a modular " configuration for Vim. It was inspired by Spacemacs. " diff --git a/autoload/SpaceVim/api.vim b/autoload/SpaceVim/api.vim index aa514aa91..76fac3294 100644 --- a/autoload/SpaceVim/api.vim +++ b/autoload/SpaceVim/api.vim @@ -1,3 +1,14 @@ +"" +" @section API, api +" SpaceVim contains a variety of public apis. here is a list of all the apis. +" @subsection usage +" This is just an example, and it works well in old version vim. +" > +" let s:json = SpaceVim#api#import('data#json') +" let rst = s:json.json_encode(onject) +" let rst = s:json.json_decode(string) +" < + function! SpaceVim#api#import(name) abort let p = {} try diff --git a/autoload/SpaceVim/api/cmdlinemenu.vim b/autoload/SpaceVim/api/cmdlinemenu.vim index ee0a20b9d..025a202ee 100644 --- a/autoload/SpaceVim/api/cmdlinemenu.vim +++ b/autoload/SpaceVim/api/cmdlinemenu.vim @@ -38,6 +38,16 @@ function! s:parseItems(items) abort endfunction " items should be a list of [name, funcrc or string] + +"" +" @section cmdlinemenu, api-cmdlinemenu +" @parentsection api +" menu({items}) +" +" Create a cmdline selection menu from a list of {items}, each item should be a +" list of two value in it, first one is the description, and the next one +" should be a funcrc. + function! s:menu(items) abort let saved_more = &more set nomore diff --git a/doc/SpaceVim.txt b/doc/SpaceVim.txt index dcb0f5c0d..227012ed6 100644 --- a/doc/SpaceVim.txt +++ b/doc/SpaceVim.txt @@ -42,7 +42,9 @@ CONTENTS *SpaceVim-contents* 19. operator...................................|SpaceVim-layer-operator| 20. shell.........................................|SpaceVim-layer-shell| 21. tmux...........................................|SpaceVim-layer-tmux| - 6. FAQ........................................................|SpaceVim-faq| + 6. API........................................................|SpaceVim-api| + 1. cmdlinemenu................................|SpaceVim-api-cmdlinemenu| + 7. FAQ........................................................|SpaceVim-faq| ============================================================================== INTRODUCTION *SpaceVim-intro* @@ -782,6 +784,27 @@ MAPPINGS normal Switch to vim/tmux pane in right direction < +============================================================================== +API *SpaceVim-api* + +SpaceVim contains a variety of public apis. here is a list of all the apis. +USAGE +This is just an example, and it works well in old version vim. +> + let s:json = SpaceVim#api#import('data#json') + let rst = s:json.json_encode(onject) + let rst = s:json.json_decode(string) +< + +============================================================================== +CMDLINEMENU *SpaceVim-api-cmdlinemenu* + +menu({items}) + +Create a cmdline selection menu from a list of {items}, each item should be a +list of two value in it, first one is the description, and the next one should +be a funcrc. + ============================================================================== FAQ *SpaceVim-faq*