sponsor Vim development Vim logo Vim Book Ad

vimspectorpy : python default configurations for vimspector

 script karma  Rating -1/1, Downloaded by 287  Comments, bugs, improvements  Vim wiki

created by
sagi zeevi
 
script type
ftplugin
 
description
This plugin is maintained on github - https://github.com/sagi-z/vimspectorpy

# vimspectorpy - python default configurations for vimspector

## Description

Being able to simply debug a piece of code with 'ipython' or set a breakpoint
in a *pytest/nose* is priceless. Also to use the correct python
environment for debugging automatically should be transparent.

This plugin adds some python customization to [vimspector]:

* Choose the correct python executable if in a VIRTUAL_ENV.
* Run pytest/nosetests for the project or test file, with breakpoints in
  [vimspector].
* Debug the current file as a program.
* Launch ipython and attach a debugger to it to debug your code with vimspector.
* Add a strategy to [vim-test] to allow running a test case in a debugger.

## Usage

### Vimspector new configurations

Next time you are on a python source and start a debug session (F5) you'll get
this option:

1. debug this file - launch a debug session for the current file, using the
   python from your $VIRTUAL_ENV if there is one, or *python3*.

### ipython/pytest/nosetests with vim breakpoints

These commands are available to you:

```vim
" ipython started with debugpy, ready to attach to, but not attached.
" The default name is 'Pyconsole' - it is mapped to a port number you
" can attach to with :Pyattach.
:Pyconsole [name]

" start a debug session with vimspector against the port mapped to by
" 'name'. The default name is 'Pyconsole'.
:Pyattach [name]

" pytest started with debugpy, attached to immediately with vimspector.
" The default name is 'PytestD' - it is mapped to a port number you
" can attach to with :Pyattach, if you accidentally detach from it.
" 'options' are passed on to pytest.
:PytestD [name] [options]

" pytest started with debugpy for the current file, attached to immediately
" with vimspector. The default name is 'PytestD' - it is mapped to a port
" number you can attach to with :Pyattach, if you accidentally detach from it.
" 'options' are passed on to pytest. The path to the current file is appended.
:PytestDThis [name] [options]

" nosetests started with debugpy, attached to immediately with vimspector.
" The default name is 'NosetestsD' - it is mapped to a port number you
" can attach to with :Pyattach, if you accidentally detach from it.
" 'options' are passed on to nosetests.
:NosetestsD [name] [options]

" nosetests started with debugpy for the current file, attached to immediately
" with vimspector. The default name is 'NosetestsD' - it is mapped to a port
" number you can attach to with :Pyattach, if you accidentally detach from it.
" 'options' are passed on to nosetests. The path to the current file is appended.
:NosetestsDThis [name] [options]
```

### other commands

```vim
" This installs/updates this plugin's external dependencies:
" * A virtualenv with ipython and debugpy.
" * Some default configurations for {vimspector} python filetype.
:VimspectorpyUpdate
```

## Settings

### g:vimspectorpy#cmd_prefix

This plugin will not override command names you defined yourself.  To avoid
naming conflicts you could add a prefix to its commands.

This will make all the 'Py...' commands start with 'VS' (VSPyconsole,
VSPyattach, ...):

```vim
let g:vimspectorpy#cmd_prefix = "VS"
```

### g:vimspectorpy#launcher

For starting another window the plugin will use [tmux] automatically in a
console and 'xterm' in GUI.

You could choose 'rxvt' or force 'xterm' using:

```vim
let g:vimspectorpy#launcher = "rxvt"
```

## Vim-test

If you are using the excellent [vim-test] plugin, then now you can choose a
strategy to open the test in a [vimspector] debugger:

```vim
let test#strategy = "vimspectorpy"
```

## More help

For the most up to date docs use [:help vimspectorpy](doc/vimspectorpy.txt)

## License

MIT

[vimspector]: https://github.com/puremourning/vimspector
[tmux]:       https://github.com/tmux/tmux/wiki
[vim-test]:   https://github.com/vim-test/vim-test
 
install details
## Install

### with plug.vim

Of course make sure [vimspector] is installed:

`Plug 'puremourning/vimspector'`

And also add this:

`Plug 'sagi-z/vimspectorpy', { 'do': { -> vimspectorpy#update() } }`

### Manual

* Install [vimspector].
* Clone this repository into your *~/.vim/plugin/* directory.
* From vim execute this command:

```vim
:VimspectorpyUpdate
```
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
vimspectorpy-0.9.3.zip 0.9.3 2021-05-02 8.2 sagi zeevi Fixed these issues:
Issue 10: Unable to install via vim-plug (missing nvim support)
Issue 9: Cannot step into code in other packages
vimspectorpy-0.9.2.tar.gz 0.9.2 2021-03-25 8.2 sagi zeevi Handle race conditions during installation. Also verifies debugpy is installed by vimspector.
vimspectorpy-0.9.1.tar.gz 0.9.1 2021-03-24 8.2 sagi zeevi Initial upload
ip used for rating: 18.223.32.230

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github