1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-04-07 21:36:19 +08:00

Compare commits

..

No commits in common. "2d6abfdb7b91e3d5a998d19414a9909a30d68469" and "bf643b2463b4219b370fdce28976aa0840469144" have entirely different histories.

4 changed files with 12 additions and 28 deletions

View File

@ -28,9 +28,7 @@ if has('nvim-0.10.0')
if !empty(get(g:, '_spacevim_bootstrap_after', '')) if !empty(get(g:, '_spacevim_bootstrap_after', ''))
function! s:bootstrap_after(...) abort function! s:bootstrap_after(...) abort
try try
call SpaceVim#logger#info('run bootstrap_after function:' . g:_spacevim_bootstrap_after)
call call(g:_spacevim_bootstrap_after, []) call call(g:_spacevim_bootstrap_after, [])
call SpaceVim#logger#info('bootstrap_after function was called successfully.')
let g:_spacevim_bootstrap_after_success = 1 let g:_spacevim_bootstrap_after_success = 1
catch catch
call SpaceVim#logger#error('failed to call bootstrap_after function: ' . g:_spacevim_bootstrap_after) call SpaceVim#logger#error('failed to call bootstrap_after function: ' . g:_spacevim_bootstrap_after)
@ -90,9 +88,7 @@ else
call SpaceVim#plugins#projectmanager#RootchandgeCallback() call SpaceVim#plugins#projectmanager#RootchandgeCallback()
if !empty(get(g:, '_spacevim_bootstrap_after', '')) if !empty(get(g:, '_spacevim_bootstrap_after', ''))
try try
call SpaceVim#logger#info('run bootstrap_after function:' . g:_spacevim_bootstrap_after)
call call(g:_spacevim_bootstrap_after, []) call call(g:_spacevim_bootstrap_after, [])
call SpaceVim#logger#info('bootstrap_after function was called successfully.')
let g:_spacevim_bootstrap_after_success = 1 let g:_spacevim_bootstrap_after_success = 1
catch catch
call SpaceVim#logger#error('failed to call bootstrap_after function: ' . g:_spacevim_bootstrap_after) call SpaceVim#logger#error('failed to call bootstrap_after function: ' . g:_spacevim_bootstrap_after)

View File

@ -282,9 +282,7 @@ function! s:apply(config, type) abort
if !empty(bootstrap_before) if !empty(bootstrap_before)
try try
call SpaceVim#logger#info('run bootstrap_before function:' . bootstrap_before)
call call(bootstrap_before, []) call call(bootstrap_before, [])
call SpaceVim#logger#info('bootstrap_before function was called successfully.')
let g:_spacevim_bootstrap_before_success = 1 let g:_spacevim_bootstrap_before_success = 1
catch catch
call SpaceVim#logger#error('bootstrap_before function failed: ' call SpaceVim#logger#error('bootstrap_before function failed: '

View File

@ -289,8 +289,8 @@ SpaceVim 默认安装了一些插件,如果需要禁用某个插件,可以
### 启动函数 ### 启动函数
由于 toml 语法的局限性SpaceVim 提供了两种启动函数选项 `bootstrap_before``bootstrap_after`这两个选项分别指定两个 Vim 自定义函数 由于 toml 配置的局限性SpaceVim 提供了两种启动函数 `bootstrap_before``bootstrap_after`在该函数内可以使用 Vim script
以在 toml 配置文件 `~/.SpaceVim.d/init.toml``[options]` 字段中设置这两个选项 `bootstrap_before``bootstrap_after` 对应的函数名称,例如: 通过 `~/.SpaceVim.d/init.toml``[options]` 片段中的这两个选项 `bootstrap_before``bootstrap_after` 来指定函数名称,例如:
```toml ```toml
[options] [options]
@ -298,13 +298,10 @@ SpaceVim 默认安装了一些插件,如果需要禁用某个插件,可以
bootstrap_after = "myspacevim#after" bootstrap_after = "myspacevim#after"
``` ```
这两种启动函数的区别在于,`bootstrap_before` 函数是在载入用户配置时候执行的, 这两种启动函数的区别在于,`bootstrap_before`函数是在载入用户配置时候执行的,
`bootstrap_after` 函数是在触发 `VimEnter` 事件时执行的。因此,可以在 `bootstrap_after` `bootstrap_after`函数是在触发`VimEnter`事件时执行的。
函数内对默认的快捷键进行修改。
下面展示一个启动函数的示例,包含 `bootstrap_before``bootstrap_after` 两个函数: 启动函数文件应放置在 Vim &runtimepath 的 autoload 文件夹内。例如:
定义启动函数的 Vim 脚本文件应放置在 Vim &runtimepath 的 autoload 文件夹内。例如:
文件名:`~/.SpaceVim.d/autoload/myspacevim.vim` 文件名:`~/.SpaceVim.d/autoload/myspacevim.vim`
@ -315,10 +312,7 @@ function! myspacevim#before() abort
endfunction endfunction
function! myspacevim#after() abort function! myspacevim#after() abort
" 删除默认快捷键 <F3>, 该快捷键原先设定为打开文件树 iunmap jk
unmap <F3>
" 设定新的快捷打开文件树, 在这里假定文件树插件选择的是 defx.nvim
nnoremap <silent> <F3> :Defx<Cr>
endfunction endfunction
``` ```

View File

@ -282,11 +282,11 @@ you can use SpaceVim `disabled_plugins` in the `[options]` section of your confi
### Bootstrap Functions ### Bootstrap Functions
Due to the limitations of toml syntax, SpaceVim provides two bootstrap function options SpaceVim provides two kinds of bootstrap functions
`bootstrap_before` and `bootstrap_after`, which specify two Vim custom functions. for custom configurations and key bindings,
namely `bootstrap_before` and `bootstrap_after`.
To enable this feature you need to add the following config to the `[options]` section of your To enable them you need to add the following into lines to the `[options]` section of your configuration file.
configuration file `~/.SpaceVim.d/init.toml`.
```toml ```toml
[options] [options]
@ -295,8 +295,7 @@ configuration file `~/.SpaceVim.d/init.toml`.
``` ```
The difference is that the bootstrap before function will be called before SpaceVim core, The difference is that the bootstrap before function will be called before SpaceVim core,
and the bootstrap after function is called on autocmd `VimEnter`, so you can override defaults and the bootstrap after function is called on autocmd `VimEnter`.
key bindings in `bootstrap_after` function.
The bootstrap functions should be placed in the `autoload` directory The bootstrap functions should be placed in the `autoload` directory
in `~/.SpaceVim.d/`. In our case, create file `~/.SpaceVim.d/autoload/myspacevim.vim` in `~/.SpaceVim.d/`. In our case, create file `~/.SpaceVim.d/autoload/myspacevim.vim`
@ -312,10 +311,7 @@ endfunction
function! myspacevim#after() abort function! myspacevim#after() abort
" you can remove key binding in bootstrap_after function " you can remove key binding in bootstrap_after function
" for example, remove F3 which is to open file tree by default. iunmap kj
unmap <F3>
" create new key binding to open file tree.
nnoremap <silent> <F3> :Defx<Cr>
endfunction endfunction
``` ```