Custom config of Nvim (NvChad) as a Python IDE. Note: This guide takes into account the new configuration structure in NvChad v2.5 and beyond as outlined in the release notes.
- Pyright: Static type checker and LSP.
- Black: Code formatter (automatically runs on save).
- Ruff: Linting and code analysis.
- MyPy: Static type checker for Python.
- DebugPy: Debugger integration.
- Tree-sitter: Syntax highlighting and code folding.
nvim/
├── lua/
│ └── custom/
│ ├── configs/
│ │ └── python.lua
│ ├── plugins.lua
│ └── init.lua
-
NvChad (Check if Neovim is up to date (v0.9.5+)!)
Backup previous Nvim config (optional)
mv ~/.config/nvim ~/.config/nvim_backup
- npm (for installing Pyright)
- Python (of course)
git clone https://github.com/dobval/NvChad-python-config.git ~/.config/nvim/lua
Python tools
pip install black ruff mypy debugpy
start nvim and sync
:Lazy sync
pyright
:MasonInstall pyright
Tree-sitter
:TSInstall python
To make debugging more convenient, the following key mappings are set up:
-
F5: Start or continue the debugger.
-
F10: Step over the current line.
-
F11: Step into a function.
-
F12: Step out of a function.
-
<leader>b: Toggle a breakpoint.
- Open a Python file in Neovim.
- Check if Pyright is running by using the command
:LspInfo
. - Save a Python file to ensure Black formats the code.
- Check for diagnostics from Ruff and MyPy.
- Debug a Python file using the key mappings defined above.