diff --git a/docs/api/file.cn.md b/docs/api/file.cn.md deleted file mode 100644 index 562850a82..000000000 --- a/docs/api/file.cn.md +++ /dev/null @@ -1,14 +0,0 @@ ---- -title: "file api" ---- - -# [APIs](https://spacevim.org/apis) : file - -## values - -name | values | description ------ |:----:| ------------------ -separator | `/` or `\` | The system-dependent name-separator character. -pathSeparator | `:` or `;` | The system-dependent path-separator character. - -## functions diff --git a/docs/api/system.cn.md b/docs/api/system.cn.md deleted file mode 100644 index e357be0f2..000000000 --- a/docs/api/system.cn.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -title: "system api" ---- - -# [APIs](https://spacevim.org/apis) : system - -## values - -name | values | description ------ |:----:| ------------------ -isWindows | 0 or 1 | check if the os is windows -isLinux | 0 or 1 | check if the os is linux -isOSX | 0 or 1 | check if the os is OSX - -## functions diff --git a/docs/cn/api/file.md b/docs/cn/api/file.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/cn/api/job.md b/docs/cn/api/job.md new file mode 100644 index 000000000..14b229135 --- /dev/null +++ b/docs/cn/api/job.md @@ -0,0 +1,43 @@ +--- +title: "异步协同 API" +--- + +# [APIs](https://spacevim.org/cn/apis) : job + +`job` API 提供了一套可以兼容 neovim 和 vim 的异步控制机制,具体实现模型是参考的 neovim 的模型,具体示例如下: + +```vim +let s:JOB = SpaceVim#api#import('job') + +function! s:on_stdout(id, data, event) abort + " do something with stdout +endfunction + +function! s:on_stderr(id, data, event) abort + " do something with stderr +endfunction + +function! s:on_exit(id, data, event) abort + " handle exit code +endfunction + +let cmd = ['python', 'test.py'] + +call s:JOB.start(cmd, + \ { + \ 'on_stdout' : function('s:on_stdout'), + \ 'on_stderr' : function('s:on_stderr'), + \ 'on_exit' : function('s:on_exit'), + \ } + \ ) + +``` + +以上代码可以在 vim 或者 neovim 中异步运行命令,甚至对于老版本的 vim 也兼容,但是在老版本 vim 中执行的时候不是异步的。 + + +## functions + +| 名称 | 描述 | +| ------------------ | ---------------------------- | +| `start(cmd, argv)` | 开始一个 job, 并返回 job id. | diff --git a/docs/cn/api/system.md b/docs/cn/api/system.md new file mode 100644 index 000000000..e69de29bb diff --git a/docs/cn/apis.md b/docs/cn/apis.md index cbc8ebec6..5b3564300 100644 --- a/docs/cn/apis.md +++ b/docs/cn/apis.md @@ -1,5 +1,6 @@ --- title: "公共 API" +description: "SpaceVim 公共 API 提供了一套开发插件的公共函数,以及 neovim 和 vim 的兼容组件" lang: cn --- @@ -9,6 +10,8 @@ SpaceVim 提供了许多公共的 apis,你可以在你的插件中使用这些 ## 使用方法 +可以使用 `SpaceVim#api#import()` 方法导入 API。参考以下示例: + ```viml let s:file = SpaceVim#api#import('file') @@ -25,5 +28,6 @@ echom s:file.pathSeparator 名称 | 描述 | 文档 ----- |:----:| ------- -file | 文件 API | [readme](https://spacevim.org/api/file) -system | 系统 API | [readme](https://spacevim.org/api/system) +file | 文件 API | [readme](https://spacevim.org/cn/api/file) +system | 系统 API | [readme](https://spacevim.org/cn/api/system) +job | 异步协同 API | [readme](https://spacevim.org/cn/api/job)