1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-03 03:50:04 +08:00

Pythonenable typeinfo (#3088)

* Update

* Add enable_typeinfo option

close #2922
This commit is contained in:
Wang Shidong 2019-09-25 18:37:22 +08:00 committed by GitHub
parent 64a984b756
commit 3953214b6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 55 additions and 21 deletions

View File

@ -58,7 +58,7 @@ function! SpaceVim#layers#lang#python#config() abort
augroup end augroup end
endif endif
" }}} " }}}
let g:deoplete#sources#jedi#enable_typeinfo = s:enable_typeinfo
call SpaceVim#plugins#runner#reg_runner('python', call SpaceVim#plugins#runner#reg_runner('python',
\ { \ {
\ 'exe' : function('s:getexe'), \ 'exe' : function('s:getexe'),
@ -164,19 +164,28 @@ function! s:go_to_def() abort
endif endif
endfunction endfunction
let s:format_on_save = 0 let s:format_on_save = 0
let s:python_file_head = [ let s:python_file_head = [
\ '#!/usr/bin/env python', \ '#!/usr/bin/env python',
\ '# -*- coding: utf-8 -*-', \ '# -*- coding: utf-8 -*-',
\ '', \ '',
\ '' \ ''
\ ] \ ]
let s:enable_typeinfo = 0
function! SpaceVim#layers#lang#python#set_variable(var) abort function! SpaceVim#layers#lang#python#set_variable(var) abort
let s:format_on_save = get(a:var, let s:format_on_save = get(a:var,
\ 'format_on_save',
\ get(a:var,
\ 'format-on-save', \ 'format-on-save',
\ 0) \ s:format_on_save))
let s:python_file_head = get(a:var, let s:python_file_head = get(a:var,
\ 'python_file_head',
\ get(a:var,
\ 'python-file-head', \ 'python-file-head',
\ s:python_file_head) \ s:python_file_head))
let s:enable_typeinfo = get(a:var,
\ 'enable_typeinfo',
\ s:enable_typeinfo
\ )
endfunction endfunction

View File

@ -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 ```sh
pip install --user yapf pip install --user yapf
@ -91,12 +98,12 @@ pip install --user coverage
## 模块设置 ## 模块设置
默认情况下,当新建一个空白 python 文件时,会自动添加文件头,如果需要修改默认的文件头样式, 默认情况下,当新建一个空白 python 文件时,会自动添加文件头,如果需要修改默认的文件头样式,
可以通过设置 `python-file-head` 选项: 可以通过设置 `python_file_head` 选项:
```toml ```toml
[[layers]] [[layers]]
name = "lang#python" name = "lang#python"
python-file-head = [ python_file_head = [
'#!/usr/bin/env python', '#!/usr/bin/env python',
'# -*- coding: utf-8 -*-', '# -*- 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 r` | coverager report |
| normal | `SPC l c s` | coverager show | | normal | `SPC l c s` | coverager show |
| normal | `SPC l c e` | coverager session | | normal | `SPC l c e` | coverager session |
| normal | `SPC l c f` | coverager refresh | | normal | `SPC l c f` | coverager refresh |
### 交互式编程 ### 交互式编程
启动 `python``ipython` 交互进程,快捷键为: `SPC l s i`。如果存在可执行命令 `ipython` 启动 `python``ipython` 交互进程,快捷键为: `SPC l s i`。如果存在可执行命令 `ipython`

View File

@ -47,7 +47,6 @@ To use this configuration layer, add following snippet to your custom configurat
### language tools ### language tools
**syntax checking:** **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:
@ -58,12 +57,15 @@ pip install --user flake8
**code 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`.
``` ```toml
[[layers]] [[layers]]
name = "lang#python" name = "lang#python"
format-on-save = 1 format_on_save = 1
``` ```
```sh ```sh
@ -95,12 +97,12 @@ pip install --user coverage
## Configuration ## Configuration
By default, when create a new python file, SpaceVim will insert file head automatically. 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 ```toml
[[layers]] [[layers]]
name = "lang#python" name = "lang#python"
python-file-head = [ python_file_head = [
'#!/usr/bin/env python', '#!/usr/bin/env python',
'# -*- coding: utf-8 -*-', '# -*- 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 ## Key bindings
### Jump to definition ### Jump to definition