diff --git a/docs/cn/documentation.md b/docs/cn/documentation.md index 2a5dde8ad..7143702ae 100644 --- a/docs/cn/documentation.md +++ b/docs/cn/documentation.md @@ -18,6 +18,7 @@ lang: cn - [更新插件](#更新插件) - [获取日志](#获取日志) - [用户配置](#用户配置) + - [启动函数](#启动函数) - [Vim 兼容模式](#vim-兼容模式) - [私有模块](#私有模块) - [概念](#概念) @@ -199,6 +200,28 @@ call SpaceVim#custom#SPCGroupName(['G'], '+TestGroup') call SpaceVim#custom#SPC('nore', ['G', 't'], 'echom 1', 'echomessage 1', 1) ``` +### 启动函数 + +由于 toml 配置的局限性,SpaceVim 提供了两种启动函数 `bootstrap_before` 和 `bootstrap_after`,在该函数内可以使用 Vim script。 +可通过设置这两个选项值来指定函数名称。 + +启动函数文件应防止在 Vim &runtimepath 的 autoload 文件夹内。例如: + +文件名: `~/.SpaceVim.d/autoload/myspacevim.vim` + +```vim +func! myspacevim#before() abort + let g:neomake_enabled_c_makers = ['clang'] + nnoremap jk +endf + +func! myspacevim#after() abort + iunmap jk +endf +``` + +函数 `bootstrap_before` 将在读取用户配置后执行,而函数 `bootstrap_after` 将在 VimEnter autocmd 之后执行。 + ### Vim 兼容模式 以下为 SpaceVim 中与 Vim 默认情况下的一些差异,而在兼容模式下, diff --git a/docs/documentation.md b/docs/documentation.md index 5a1773f53..60b487965 100644 --- a/docs/documentation.md +++ b/docs/documentation.md @@ -253,6 +253,9 @@ func! myspacevim#after() abort endf ``` +the `bootstrap_before` will be called after custom configuration file is loaded. and the `bootstrap_after` will +be called after VimEnter autocmd. + ### Vim Compatible Mode This a list of different key bindings between SpaceVim and origin vim. If you still want to use this origin function, you can enable vimcompatible mode, via `vimcompatible = true` in `[options]` section.