mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 13:40:05 +08:00
Pythonenable typeinfo (#3088)
* Update * Add enable_typeinfo option close #2922
This commit is contained in:
parent
64a984b756
commit
3953214b6d
@ -58,7 +58,7 @@ function! SpaceVim#layers#lang#python#config() abort
|
||||
augroup end
|
||||
endif
|
||||
" }}}
|
||||
|
||||
let g:deoplete#sources#jedi#enable_typeinfo = s:enable_typeinfo
|
||||
call SpaceVim#plugins#runner#reg_runner('python',
|
||||
\ {
|
||||
\ 'exe' : function('s:getexe'),
|
||||
@ -164,19 +164,28 @@ function! s:go_to_def() abort
|
||||
endif
|
||||
endfunction
|
||||
|
||||
let s:format_on_save = 0
|
||||
let s:python_file_head = [
|
||||
\ '#!/usr/bin/env python',
|
||||
\ '# -*- coding: utf-8 -*-',
|
||||
\ '',
|
||||
\ ''
|
||||
\ ]
|
||||
let s:format_on_save = 0
|
||||
let s:python_file_head = [
|
||||
\ '#!/usr/bin/env python',
|
||||
\ '# -*- coding: utf-8 -*-',
|
||||
\ '',
|
||||
\ ''
|
||||
\ ]
|
||||
let s:enable_typeinfo = 0
|
||||
function! SpaceVim#layers#lang#python#set_variable(var) abort
|
||||
|
||||
let s:format_on_save = get(a:var,
|
||||
\ 'format_on_save',
|
||||
\ get(a:var,
|
||||
\ 'format-on-save',
|
||||
\ 0)
|
||||
\ s:format_on_save))
|
||||
let s:python_file_head = get(a:var,
|
||||
\ 'python_file_head',
|
||||
\ get(a:var,
|
||||
\ 'python-file-head',
|
||||
\ s:python_file_head)
|
||||
\ s:python_file_head))
|
||||
let s:enable_typeinfo = get(a:var,
|
||||
\ 'enable_typeinfo',
|
||||
\ s:enable_typeinfo
|
||||
\ )
|
||||
endfunction
|
||||
|
@ -60,7 +60,14 @@ pip install --user flake8
|
||||
|
||||
**代码格式化:**
|
||||
|
||||
默认的代码格式化快捷键为 `SPC b f`, 需要安装 `yapf`。若需要在保存文件时自动格式化该 Python 文件,需要设置 `format-on-save` 为 `true`。
|
||||
默认的代码格式化快捷键为 `SPC b f`, 需要安装 `yapf`。
|
||||
若需要在保存文件时自动格式化该 Python 文件,需要设置 `format_on_save` 为 `true`。
|
||||
|
||||
```toml
|
||||
[[layers]]
|
||||
name = "lang#python"
|
||||
format_on_save = 1
|
||||
```
|
||||
|
||||
```sh
|
||||
pip install --user yapf
|
||||
@ -91,12 +98,12 @@ pip install --user coverage
|
||||
## 模块设置
|
||||
|
||||
默认情况下,当新建一个空白 python 文件时,会自动添加文件头,如果需要修改默认的文件头样式,
|
||||
可以通过设置 `python-file-head` 选项:
|
||||
可以通过设置 `python_file_head` 选项:
|
||||
|
||||
```toml
|
||||
[[layers]]
|
||||
name = "lang#python"
|
||||
python-file-head = [
|
||||
python_file_head = [
|
||||
'#!/usr/bin/env python',
|
||||
'# -*- coding: utf-8 -*-',
|
||||
'',
|
||||
@ -104,6 +111,14 @@ pip install --user coverage
|
||||
]
|
||||
```
|
||||
|
||||
默认自动补全是不显示类型信息,因为这会让补全变得比较慢,如果需要显示,可以启用 `enable_typeinfo` 选项:
|
||||
|
||||
```toml
|
||||
[[layers]]
|
||||
name = "lang#python"
|
||||
enable_typeinfo = true
|
||||
```
|
||||
|
||||
## 快捷键
|
||||
|
||||
### 跳至定义处
|
||||
@ -120,14 +135,13 @@ pip install --user coverage
|
||||
|
||||
### 测试覆盖
|
||||
|
||||
| 模式 | 快捷键 | 功能描述 |
|
||||
| 模式 | 快捷键 | 功能描述 |
|
||||
| ------ | ----------- | ----------------- |
|
||||
| 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`,
|
||||
|
@ -47,7 +47,6 @@ To use this configuration layer, add following snippet to your custom configurat
|
||||
|
||||
### language tools
|
||||
|
||||
|
||||
**syntax checking:**
|
||||
|
||||
`checker` layer provide syntax checking feature, and for Python it uses `flake8` package:
|
||||
@ -58,12 +57,15 @@ pip install --user flake8
|
||||
|
||||
**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`.
|
||||
|
||||
```
|
||||
```toml
|
||||
[[layers]]
|
||||
name = "lang#python"
|
||||
format-on-save = 1
|
||||
format_on_save = 1
|
||||
```
|
||||
|
||||
```sh
|
||||
@ -95,12 +97,12 @@ pip install --user coverage
|
||||
## Configuration
|
||||
|
||||
By default, when create a new python file, SpaceVim will insert file head automatically.
|
||||
to change the file head, use `python-file-head` option:
|
||||
to change the file head, use `python_file_head` option:
|
||||
|
||||
```toml
|
||||
[[layers]]
|
||||
name = "lang#python"
|
||||
python-file-head = [
|
||||
python_file_head = [
|
||||
'#!/usr/bin/env python',
|
||||
'# -*- coding: utf-8 -*-',
|
||||
'',
|
||||
@ -108,6 +110,15 @@ to change the file head, use `python-file-head` option:
|
||||
]
|
||||
```
|
||||
|
||||
When enable autocomplete layer, the symbol will be complete automatically. By default the type info
|
||||
is disabled, because it is too slow. To enable type info:
|
||||
|
||||
```toml
|
||||
[[layers]]
|
||||
name = "lang#python"
|
||||
enable_typeinfo = true
|
||||
```
|
||||
|
||||
## Key bindings
|
||||
|
||||
### Jump to definition
|
||||
|
Loading…
Reference in New Issue
Block a user