SpaceVim

A modular Vim/Neovim configuration


Home | About | Quick start guide | Documentation | Development | Community | Sponsors | 中文


Available Layers » lang#python

Description

This layer is for Python development.

Installation

Enable language layer

The lang#python layer is not loaded by default, to use this layer, you need to add following snippet into your spacevim configuration file.

[[layers]]
  name = "lang#python"

Language tools

Layer options

Key bindings

Jump to definition

Mode Key Bindings Description
normal g d Jump to the definition position of the symbol under cursor

Code generation

Mode Key Binding Description
normal SPC l g d Generate docstring

Code Coverage

Mode Key Binding Description
normal SPC l c r coverage report
normal SPC l c s coverage show
normal SPC l c e coverage session
normal SPC l c f coverage refresh

Text objects and motions

This layer contains vim-pythonsense which provides text objects and motions for Python classes, methods, functions, and doc strings.

Text Objects Descriptions
ac Outer class text object
ic Inner class text object
af Inner function text object
if Inner function text object
ad Inner docstring text object
id Inner docstring text object

Inferior REPL process

Start a Python or iPython inferior REPL process with SPC l s i. If ipython is available in system executable search paths, ipython will be used to launch Python shell; otherwise, default python interpreter will be used. You may change your system executable search path by activating a virtual environment.

Send code to inferior process commands:

Key Bindings Descriptions
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

Running current script

To run a Python script, you can press SPC l r to run the current file without losing focus, and the result will be shown in a runner buffer.

Testing

Refactoring

Key Bindings Descriptions
SPC l i r remove unused imports with autoflake
SPC l i s sort imports with isort

LSP key Bindings

If the lsp layer is enabled for python, the following key bindings can be used:

key binding Description
g D jump to type definition
SPC l e rename symbol
SPC l x show references
SPC l s show line diagnostics
SPC l d show document
K show document
SPC l w l list workspace folder
SPC l w a add workspace folder
SPC l w r remove workspace folder

Powered by Jekyll