All Projects → mfussenegger → nvim-dap-python

mfussenegger / nvim-dap-python

Licence: GPL-3.0 License
An extension for nvim-dap, providing default configurations for python and methods to debug individual test methods or classes.

Programming Languages

lua
6591 projects

Projects that are alternatives of or similar to nvim-dap-python

Nvim Dap
Debug Adapter Protocol client implementation for Neovim (>= 0.5)
Stars: ✭ 326 (+365.71%)
Mutual labels:  debugger, neovim, neovim-plugin
Vimspector
vimspector - A multi-language debugging system for Vim
Stars: ✭ 2,711 (+3772.86%)
Mutual labels:  debugger, debugging, debug-adapter-protocol
vim-dap
Vim/Neovim debugger plugin providing a terminal interface to the Debug Adapter Protocol
Stars: ✭ 43 (-38.57%)
Mutual labels:  debugger, neovim-plugin, debug-adapter-protocol
nvim-ghost.nvim
👻 GhostText plugin for Neovim with zero dependencies 🎉 Supports neovim running inside WSL too! 🥳 Windows/Linux/macOS supported out-of-the-box! 😄 (Other OSes need python3.6+ installed)
Stars: ✭ 32 (-54.29%)
Mutual labels:  neovim, neovim-plugin
virt-column.nvim
Display a character as the colorcolumn
Stars: ✭ 64 (-8.57%)
Mutual labels:  neovim, neovim-plugin
madbomber
Backtrace-on-throw C++ exception logger
Stars: ✭ 17 (-75.71%)
Mutual labels:  debugger, debugging
Comment.nvim
🧠 💪 // Smart and powerful comment plugin for neovim. Supports treesitter, dot repeat, left-right/up-down motions, hooks, and more
Stars: ✭ 796 (+1037.14%)
Mutual labels:  neovim, neovim-plugin
neogen
A better annotation generator. Supports multiple languages and annotation conventions.
Stars: ✭ 339 (+384.29%)
Mutual labels:  neovim, neovim-plugin
spellsitter.nvim
Treesitter powered spellchecker
Stars: ✭ 251 (+258.57%)
Mutual labels:  neovim, neovim-plugin
boo-colorscheme-nvim
Boo is a colorscheme for Neovim with handcrafted support for LSP, Treesitter.
Stars: ✭ 62 (-11.43%)
Mutual labels:  neovim, neovim-plugin
nvim-lsp-smag
Seamless integration of language server locations into NeoVim
Stars: ✭ 60 (-14.29%)
Mutual labels:  neovim, neovim-plugin
null-ls.nvim
Use Neovim as a language server to inject LSP diagnostics, code actions, and more via Lua.
Stars: ✭ 965 (+1278.57%)
Mutual labels:  neovim, neovim-plugin
close-buffers.nvim
📑 Delete multiple vim buffers based on different conditions
Stars: ✭ 54 (-22.86%)
Mutual labels:  neovim, neovim-plugin
gdbstub
An ergonomic and easy-to-integrate implementation of the GDB Remote Serial Protocol in Rust, with full no_std support.
Stars: ✭ 158 (+125.71%)
Mutual labels:  debugger, debugging
lir.nvim
Neovim file explorer
Stars: ✭ 194 (+177.14%)
Mutual labels:  neovim, neovim-plugin
nvim-lsp-compl
A fast and asynchronous auto-completion plugin for Neovim >= 0.5, focused on LSP.
Stars: ✭ 46 (-34.29%)
Mutual labels:  neovim, neovim-plugin
cmp-under-comparator
nvim-cmp comparator function for completion items that start with one or more underlines
Stars: ✭ 77 (+10%)
Mutual labels:  neovim, neovim-plugin
igs.nvim
A minimalist Neovim plugin that enhances the usage of git status inside Neovim.
Stars: ✭ 17 (-75.71%)
Mutual labels:  neovim, neovim-plugin
black-nvim
A Neovim plugin to format your code using Black
Stars: ✭ 23 (-67.14%)
Mutual labels:  neovim, neovim-plugin
nvim context vt
Virtual text context for neovim treesitter
Stars: ✭ 193 (+175.71%)
Mutual labels:  neovim, neovim-plugin

nvim-dap-python

An extension for nvim-dap providing default configurations for python and methods to debug individual test methods or classes.

Installation

  • Requires Neovim >= 0.5
  • Requires nvim-dap
  • Requires debugpy
  • Install like any other neovim plugin:
    • If using vim-plug: Plug 'mfussenegger/nvim-dap-python'
    • If using packer.nvim: use 'mfussenegger/nvim-dap-python'

If you want to use the test runner functionality, it additionally requires a tree sitter parser for Python.

Debugpy

It is recommended to install debugpy into a dedicated virtualenv. To do so:

mkdir .virtualenvs
cd .virtualenvs
python -m venv debugpy
debugpy/bin/python -m pip install debugpy

The debugger will automatically pick-up another virtual environment if it is activated before neovim is started.

Tree-sitter

Install either:

  • Via :TSInstall python of nvim-treesitter
  • Compile the parser from tree-sitter-python and copy it into .config/nvim/parser/:
    • git clone https://github.com/tree-sitter/tree-sitter-python.git
    • cd tree-sitter-python
    • cc -O2 -o ~/.config/nvim/parser/python}.so -I./src src/parser.c src/scanner.cc -shared -Os -lstdc++ -fPIC

Usage

  1. Call setup in your init.vim to register the adapter and configurations:
lua require('dap-python').setup('~/.virtualenvs/debugpy/bin/python')

The argument to setup is the path to the python installation which contains the debugpy module.

  1. Use nvim-dap as usual.
  • Call :lua require('dap').continue() to start debugging.
  • See :help dap-mappings and :help dap-api.
  • Use :lua require('dap-python').test_method() to debug the closest method above the cursor.

Supported test frameworks are unittest and pytest. It defaults to using unittest. To configure pytest set the test runner like this:

lua require('dap-python').test_runner = 'pytest'

Mappings

nnoremap <silent> <leader>dn :lua require('dap-python').test_method()<CR>
nnoremap <silent> <leader>df :lua require('dap-python').test_class()<CR>
vnoremap <silent> <leader>ds <ESC>:lua require('dap-python').debug_selection()<CR>

Custom configuration

If you call the require('dap-python').setup method it will create a few nvim-dap configuration entries. These configurations are general purpose configurations suitable for many use cases, but you may need to customize the configurations - for example if you want to use Docker containers.

To add your own entries, you can extend the dap.configurations.python list after calling the setup function:

lua << EOF
require('dap-python').setup('/path/to/python')
table.insert(require('dap').configurations.python, {
  type = 'python',
  request = 'launch',
  name = 'My custom launch configuration',
  program = '${file}',
  -- ... more options, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings
})
EOF

An alternative is to use project specific .vscode/launch.json files, see :help dap-launch.json.

The Debugpy Wiki contains a list of all supported configuration options.

Alternatives

vim-ultest

A test runner building upon vim-test with nvim-dap support. Aims to work for all python runners.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].