1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 10:40:03 +08:00
SpaceVim/docs/development.md

365 lines
12 KiB
Markdown
Raw Normal View History

2017-02-12 16:36:17 +08:00
---
title: "Development"
2018-01-21 15:54:26 +08:00
description: "General contributing guidelines and changelog of SpaceVim, including development information about SpaceVim"
2017-02-12 16:36:17 +08:00
---
2019-10-14 23:29:07 +08:00
# [Home](../) >> Development
2017-02-07 01:51:23 +08:00
2017-12-09 13:33:16 +08:00
<!-- vim-markdown-toc GFM -->
2017-03-02 20:17:13 +08:00
2018-01-21 15:54:26 +08:00
- [Asking for help](#asking-for-help)
- [Reporting issues](#reporting-issues)
- [Contributing code](#contributing-code)
- [License](#license)
- [Conventions](#conventions)
2021-01-01 16:18:31 +08:00
- [Git commit style guide](#git-commit-style-guide)
- [types](#types)
- [scopes](#scopes)
- [subject](#subject)
- [body](#body)
- [footer](#footer)
2018-01-21 15:54:26 +08:00
- [Pull Request](#pull-request)
2018-06-20 21:22:35 +08:00
- [Title prefix of pull request](#title-prefix-of-pull-request)
- [Rebase on top of upstream master](#rebase-on-top-of-upstream-master)
- [Ideally for simple PRs](#ideally-for-simple-prs)
- [For complex PRs](#for-complex-prs)
2018-01-21 15:54:26 +08:00
- [Contributing a layer](#contributing-a-layer)
- [File header](#file-header)
- [Author of a new layer](#author-of-a-new-layer)
- [Contributor to an existing layer](#contributor-to-an-existing-layer)
2017-12-09 13:33:16 +08:00
- [Contributing a keybinding](#contributing-a-keybinding)
2018-01-21 15:54:26 +08:00
- [Language specified key bindings](#language-specified-key-bindings)
2017-12-09 13:33:16 +08:00
- [Contributing a banner](#contributing-a-banner)
2017-03-02 22:20:46 +08:00
- [Build with SpaceVim](#build-with-spacevim)
2020-12-13 17:49:11 +08:00
- [Newsletters](#newsletters)
2017-03-02 22:20:46 +08:00
- [Changelog](#changelog)
2017-03-02 20:17:13 +08:00
2017-12-09 13:33:16 +08:00
<!-- vim-markdown-toc -->
2019-01-22 07:50:55 +08:00
SpaceVim is an effort of all the volunteers. We encourage you to pitch in. The community makes SpaceVim what it is.
We have a few guidelines which we need all contributors to follow.
2018-01-21 15:54:26 +08:00
2017-03-02 20:17:13 +08:00
You can only consider reading the sections relevant to what you are going to do:
- [Asking for help](#asking-for-help) if you are about to open an issue to ask a question.
- [Reporting issues](#reporting-issues) if you are about to open a new issue.
- [Contributing code](#contributing-code) if you are about to send a pull-request.
2017-03-02 20:17:13 +08:00
2018-01-21 15:54:26 +08:00
## Asking for help
2017-03-02 20:17:13 +08:00
If you want to ask an usage question, be sure to look first into some places as it may hold the answers:
2017-12-09 13:33:16 +08:00
2017-03-02 22:20:46 +08:00
- <kbd>:h SpaceVim-faq</kbd>: Some of the most frequently asked questions are answered there.
2018-06-20 21:22:35 +08:00
- [SpaceVim documentation](https://spacevim.org/documentation/): It is the general documentation of SpaceVim.
2017-03-02 20:17:13 +08:00
2018-01-21 15:54:26 +08:00
## Reporting issues
2017-03-02 20:17:13 +08:00
2019-01-22 07:50:55 +08:00
Issues have to be reported on [issues tracker](https://github.com/SpaceVim/SpaceVim/issues), please:
2017-12-09 13:33:16 +08:00
2019-01-22 07:50:55 +08:00
- Check that no duplicate issue is in the issues tracker, you can search for keywords in the issues tracker.
2017-03-02 20:17:13 +08:00
- Check that the issue has not been fixed in latest version of SpaceVim, please update your SpaceVim, and try to reproduce the bug here.
- Use a clear title and follow the issue template.
- Include details on how to reproduce it, just like a step by step guide.
2018-01-21 15:54:26 +08:00
## Contributing code
2017-03-02 20:17:13 +08:00
2021-01-01 16:18:31 +08:00
Code contributions are welcome. Please read the following sections carefully.
In any case, feel free to join us on the [gitter chat](https://gitter.im/SpaceVim/SpaceVim) to ask questions about contributing!
2017-02-25 21:23:27 +08:00
2018-01-21 15:54:26 +08:00
### License
2017-02-07 01:51:23 +08:00
2019-01-22 07:50:55 +08:00
The license is GPLv3 for all the parts of SpaceVim. This includes:
2017-12-09 13:33:16 +08:00
2018-02-15 22:25:03 +08:00
- The initialization and core files.
2017-03-02 22:20:46 +08:00
- All the layer files.
2018-02-15 22:25:03 +08:00
- The documentation
2017-02-07 01:51:23 +08:00
2021-01-01 16:18:31 +08:00
For files not belonging to SpaceVim like local packages and libraries,
refer to the header file. Those files should not have an empty header, we may not accept code without a proper header file.
2017-03-02 22:20:46 +08:00
2021-01-01 16:18:31 +08:00
### Conventions
2021-01-01 16:18:31 +08:00
SpaceVim is based on conventions, mainly for naming functions,
keybindings definition and writing documentation.
Please read the [conventions](https://spacevim.org/conventions/) before your first contribution to get to know them.
2021-01-01 16:18:31 +08:00
### Git commit style guide
A git commit message consists a three distinct parts separated by black line.
```
Type (scope): Subject
body
footer
```
#### types
- `feat`: A new feature
- `fix`: A bug fix
- `docs`: Changes to documentation
- `style`: Formatting, missing semi colons, etc; no code change
- `refactor`: Refactoring production code
- `test`: Adding tests, refactoring test; no production code change
- `chore`: Updating build tasks, package manager configs, etc; no production code change
#### scopes
- `layer`
- `api`
- `plugin`
#### subject
Subjects should be no greater than 50 characters,
should begin with a capital letter and do not end with a period.
Use an imperative tone to describe what a commit does,
rather than what it did. For example, use change; not changed or changes.
#### body
Not all commits are complex enough to warrant a body body,
therefore it is optional and only used when a commit requires a bit of explanation and context.
#### footer
The footer is optional and is used to reference issue tracker IDs.
2017-03-02 22:20:46 +08:00
2018-01-21 15:54:26 +08:00
### Pull Request
2018-06-20 21:22:35 +08:00
#### Title prefix of pull request
2019-01-08 11:47:28 +08:00
Pull request titles should contain one of these prefix:
2018-06-20 21:22:35 +08:00
2019-02-23 08:18:06 +08:00
- `Add:` Adding new features.
2018-06-20 21:22:35 +08:00
- `Change:` Change default behaviors or the existing features.
2019-02-23 08:18:06 +08:00
- `Fix:` Fix some bugs.
- `Remove:` Remove some existing features.
- `Doc:` Update the help files.
- `Website:` Update the content of website.
2018-06-20 21:22:35 +08:00
2019-01-08 11:47:28 +08:00
Here is an example:
2018-06-20 21:22:35 +08:00
2019-01-22 07:50:55 +08:00
`Website: Update the lang#c layer page.`
2018-06-20 21:22:35 +08:00
#### Rebase on top of upstream master
2017-03-02 22:20:46 +08:00
2019-01-22 07:50:55 +08:00
- Fork SpaceVim repository
- Clone your repository
2018-01-21 15:54:26 +08:00
```sh
git clone ${YOUR_OWN_REPOSITORY_URL}
```
2019-01-22 07:50:55 +08:00
- Add upstream remote
2018-01-21 15:54:26 +08:00
```sh
git remote add upstream https://github.com/SpaceVim/SpaceVim.git
```
2017-03-02 22:20:46 +08:00
2019-01-22 07:50:55 +08:00
- Fetch upstream and rebase on top of upstream master
2018-01-21 15:54:26 +08:00
```sh
git fetch upstream
2019-01-08 11:47:28 +08:00
git rebase upstream/master
2018-01-21 15:54:26 +08:00
```
2018-06-20 21:22:35 +08:00
#### Ideally for simple PRs
2017-03-02 22:20:46 +08:00
2018-01-20 16:39:54 +08:00
- Branch from `master`
2017-03-02 22:20:46 +08:00
- One topic per PR
- One commit per PR
- If you have several commits on different topics, close the PR and create one PR per topic
- If you still have several commits, squash them into only one commit
2018-06-20 21:22:35 +08:00
#### For complex PRs
2017-03-02 22:20:46 +08:00
2021-01-01 16:18:31 +08:00
Squash only the commits with uninteresting changes like typos, syntax fixes, etc.
And keep the important and isolated steps in different commits.
2017-03-02 22:20:46 +08:00
Those PRs are merged and explicitly not fast-forwarded.
2018-01-20 16:39:54 +08:00
2018-01-21 15:54:26 +08:00
### Contributing a layer
2017-03-02 22:20:46 +08:00
Please read the layers documentation first.
2019-01-22 07:50:55 +08:00
Layer with no associated configuration will be rejected. For instance a layer with just a package and a hook can be easily replaced by the usage of the variable `custom_plugins`.
2017-03-02 22:20:46 +08:00
2018-01-21 15:54:26 +08:00
#### File header
2017-03-02 22:20:46 +08:00
2019-01-22 07:50:55 +08:00
The file header for Vim script should look like the following template:
2017-03-02 22:20:46 +08:00
2019-01-22 07:50:55 +08:00
```vim
2017-03-02 22:20:46 +08:00
"=============================================================================
" FILENAME --- NAME layer file for SpaceVim
2020-08-31 21:24:27 +08:00
" Copyright (c) 2016-2020 Wang Shidong & Contributors
2019-06-09 14:11:17 +08:00
" Author: Wang Shidong < wsdjeg@outlook.com >
2017-03-02 22:20:46 +08:00
" URL: https://spacevim.org
2018-02-15 22:25:03 +08:00
" License: GPLv3
2017-03-02 22:20:46 +08:00
"=============================================================================
```
2019-01-22 07:50:55 +08:00
You should replace FILENAME by the name of the file (e.g. foo.vim) and NAME by the name of the layer you are creating, dont forget to replace **YOUR NAME** and **YOUR EMAIL** neighter.
2017-03-02 22:20:46 +08:00
2018-01-21 15:54:26 +08:00
#### Author of a new layer
2017-03-02 22:20:46 +08:00
2019-01-22 07:50:55 +08:00
In the files header, replace the default author name (Shidong Wang) with your name.
2017-03-02 22:20:46 +08:00
2019-01-22 07:50:55 +08:00
The following example shows how to create a new layer names `foo`:
2017-02-10 22:05:19 +08:00
2019-01-22 07:50:55 +08:00
1. Fork SpaceVim repo.
2. Add a layer file `autoload/SpaceVim/layers/foo.vim` for `foo` layer.
3. Edit layer file, check out the example below:
2017-02-10 22:05:19 +08:00
```vim
2017-03-02 22:20:46 +08:00
"=============================================================================
" foo.vim --- foo Layer file for SpaceVim
" Copyright (c) 2012-2016 Shidong Wang & Contributors
" Author: Shidong Wang < wsdjeg at 163.com >
" URL: https://spacevim.org
2018-02-15 22:25:03 +08:00
" License: GPLv3
2017-03-02 22:20:46 +08:00
"=============================================================================
""
" @section foo, layer-foo
" @parentsection layers
" This the doc for this layer:
"
2018-01-03 23:14:15 +08:00
" @subsection Key Bindings
2017-03-02 22:20:46 +08:00
" >
" Mode Key Function
" -------------------------------------------------------------
" normal <leader>jA generate accessors
" normal <leader>js generate setter accessor
" <
2018-01-03 23:14:15 +08:00
" @subsection Layer options
2017-03-02 22:20:46 +08:00
" >
" Name Description Default
" -------------------------------------------------------------
2018-01-03 23:14:15 +08:00
" option1 Set option1 for foo layer ''
" option2 Set option2 for foo layer []
" option3 Set option3 for foo layer {}
" <
" @subsection Global options
" >
" Name Description Default
" -------------------------------------------------------------
" g:pluginA_opt1 Set opt1 for plugin A ''
" g:pluginB_opt2 Set opt2 for plugin B []
2017-03-02 22:20:46 +08:00
" <
2017-02-10 22:05:19 +08:00
function! SpaceVim#layers#foo#plugins() abort
2017-03-02 22:20:46 +08:00
let plugins = []
call add(plugins, ['Shougo/foo.vim', {'option' : 'value'}])
call add(plugins, ['Shougo/foo_test.vim', {'option' : 'value'}])
return plugins
2017-02-10 22:05:19 +08:00
endfunction
function! SpaceVim#layers#foo#config() abort
2017-03-02 22:20:46 +08:00
let g:foo_option1 = get(g:, 'foo_option1', 1)
let g:foo_option2 = get(g:, 'foo_option2', 2)
let g:foo_option3 = get(g:, 'foo_option3', 3)
" ...
2017-02-10 22:05:19 +08:00
endfunction
2019-09-12 12:24:05 +08:00
" add layer options:
let s:layer_option = 'default var'
function! SpaceVim#layers#foo#set_variable(var) abort
let s:layer_option = get(a:var, 'layer_option', s:layer_option)
endfunction
" completion function for layer options:
function! SpaceVim#layers#foo#get_options() abort
return ['layer_option']
endfunction
2017-02-10 22:05:19 +08:00
```
2018-01-03 23:14:15 +08:00
4. Add layer document `docs/layers/foo.md` for `foo` layer.
5. Open `docs/layers/index.md`, run `:call SpaceVim#dev#layers#update()` to update layer list.
2019-01-22 07:50:55 +08:00
6. Send PR to SpaceVim.
2017-02-12 19:21:46 +08:00
2018-01-21 15:54:26 +08:00
#### Contributor to an existing layer
2017-03-02 22:20:46 +08:00
2019-01-22 07:50:55 +08:00
If you want to contribute to an already existing layer, you should not modify any header file.
2017-03-02 22:20:46 +08:00
#### Contributing a keybinding
Mappings are an important part of SpaceVim.
2019-01-22 07:50:55 +08:00
First if you want to have some personal mappings. This can be done in your bootstrap function.
2017-03-02 22:20:46 +08:00
2019-01-22 07:50:55 +08:00
If you think it worth contributing new mappings, be sure to read the documentation to find the best mappings, then create a Pull-Request with your mappings.
2017-03-02 22:20:46 +08:00
ALWAYS document your new mappings or mappings changes inside the relevant documentation file.
2019-01-22 07:50:55 +08:00
It should be the layername.md and the [documentation](../documentation/).
2017-03-02 22:20:46 +08:00
2018-01-21 15:54:26 +08:00
##### Language specified key bindings
2018-01-02 20:00:16 +08:00
2019-01-22 07:50:55 +08:00
All language specified key bindings prefix `SPC l`.
2018-01-02 20:00:16 +08:00
2019-01-22 07:50:55 +08:00
We recommend to keep same language specified key bindings for different languages:
2018-01-02 20:00:16 +08:00
| Key Binding | Description |
| ----------- | ------------------------------------------------ |
| `SPC l r` | start a runner for current file |
| `SPC l e` | rename symbol |
| `SPC l d` | show doc |
| `SPC l i r` | remove unused imports |
| `SPC l i s` | sort imports with isort |
| `SPC l s i` | Start a language specified inferior REPL process |
| `SPC l s b` | send buffer and keep code buffer focused |
| `SPC l s l` | send line and keep code buffer focused |
| `SPC l s s` | send selection text and keep code buffer focused |
2018-01-02 20:00:16 +08:00
2019-01-22 07:50:55 +08:00
All above key bindings are just recommended as default, but they also base on the language layer itself.
2018-01-04 12:18:19 +08:00
2017-03-02 22:20:46 +08:00
#### Contributing a banner
The startup banner is by default the SpaceVim logo but there are also ASCII banners available in the core/banner layer.
If you have some ASCII skills you can submit your artwork!
You are free to choose a reasonable height size but the width size should be around 75 characters.
2017-02-14 23:15:22 +08:00
## Build with SpaceVim
2019-01-22 07:50:55 +08:00
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.
2017-02-14 23:15:22 +08:00
![](https://img.shields.io/badge/build%20with-SpaceVim-ff69b4.svg)
markdown
2017-02-15 23:56:04 +08:00
2017-02-14 23:15:22 +08:00
```md
2017-02-15 23:56:04 +08:00
[![](https://spacevim.org/img/build-with-SpaceVim.svg)](https://spacevim.org)
2017-02-14 23:15:22 +08:00
```
2020-12-13 17:49:11 +08:00
## Newsletters
<ul>
{% for post in site.categories.newsletter %}
<li>
<h3><a href="{{ post.url }}">{{ post.title }}</a></h3>
<span class="post-date">{{ post.date | date_to_string }}</span>
<p>{{ post.description | truncatewords: 100 }}</p>
</li>
{% endfor %}
</ul>
2017-02-12 19:21:46 +08:00
## Changelog
<ul>
2017-02-12 19:36:33 +08:00
{% for post in site.categories.changelog %}
2017-02-12 19:21:46 +08:00
<li>
2018-05-27 20:54:33 +08:00
<h3><a href="{{ post.url }}">{{ post.title }}</a></h3>
<span class="post-date">{{ post.date | date_to_string }}</span>
2020-05-10 14:05:04 +08:00
<p>{{ post.description | truncatewords: 100 }}</p>
2017-02-12 19:21:46 +08:00
</li>
{% endfor %}
</ul>