The configuration Spacevim mainly includes the following content:
- Set Spacevim options
- Start/Disable Module
- Add custom plug-ins
- Add custom key mapping and plug-in configuration
Set Spacevim options
Originally, in the Init.vim file, we can let g:spacevim_*
set the SPACEVIM option by this statement. In the new version of Spacevim,
We use the TOML as the default configuration file, if you are unfamiliar with toml syntax, you can read the basic syntax of TOML, of course, do not read it is okay,
TOML is already the simplest configuration file format.
All Spacevim options are configured in a dictionary, and key removes the prefix for the original option name g:spacevim_
:
g:spacevim_enable_guicolors
-enable_guicolors
The value of this option can be true
either false
, so the write configuration is:
[options] enable_guicolors = false
Some other options, some of which are numbers, strings, strings formatted like Vim script, can be in single quotes or double quotes, such as:
[options] enable_guicolors = false snippet_engine = "neosnippet" statusline_separator = ‘arrow‘ sidebar_width = 30
Enable/disable module
Spacevim has built-in modules, each of which consists of plug-ins and related configurations to provide specific functions, such as a fuzzy search module,
Provides version-controlled modules, as well as language modules that provide language development support.
To enable or disable the module, you need to follow a certain syntax structure, and to be in the layers list, such as I now need to enable Shell module, set module options
default_position
And default_height
, these two options control the Shell window opening position and height, respectively:
[[layers]] name = "shell" default_position = "top" default_height = 30
If you want to disable a module, you need to add an option enable
and assign a value false
, which is the default true
. For example, I need to disable the Shell module,
As you can write, when you disable a module, enable
other options can be written without writing, as it will not take effect. Of course, if you want to enable/disable the module quickly,
You can keep other options intact.
[[layers]] name = "shell" enable = false
Add custom plug-ins
Custom plug-in configuration syntax and modules are a bit similar, will need to configure the plug-in, configuration into the custom_plugins
list. For example, I need to add 2 plugins,
You can refer to the following syntax:
[[custom_plugins]] name = "lilydjwg/colorizer" merged = 0[[custom_plugins]] name = "tpope/vim-scriptease" merged = 0 on_cmd = "Scriptnames"
As you can see, we support many options when adding custom plugins, thanks to Dein, Dein supports the following common
Options:
Option |
Type |
Description |
name |
string |
A name for the plugin. If It is omitted, the tail of the repository name would be used |
rev |
string |
The revision number or Branch/tag name for the repo |
build |
string |
Command to run after the plugin is installed |
on_ft |
string Orlist |
Load a plugin for the current filetype |
on_cmd |
string Orlist |
Load The plugin for these commands |
rtp |
string |
You can use it when the repository have the Vim plugin in a subdirectory |
if |
string Ornumber |
If It is a String, Dein'll eval it. |
merged |
number |
If set to 0, Dein doesn ' t merge the plugin directory. |
custom shortcut keys and plug-in configuration
Finally, let's say, if you add custom configurations, and customize shortcut keys. When configuring Spacevim with TOML, we offer two options, located [options]
under:
bootstrap_before
And bootstrap_after
, these two options accept a string that is the most valued, and that the string is worth a vim method name. As the name implies, you can pass this
Two options define two Vim methods, which are called when the configuration is loaded, and when Vim is started, within the method, you can add some vim scripts, such as shortcut keys,
such as plug-in options.
For example, add the following to the configuration file:
[options] enable_guicolors = false snippet_engine = "neosnippet" statusline_separator = ‘arrow‘ sidebar_width = 30 bootstrap_before = "myspacevim#before"
New ~/.SpaceVim.d/autoload/myspacevim.vim
, adding content:
func! myspacevim#before() abort let g:neomake_enabled_c_makers = [‘clang‘] nnoremap jk <esc>endf
How to configure Spacevim with TOML