mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-02-03 03:50:04 +08:00
Add coverage commands for python (#2866)
This commit is contained in:
parent
88340e285b
commit
6f31fa3f15
@ -34,6 +34,8 @@ function! SpaceVim#layers#lang#python#plugins() abort
|
|||||||
\ { 'on_ft' : 'python'}])
|
\ { 'on_ft' : 'python'}])
|
||||||
call add(plugins, ['jeetsukumaran/vim-pythonsense',
|
call add(plugins, ['jeetsukumaran/vim-pythonsense',
|
||||||
\ { 'on_ft' : 'python'}])
|
\ { 'on_ft' : 'python'}])
|
||||||
|
call add(plugins, ['alfredodeza/coveragepy.vim',
|
||||||
|
\ { 'merged' : 0}])
|
||||||
return plugins
|
return plugins
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@ -102,6 +104,24 @@ function! s:language_specified_mappings() abort
|
|||||||
\ 'call SpaceVim#plugins#repl#send("selection")',
|
\ 'call SpaceVim#plugins#repl#send("selection")',
|
||||||
\ 'send selection and keep code buffer focused', 1)
|
\ 'send selection and keep code buffer focused', 1)
|
||||||
|
|
||||||
|
let g:_spacevim_mappings_space.l.c = {'name' : '+Coverage'}
|
||||||
|
|
||||||
|
call SpaceVim#mapping#space#langSPC('nmap', ['l','c', 'r'],
|
||||||
|
\ 'Coveragepy report',
|
||||||
|
\ 'coverager eport', 1)
|
||||||
|
|
||||||
|
call SpaceVim#mapping#space#langSPC('nmap', ['l','c', 's'],
|
||||||
|
\ 'Coveragepy show',
|
||||||
|
\ 'coverager show', 1)
|
||||||
|
|
||||||
|
call SpaceVim#mapping#space#langSPC('nmap', ['l','c', 'e'],
|
||||||
|
\ 'Coveragepy session',
|
||||||
|
\ 'coverager session', 1)
|
||||||
|
|
||||||
|
call SpaceVim#mapping#space#langSPC('nmap', ['l','c', 'f'],
|
||||||
|
\ 'Coveragepy refresh',
|
||||||
|
\ 'coverager refresh', 1)
|
||||||
|
|
||||||
" +Generate {{{
|
" +Generate {{{
|
||||||
|
|
||||||
let g:_spacevim_mappings_space.l.g = {'name' : '+Generate'}
|
let g:_spacevim_mappings_space.l.g = {'name' : '+Generate'}
|
||||||
|
@ -12,12 +12,11 @@ lang: cn
|
|||||||
- [功能特性](#功能特性)
|
- [功能特性](#功能特性)
|
||||||
- [依赖安装及启用模块](#依赖安装及启用模块)
|
- [依赖安装及启用模块](#依赖安装及启用模块)
|
||||||
- [启用模块](#启用模块)
|
- [启用模块](#启用模块)
|
||||||
- [语法检查](#语法检查)
|
- [语言工具](#语言工具)
|
||||||
- [代码格式化](#代码格式化)
|
|
||||||
- [格式化 Imports](#格式化-imports)
|
|
||||||
- [快捷键](#快捷键)
|
- [快捷键](#快捷键)
|
||||||
- [跳至定义处](#跳至定义处)
|
- [跳至定义处](#跳至定义处)
|
||||||
- [代码生成](#代码生成)
|
- [代码生成](#代码生成)
|
||||||
|
- [测试覆盖](#测试覆盖)
|
||||||
- [交互式编程](#交互式编程)
|
- [交互式编程](#交互式编程)
|
||||||
- [运行当前脚本](#运行当前脚本)
|
- [运行当前脚本](#运行当前脚本)
|
||||||
- [整理 imports](#整理-imports)
|
- [整理 imports](#整理-imports)
|
||||||
@ -48,7 +47,9 @@ lang: cn
|
|||||||
name = "lang#python"
|
name = "lang#python"
|
||||||
```
|
```
|
||||||
|
|
||||||
### 语法检查
|
### 语言工具
|
||||||
|
|
||||||
|
**语法检查:**
|
||||||
|
|
||||||
`checkers` 模块提供了代码检查功能, 此外需要安装 `flake8` 包:
|
`checkers` 模块提供了代码检查功能, 此外需要安装 `flake8` 包:
|
||||||
|
|
||||||
@ -56,7 +57,7 @@ lang: cn
|
|||||||
pip install --user flake8
|
pip install --user flake8
|
||||||
```
|
```
|
||||||
|
|
||||||
### 代码格式化
|
**代码格式化:**
|
||||||
|
|
||||||
默认的代码格式化快捷键为 `SPC b f`, 需要安装 `yapf`。若需要在保存文件时自动格式化该 Python 文件,需要设置 `format-on-save` 为 `true`。
|
默认的代码格式化快捷键为 `SPC b f`, 需要安装 `yapf`。若需要在保存文件时自动格式化该 Python 文件,需要设置 `format-on-save` 为 `true`。
|
||||||
|
|
||||||
@ -64,7 +65,7 @@ pip install --user flake8
|
|||||||
pip install --user yapf
|
pip install --user yapf
|
||||||
```
|
```
|
||||||
|
|
||||||
### 格式化 Imports
|
**格式化导包:**
|
||||||
|
|
||||||
若需要更便捷地删除未使用的 imports,需要安装 [autoflake](https://github.com/myint/autoflake):
|
若需要更便捷地删除未使用的 imports,需要安装 [autoflake](https://github.com/myint/autoflake):
|
||||||
|
|
||||||
@ -78,6 +79,16 @@ pip install --user autoflake
|
|||||||
pip install --user isort
|
pip install --user isort
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**测试覆盖:**
|
||||||
|
|
||||||
|
通过安装 coverage 可对代码测试覆盖情况进行统计:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pip install --user coverage
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## 快捷键
|
## 快捷键
|
||||||
|
|
||||||
### 跳至定义处
|
### 跳至定义处
|
||||||
@ -92,6 +103,16 @@ pip install --user isort
|
|||||||
| ------ | ----------- | -------------- |
|
| ------ | ----------- | -------------- |
|
||||||
| Normal | `SPC l g d` | 生成 docstring |
|
| Normal | `SPC l g d` | 生成 docstring |
|
||||||
|
|
||||||
|
### 测试覆盖
|
||||||
|
|
||||||
|
| 模式 | 快捷键 | 功能描述 |
|
||||||
|
| ------ | ----------- | ----------------- |
|
||||||
|
| normal | `SPC l c r` | coverager report |
|
||||||
|
| normal | `SPC l c s` | coverager show |
|
||||||
|
| normal | `SPC l c e` | coverager session |
|
||||||
|
| normal | `SPC l c f` | coverager refresh |
|
||||||
|
|
||||||
|
|
||||||
### 交互式编程
|
### 交互式编程
|
||||||
|
|
||||||
启动 `python` 或 `ipython` 交互进程,快捷键为: `SPC l s i`。如果存在可执行命令 `ipython`,
|
启动 `python` 或 `ipython` 交互进程,快捷键为: `SPC l s i`。如果存在可执行命令 `ipython`,
|
||||||
|
@ -10,13 +10,12 @@ description: "This layer is for Python development, provide autocompletion, synt
|
|||||||
- [Description](#description)
|
- [Description](#description)
|
||||||
- [Features](#features)
|
- [Features](#features)
|
||||||
- [Install](#install)
|
- [Install](#install)
|
||||||
- [Layer](#layer)
|
- [enable layer](#enable-layer)
|
||||||
- [Syntax Checking](#syntax-checking)
|
- [language tools](#language-tools)
|
||||||
- [Buffer formatting](#buffer-formatting)
|
|
||||||
- [Format imports](#format-imports)
|
|
||||||
- [Key bindings](#key-bindings)
|
- [Key bindings](#key-bindings)
|
||||||
- [Jump to definition](#jump-to-definition)
|
- [Jump to definition](#jump-to-definition)
|
||||||
- [Code generation](#code-generation)
|
- [Code generation](#code-generation)
|
||||||
|
- [Code Coverage](#code-coverage)
|
||||||
- [Text objects and motions](#text-objects-and-motions)
|
- [Text objects and motions](#text-objects-and-motions)
|
||||||
- [Inferior REPL process](#inferior-repl-process)
|
- [Inferior REPL process](#inferior-repl-process)
|
||||||
- [Running current script](#running-current-script)
|
- [Running current script](#running-current-script)
|
||||||
@ -36,7 +35,7 @@ This layer is for Python development.
|
|||||||
|
|
||||||
## Install
|
## Install
|
||||||
|
|
||||||
### Layer
|
### enable layer
|
||||||
|
|
||||||
To use this configuration layer, add following snippet to your custom configuration file.
|
To use this configuration layer, add following snippet to your custom configuration file.
|
||||||
|
|
||||||
@ -45,7 +44,10 @@ To use this configuration layer, add following snippet to your custom configurat
|
|||||||
name = "lang#python"
|
name = "lang#python"
|
||||||
```
|
```
|
||||||
|
|
||||||
### Syntax Checking
|
### language tools
|
||||||
|
|
||||||
|
|
||||||
|
**syntax checking:**
|
||||||
|
|
||||||
`checker` layer provide syntax checking feature, and for Python it uses `flake8` package:
|
`checker` layer provide syntax checking feature, and for Python it uses `flake8` package:
|
||||||
|
|
||||||
@ -53,7 +55,7 @@ To use this configuration layer, add following snippet to your custom configurat
|
|||||||
pip install --user flake8
|
pip install --user flake8
|
||||||
```
|
```
|
||||||
|
|
||||||
### Buffer formatting
|
**code formatting:**
|
||||||
|
|
||||||
The default key binding for formatting buffer is `SPC b f`, and you need to install `yapf`. To enable automatic buffer formatting on save, load this layer with setting `format-on-save` to `1`.
|
The default key binding for formatting buffer is `SPC b f`, and you need to install `yapf`. To enable automatic buffer formatting on save, load this layer with setting `format-on-save` to `1`.
|
||||||
|
|
||||||
@ -67,7 +69,7 @@ The default key binding for formatting buffer is `SPC b f`, and you need to inst
|
|||||||
pip install --user yapf
|
pip install --user yapf
|
||||||
```
|
```
|
||||||
|
|
||||||
### Format imports
|
**format imports:**
|
||||||
|
|
||||||
To be able to suppress unused imports easily, install [autoflake](https://github.com/myint/autoflake):
|
To be able to suppress unused imports easily, install [autoflake](https://github.com/myint/autoflake):
|
||||||
|
|
||||||
@ -81,6 +83,14 @@ To be able to sort your imports, install [isort](https://github.com/timothycrosl
|
|||||||
pip install --user isort
|
pip install --user isort
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**code coverage:**
|
||||||
|
|
||||||
|
To be able to show code coverage, install coverage.py
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pip install --user coverage
|
||||||
|
```
|
||||||
|
|
||||||
## Key bindings
|
## Key bindings
|
||||||
|
|
||||||
### Jump to definition
|
### Jump to definition
|
||||||
@ -95,6 +105,15 @@ pip install --user isort
|
|||||||
| ------ | ----------- | ------------------ |
|
| ------ | ----------- | ------------------ |
|
||||||
| normal | `SPC l g d` | Generate docstring |
|
| normal | `SPC l g d` | Generate docstring |
|
||||||
|
|
||||||
|
### Code Coverage
|
||||||
|
|
||||||
|
| Mode | Key Binding | Description |
|
||||||
|
| ------ | ----------- | ----------------- |
|
||||||
|
| normal | `SPC l c r` | coverager report |
|
||||||
|
| normal | `SPC l c s` | coverager show |
|
||||||
|
| normal | `SPC l c e` | coverager session |
|
||||||
|
| normal | `SPC l c f` | coverager refresh |
|
||||||
|
|
||||||
### Text objects and motions
|
### Text objects and motions
|
||||||
|
|
||||||
This layer contains vim-pythonsense which provides text objects and motions for Python classes, methods, functions, and doc strings.
|
This layer contains vim-pythonsense which provides text objects and motions for Python classes, methods, functions, and doc strings.
|
||||||
|
Loading…
Reference in New Issue
Block a user