From d064660bc189c8b86b15039e5d9bfabbce25db44 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 24 Dec 2024 10:56:21 +0800 Subject: [PATCH] docs(bootstrap): update doc of bootstrap functions --- docs/cn/documentation.md | 18 ++++++++++++------ docs/documentation.md | 16 ++++++++++------ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/docs/cn/documentation.md b/docs/cn/documentation.md index 0a84828af..70ab69dea 100644 --- a/docs/cn/documentation.md +++ b/docs/cn/documentation.md @@ -289,8 +289,8 @@ SpaceVim 默认安装了一些插件,如果需要禁用某个插件,可以 ### 启动函数 -由于 toml 配置的局限性,SpaceVim 提供了两种启动函数 `bootstrap_before` 和 `bootstrap_after`,在该函数内可以使用 Vim script。 -可通过 `~/.SpaceVim.d/init.toml` 的 `[options]` 片段中的这两个选项 `bootstrap_before` 和 `bootstrap_after` 来指定函数名称,例如: +由于 toml 语法的局限性,SpaceVim 提供了两种启动函数选项 `bootstrap_before` 和 `bootstrap_after`,这两个选项分别指定两个 Vim 自定义函数。 +可以在 toml 配置文件 `~/.SpaceVim.d/init.toml` 的 `[options]` 字段中设置这两个选项 `bootstrap_before` 和 `bootstrap_after` 对应的函数名称,例如: ```toml [options] @@ -298,10 +298,13 @@ SpaceVim 默认安装了一些插件,如果需要禁用某个插件,可以 bootstrap_after = "myspacevim#after" ``` -这两种启动函数的区别在于,`bootstrap_before`函数是在载入用户配置时候执行的, -而`bootstrap_after`函数是在触发`VimEnter`事件时执行的。 +这两种启动函数的区别在于,`bootstrap_before` 函数是在载入用户配置时候执行的, +而 `bootstrap_after` 函数是在触发 `VimEnter` 事件时执行的。因此,可以在 `bootstrap_after` +函数内对默认的快捷键进行修改。 -启动函数文件应放置在 Vim &runtimepath 的 autoload 文件夹内。例如: +下面展示一个启动函数的示例,包含 `bootstrap_before` 和 `bootstrap_after` 两个函数: + +定义启动函数的 Vim 脚本文件应放置在 Vim &runtimepath 的 autoload 文件夹内。例如: 文件名:`~/.SpaceVim.d/autoload/myspacevim.vim` @@ -312,7 +315,10 @@ function! myspacevim#before() abort endfunction function! myspacevim#after() abort - iunmap jk + " 删除默认快捷键 , 该快捷键原先设定为打开文件树 + unmap + " 设定新的快捷打开文件树, 在这里假定文件树插件选择的是 defx.nvim + nnoremap :Defx endfunction ``` diff --git a/docs/documentation.md b/docs/documentation.md index fe9d97647..2e78022c7 100644 --- a/docs/documentation.md +++ b/docs/documentation.md @@ -282,11 +282,11 @@ you can use SpaceVim `disabled_plugins` in the `[options]` section of your confi ### Bootstrap Functions -SpaceVim provides two kinds of bootstrap functions -for custom configurations and key bindings, -namely `bootstrap_before` and `bootstrap_after`. +Due to the limitations of toml syntax, SpaceVim provides two bootstrap function options +`bootstrap_before` and `bootstrap_after`, which specify two Vim custom functions. -To enable them you need to add the following into lines to the `[options]` section of your configuration file. +To enable this feature you need to add the following config to the `[options]` section of your +configuration file `~/.SpaceVim.d/init.toml`. ```toml [options] @@ -295,7 +295,8 @@ To enable them you need to add the following into lines to the `[options]` secti ``` The difference is that the bootstrap before function will be called before SpaceVim core, -and the bootstrap after function is called on autocmd `VimEnter`. +and the bootstrap after function is called on autocmd `VimEnter`, so you can override defaults +key bindings in `bootstrap_after` function. The bootstrap functions should be placed in the `autoload` directory in `~/.SpaceVim.d/`. In our case, create file `~/.SpaceVim.d/autoload/myspacevim.vim` @@ -311,7 +312,10 @@ endfunction function! myspacevim#after() abort " you can remove key binding in bootstrap_after function - iunmap kj + " for example, remove F3 which is to open file tree by default. + unmap + " create new key binding to open file tree. + nnoremap :Defx endfunction ```