diff --git a/.SpaceVim.d/autoload/SpaceVim/dev/api.vim b/.SpaceVim.d/autoload/SpaceVim/dev/api.vim new file mode 100644 index 000000000..fb89cb826 --- /dev/null +++ b/.SpaceVim.d/autoload/SpaceVim/dev/api.vim @@ -0,0 +1,99 @@ +"============================================================================= +" api.vim --- Develop script for update api index +" Copyright (c) 2016-2017 Wang Shidong & Contributors +" Author: Wang Shidong < wsdjeg at 163.com > +" URL: https://spacevim.org +" License: GPLv3 +"============================================================================= + +scriptencoding utf-8 + +function! SpaceVim#dev#api#update() abort + + let [start, end] = s:find_position() + if start != 0 && end != 0 + if end - start > 1 + exe (start + 1) . ',' . (end - 1) . 'delete' + endif + call append(start, s:generate_content()) + silent! Neoformat + endif + +endfunction + +function! SpaceVim#dev#api#updateCn() abort + + let [start, end] = s:find_position_cn() + if start != 0 && end != 0 + if end - start > 1 + exe (start + 1) . ',' . (end - 1) . 'delete' + endif + call append(start, s:generate_content_cn()) + silent! Neoformat + endif + +endfunction + +function! s:find_position() abort + let start = search('^$','bwnc') + let end = search('^$','bnwc') + return sort([start, end]) +endfunction + +function! s:find_position_cn() abort + let start = search('^$','bwnc') + let end = search('^$','bnwc') + return sort([start, end]) +endfunction + +function! s:generate_content() abort + let content = ['', '## Available APIs', '', 'here is the list of all available APIs, and welcome to contribute to SpaceVim.', ''] + let content += s:layer_list() + return content +endfunction + +function! s:generate_content_cn() abort + let content = ['', '## 可用 APIs', ''] + let content += s:layer_list_cn() + return content +endfunction + +function! s:layer_list() abort + let layers = SpaceVim#util#globpath('~/.SpaceVim/', 'docs/api/**/*.md') + let list = [ + \ '| Name | Description |', + \ '| ---------- | ------------ |' + \ ] + for layer in layers + let name = split(layer, '/docs/api/')[1][:-4] . '/' + let url = name + let content = readfile(layer) + if len(content) > 3 + let line = '| [' . join(split(name, '/'), '#') . '](' . url . ') | ' . content[2][14:-2] . ' | ' + else + let line = '| [' . join(split(name, '/'), '#') . '](' . url . ') | can not find Description |' + endif + call add(list, line) + endfor + return list +endfunction + +function! s:layer_list_cn() abort + let layers = SpaceVim#util#globpath('~/.SpaceVim/', 'docs/cn/api/**/*.md') + let list = [ + \ '| 名称 | 描述 |', + \ '| ---------- | ------------ |' + \ ] + for layer in layers + let name = split(layer, '/docs/cn/api/')[1][:-4] . '/' + let url = name + let content = readfile(layer) + if len(content) > 3 + let line = '| [' . join(split(name, '/'), '#') . '](' . url . ') | ' . content[2][14:-2] . ' | ' + else + let line = '| [' . join(split(name, '/'), '#') . '](' . url . ') | can not find Description |' + endif + call add(list, line) + endfor + return list +endfunction diff --git a/autoload/SpaceVim/api/system.vim b/autoload/SpaceVim/api/system.vim index 53448178d..f2a78ae4a 100644 --- a/autoload/SpaceVim/api/system.vim +++ b/autoload/SpaceVim/api/system.vim @@ -14,17 +14,24 @@ let s:system['isLinux'] = has('unix') && !has('macunix') && !has('win32unix') let s:system['isOSX'] = has('macunix') + +" windows, unix, cygwin, mac, linux + function! s:name() abort if s:system.isLinux - return 'Linux' + return 'linux' elseif s:system.isWindows - return 'Windows' + if has('win32unix') + return 'cygwin' + else + return 'windows' + endif else - return 'OSX' + return 'mac' endif endfunction -let s:system['name'] = function('s:name') +let s:system['name'] = s:name() function! s:isDarwin() abort if exists('s:is_darwin') diff --git a/autoload/SpaceVim/layers/core.vim b/autoload/SpaceVim/layers/core.vim index 8eeea5130..9ffb94867 100644 --- a/autoload/SpaceVim/layers/core.vim +++ b/autoload/SpaceVim/layers/core.vim @@ -15,7 +15,7 @@ function! SpaceVim#layers#core#plugins() abort elseif g:spacevim_filemanager ==# 'vimfiler' call add(plugins, ['Shougo/vimfiler.vim',{'merged' : 0, 'loadconf' : 1 , 'loadconf_before' : 1, 'on_cmd' : ['VimFiler', 'VimFilerBufferDir']}]) call add(plugins, ['Shougo/unite.vim',{ 'merged' : 0 , 'loadconf' : 1}]) - call add(plugins, ['Shougo/vimproc.vim', {'build' : ['make']}]) + call add(plugins, ['Shougo/vimproc.vim', {'build' : [(executable('gmake') ? 'gmake' : 'make')]}]) endif call add(plugins, ['benizi/vim-automkdir']) diff --git a/autoload/SpaceVim/plugins/manager.vim b/autoload/SpaceVim/plugins/manager.vim index cba9ed3c0..0b9782893 100644 --- a/autoload/SpaceVim/plugins/manager.vim +++ b/autoload/SpaceVim/plugins/manager.vim @@ -10,6 +10,7 @@ let s:VIM_CO = SpaceVim#api#import('vim#compatible') let s:JOB = SpaceVim#api#import('job') let s:LIST = SpaceVim#api#import('data#list') +let s:SYS = SpaceVim#api#import('system') " init values @@ -110,7 +111,7 @@ function! s:get_uninstalled_plugins() abort endfunction -function! SpaceVim#plugins#manager#reinstall(...) +function! SpaceVim#plugins#manager#reinstall(...) abort call dein#reinstall(a:1) endfunction @@ -448,8 +449,7 @@ function! s:msg_on_build_start(name) abort endfunction function! s:get_build_argv(build) abort - " TODO check os - return a:build + return a:build[s:SYS.name] endfunction " + foo.vim: Updating... if has('nvim') @@ -643,7 +643,7 @@ else endi " Public API: SpaceVim#plugins#manager#terminal {{{ -function! SpaceVim#plugins#manager#terminal() +function! SpaceVim#plugins#manager#terminal() abort for id in keys(s:pulling_repos) call s:JOB.stop(str2nr(id)) endfor diff --git a/config/functions.vim b/config/functions.vim index c2603099e..869d747c4 100644 --- a/config/functions.vim +++ b/config/functions.vim @@ -9,9 +9,9 @@ function! WINDOWS() return (has('win16') || has('win32') || has('win64')) endfunction function! OnmiConfigForJsp() - let pos1 = search("","nb",line("w0")) - let pos2 = search("","n",line("w$")) + let pos1 = search('','nb',line('w0')) + let pos2 = search('','n',line('w$')) let pos0 = line('.') if pos1 < pos2 && pos2 < pos0 && pos0 < pos3 set omnifunc=javascriptcomplete#CompleteJS @@ -37,7 +37,7 @@ endf function! ToggleBG() let s:tbg = &background " Inversion - if s:tbg == "dark" + if s:tbg ==# 'dark' set background=light else set background=dark @@ -46,7 +46,7 @@ endfunction function! BracketsFunc() let line = getline('.') let col = col('.') - if line[col - 2] == "]" + if line[col - 2] ==# ']' return "{}\i" else return "{\}\O" @@ -191,11 +191,3 @@ fu! UpdateStarredRepos() endfor return 1 endf - - -function! TestBot(argv) abort -endfunction - -function! TestBot(argv) abort - -endfunction diff --git a/config/init.vim b/config/init.vim index 86363d585..ea46ed5de 100644 --- a/config/init.vim +++ b/config/init.vim @@ -8,14 +8,6 @@ let s:SYSTEM = SpaceVim#api#import('system') -" Fsep && Psep -if has('win16') || has('win32') || has('win64') - let s:Psep = ';' - let s:Fsep = '\' -else - let s:Psep = ':' - let s:Fsep = '/' -endif "Use English for anything in vim try if s:SYSTEM.isWindows diff --git a/docs/api.md b/docs/api.md new file mode 100644 index 000000000..b38d90f17 --- /dev/null +++ b/docs/api.md @@ -0,0 +1,45 @@ +--- +title: "APIs" +description: "A list of available APIs in SpaceVim, provide compatible functions for vim and neovim." +redirect_from: "/apis/" +--- + +# SpaceVim APIs + + + +- [Introduction](#introduction) +- [Available APIs](#available-apis) + + + +## Introduction + +SpaceVim provides many public apis, you can use this apis in your plugins. +This is an example for how to load API, and how to use the public functions within the APIs. + +```vim +" use SpaceVim#api#import() to load the API +let s:file = SpaceVim#api#import('file') +let s:system = SpaceVim#api#import('system') + +" check the if current os is Windows. +if s:system.isWindows + echom "Os is Windows" +endif +echom s:file.separator +echom s:file.pathSeparator +``` + + + +## Available APIs + +here is the list of all available APIs, and welcome to contribute to SpaceVim. + +| Name | Description | +| ----------------- | ------------------------------------------------------------------- | +| [file](file/) | file API provides some besic functions and values for current os. | +| [system](system/) | system API provides some besic functions and values for current os. | + + diff --git a/docs/api/file.md b/docs/api/file.md index 562850a82..e6ffde3a3 100644 --- a/docs/api/file.md +++ b/docs/api/file.md @@ -1,14 +1,32 @@ --- title: "file api" +description: "file API provides some besic functions and values for current os." --- -# [APIs](https://spacevim.org/apis) : file +# [Available APIs](../) >> file + + + + +- [values](#values) +- [functions](#functions) + + ## values -name | values | description ------ |:----:| ------------------ -separator | `/` or `\` | The system-dependent name-separator character. -pathSeparator | `:` or `;` | The system-dependent path-separator character. +| name | description | +| ------------- | ---------------------------------------------- | +| separator | The system-dependent name-separator character. | +| pathSeparator | The system-dependent path-separator character. | ## functions + +| name | description | +| ------------------------- | ----------------------------------------------- | +| `fticon(file)` | return the icon of specific file name or path | +| `write(message, file)` | append message to file | +| `override(message, file)` | override message to file | +| `read(file)` | read message from file | +| `ls(dir, if_file_only)` | list files and directorys in specific directory | +| `updateFiles(files)` | update the contents of all files | diff --git a/docs/api/system.md b/docs/api/system.md index e357be0f2..6d9bf45d4 100644 --- a/docs/api/system.md +++ b/docs/api/system.md @@ -1,15 +1,21 @@ --- title: "system api" +description: "system API provides some besic functions and values for current os." --- -# [APIs](https://spacevim.org/apis) : system +# [Available 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 +| 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 | +| isDarwin | 0 or 1 | check if the os is Darwin | ## functions + +| name | description | +| ---------- | -------------------------------------- | +| fileformat | return the icon of current file format | diff --git a/docs/apis.md b/docs/apis.md deleted file mode 100644 index fdbd6cb82..000000000 --- a/docs/apis.md +++ /dev/null @@ -1,28 +0,0 @@ ---- -title: "APIs" ---- - -# SpaceVim public APIs: - -SpaceVim provide many public apis, you can use this apis in your plugins. SpaceVim api got inspired by [vital.vim](https://github.com/vim-jp/vital.vim) - -## Usage - -```viml - -let s:file = SpaceVim#api#import('file') -let s:system = SpaceVim#api#import('system') - -if s:system.isWindows - echom "Os is Windows" -endif -echom s:file.separator -echom s:file.pathSeparator -``` - -here is the list of all the apis, and welcome to contribute to SpaceVim. - -name | description | documentation ------ |:----:| ------- -file | basic api about file and directory | [readme](https://spacevim.org/api/file) -system | basic api about system | [readme](https://spacevim.org/api/system) diff --git a/docs/cn/apis.md b/docs/cn/api.md similarity index 90% rename from docs/cn/apis.md rename to docs/cn/api.md index 5b3564300..f5272133c 100644 --- a/docs/cn/apis.md +++ b/docs/cn/api.md @@ -1,6 +1,7 @@ --- title: "公共 API" description: "SpaceVim 公共 API 提供了一套开发插件的公共函数,以及 neovim 和 vim 的兼容组件" +redirect_from: "/cn/apis/" lang: cn --- @@ -26,8 +27,13 @@ echom s:file.pathSeparator 以下为可用的公共 apis,欢迎贡献新的 apis + + 名称 | 描述 | 文档 ----- |:----:| ------- 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) + + + diff --git a/docs/cn/development.md b/docs/cn/development.md index 1c1c0a55f..354051ad3 100644 --- a/docs/cn/development.md +++ b/docs/cn/development.md @@ -288,7 +288,7 @@ You are free to choose a reasonable height size but the width size should be aro ## Build with SpaceVim -SpaceVim provide a lot of public [APIs](https://spacevim.org/apis), you can create plugins base on this APIs. also you can add a badge to the README.md of your plugin. +SpaceVim provide a lot of public [APIs](../api/), you can create plugins base on this APIs. also you can add a badge to the README.md of your plugin. ![](https://img.shields.io/badge/build%20with-SpaceVim-ff69b4.svg) diff --git a/docs/cn/documentation.md b/docs/cn/documentation.md index 8ab920759..c4b4dadb0 100644 --- a/docs/cn/documentation.md +++ b/docs/cn/documentation.md @@ -219,7 +219,7 @@ call SpaceVim#custom#SPC('nore', ['G', 't'], 'echom 1', 'echomessage 1', 1) ### 私有模块 这一部分简单介绍了模块的组成,更多关于新建模块的内容可以阅读 -SpaceVim 的[模块首页](layers/)。 +SpaceVim 的[模块首页](../layers/)。 **目的** @@ -264,7 +264,7 @@ SpaceVim 集成了多种使用 UI 插件,如常用的文件树、语法树等 | `SPC T n` | 切换至下一个随机主题 | | `SPC T s` | 通过 Unite 选择主题 | -可以在[主题模块](layers/colorscheme/)中查看 SpaceVim 支持的所有主题。 +可以在[主题模块](../layers/colorscheme/)中查看 SpaceVim 支持的所有主题。 **注意**: @@ -753,11 +753,9 @@ Denite/Unite 是一个强大的信息筛选浏览器,这类似于 emacs 中的 如果添加来自于 github.com 的插件,可以 `用户名/仓库名` 这一格式,将该插件添加到 `custom_plugins`,示例如下: ```toml -# custom plugins {{{ [[custom_plugins]] name = 'lilydjwg/colorizer' merged = 0 -# }}} ``` #### 界面元素显示切换 diff --git a/docs/cn/layers/colorscheme.md b/docs/cn/layers/colorscheme.md index dab793a1a..3499feec1 100644 --- a/docs/cn/layers/colorscheme.md +++ b/docs/cn/layers/colorscheme.md @@ -25,7 +25,7 @@ colorscheme 模块为 SpaceVim 提供了一系列常用的颜色主题,默认 ```toml [[layers]] - name = 'colorscheme' + name = "colorscheme" ``` ## 模块配置 @@ -57,7 +57,7 @@ SpaceVim 支持在配置文件中通过 `colorscheme_bg` 这一选项来设置 ```toml [options] colorscheme = "onedark" - colorscheme_bg = 'dark' + colorscheme_bg = "dark" ``` 这一模块提供了,在启动时随机选择主题,而不是使用默认的主题。这一特性可以很 @@ -65,6 +65,6 @@ SpaceVim 支持在配置文件中通过 `colorscheme_bg` 这一选项来设置 ```toml [[layers]] - name = 'colorscheme' + name = "colorscheme" random-theme = true ``` diff --git a/docs/development.md b/docs/development.md index c031c4300..2beda1524 100644 --- a/docs/development.md +++ b/docs/development.md @@ -291,7 +291,7 @@ You are free to choose a reasonable height size but the width size should be aro ## Build with SpaceVim -SpaceVim provide a lot of public [APIs](../apis/), you can create plugins base on this APIs. also you can add a badge to the README.md of your plugin. +SpaceVim provide a lot of public [APIs](../api/), you can create plugins base on this APIs. also you can add a badge to the README.md of your plugin. ![](https://img.shields.io/badge/build%20with-SpaceVim-ff69b4.svg) diff --git a/docs/documentation.md b/docs/documentation.md index be69b1744..4c1358b12 100644 --- a/docs/documentation.md +++ b/docs/documentation.md @@ -308,7 +308,7 @@ the variable colorschemes. For instance, to specify `desert`: | `SPC T n` | switch to next random colorscheme listed in colorscheme layer. | | `SPC T s` | select a theme using a unite buffer. | -all the included colorscheme can be found in [colorscheme layer](layers/colorscheme/). +all the included colorscheme can be found in [colorscheme layer](../layers/colorscheme/). **NOTE**: @@ -816,11 +816,9 @@ All plugins can be easily discovered via ` l p`. If you want to add plugin from github, just add the repo name to the SpaceVim option `custom_plugins`: ```toml -# custom plugins {{{ [[custom_plugins]] name = 'lilydjwg/colorizer' merged = 0 -# }}} ``` #### Toggles diff --git a/docs/layers/colorscheme.md b/docs/layers/colorscheme.md index 010e47deb..9bf7b11fd 100644 --- a/docs/layers/colorscheme.md +++ b/docs/layers/colorscheme.md @@ -25,7 +25,7 @@ To use this configuration layer, add this snippet to your custom configuration f ```toml [[layers]] - name = 'colorscheme' + name = "colorscheme" ``` ## Configuration @@ -55,13 +55,13 @@ Vim background color. SpaceVim support to change the background color with ```toml [options] colorscheme = "onedark" - colorscheme_bg = 'dark' + colorscheme_bg = "dark" ``` colorscheme layer support random colorscheme on startup. just load this layer with layer option `random-theme` ```toml [[layers]] - name = 'colorscheme' + name = "colorscheme" random-theme = true ```