A production-ready Neovim setup for mixed-mode C++/Python debugging and deep learning development
Features β’ Installation β’ Debugging β’ Keybindings β’ Documentation
This is a complete Neovim configuration built specifically for PyTorch development and mixed-mode C++/Python debugging. Whether you're working on PyTorch internals, building custom C++ extensions, or developing pybind11 bindings, this setup provides seamless navigation and debugging across both languages.
Built on Kickstart.nvim and enhanced with professional tooling for deep learning systems work.
- π Seamlessly debug Python β C++ - Step from Python code directly into C++ extensions
- β‘ Fast & Modern - Optimized completion, LSP, and treesitter for instant feedback
- π― PyTorch-Optimized - Pre-configured for PyTorch source code, extensions, and operators
- π οΈ Batteries Included - All tools pre-configured: LSP, DAP, formatters, linters
- π§© Extensible - Clean Lua configuration that's easy to customize
|
Python Debugging
|
C++ Debugging
|
| Language | LSP | Features |
|---|---|---|
| Python | pyright | Type checking, intelligent completion, import resolution, refactoring |
| C++ | clangd | Semantic indexing, cross-file navigation, code actions, IntelliSense |
| Additional | Treesitter | Advanced syntax highlighting for C, C++, Python, CMake, CUDA, JSON, TOML, Markdown |
- π Navigation - Telescope fuzzy finder, Flash jump labels, Harpoon file bookmarks
- π Completion - blink.cmp for blazing-fast completions
- π― Code Actions - Automated refactoring, imports, and fixes
- π Git Integration - Inline hunks, blame, staging, and diffview
- πͺ Session Management - Automatic session persistence across restarts
- π₯οΈ Tmux Integration - Seamless navigation between Neovim and tmux panes
- Neovim >= 0.10.0
- Git
- A C++ compiler (for building extensions)
- Python >= 3.8
- Node.js (for some LSP servers)
# Backup any existing configuration
mv ~/.config/nvim ~/.config/nvim.backup-$(date +%Y%m%d) 2>/dev/null || true
# Clone this repository
git clone https://github.com/hinriksnaer/nvim ~/.config/nvim
# Start Neovim - plugins will install automatically
nvim- Wait for all plugins to install automatically
- Run
:Masonto verify language servers are installed - Run
:LspInfoto confirm LSPs are attached - Run
:checkhealthto verify everything is working
This configuration excels at debugging PyTorch development scenarios:
# Example: Debugging a custom PyTorch operator
# 1. Set a breakpoint in your Python test
def test_custom_op():
x = torch.randn(10, 10)
y = my_custom_op(x) # β Set breakpoint here
# 2. Press <leader>ds to start debugging
# 3. Step through Python code
# 4. When you hit the C++ extension call:
# - Press <F8> to attach codelldb
# - Step into C++ implementation
# - Inspect tensors at C++ level| Workflow | Description |
|---|---|
| Python β C++ | Start in Python, step into pybind11/C API calls |
| PyTorch Operators | Debug Python tests, inspect ATen/C++ kernels |
| Standalone C++ | Launch native binaries, debug libtorch apps |
| Attach to Process | Attach to running Python processes with C++ extensions |
- Automatic Layout - Debug UI opens on start, closes on exit
- Variable Inspection - Watch expressions, scopes, and hover values
- Stack Navigation - Navigate Python and C++ frames seamlessly
- Breakpoint Management - Visual breakpoint indicators and conditional breakpoints
| Key | Action |
|---|---|
<leader>ff |
Find files |
<leader>fg |
Live grep (search in files) |
<leader>fb |
Browse open buffers |
<leader>fs |
Search word under cursor |
<leader>ft |
Theme picker |
<C-h/j/k/l> |
Navigate windows (tmux-aware) |
s |
Flash jump to any visible location |
| Key | Action |
|---|---|
gd |
Go to definition |
gr |
Find references |
K |
Hover documentation |
<leader>ca |
Code actions |
<leader>cn |
Rename symbol |
<leader>cf |
Format buffer |
[d / ]d |
Previous/next diagnostic |
Standalone Keybindings:
| Key | Action |
|---|---|
<leader>db |
Toggle breakpoint |
<leader>de |
Evaluate expression (visual mode) |
π Debug Mode Hydra (<leader>dm to enter)
Once in Debug Mode, use these single-key commands:
| Key | Action |
|---|---|
s |
Start/continue debugging |
n |
Step over (next) |
i |
Step into |
o |
Step out |
c |
Run to cursor |
b |
Toggle breakpoint |
t |
Terminate session |
x |
Toggle DAP UI |
g |
Go to stopped location |
[ / ] |
Navigate stack up/down |
v / w / r |
Focus variables/watches/REPL |
q / <Esc> |
Exit Debug Mode |
| Key | Action |
|---|---|
<leader>gs |
Stage hunk |
<leader>gr |
Reset hunk |
<leader>gb |
Blame line |
<leader>gD |
Open diffview |
<leader>gh |
File history |
<leader>gtb |
Toggle blame line |
Buffer Management:
| Key | Action |
|---|---|
<leader>bd |
Delete buffer |
<leader>bD |
Delete all buffers except current |
<leader><leader> |
Switch to alternate buffer |
[b / ]b |
Previous/next buffer |
π Window Mode Hydra (<leader>w to enter)
Once in Window Mode, use these single-key commands:
| Key | Action |
|---|---|
h / j / k / l |
Navigate between windows |
s |
Split horizontally |
v |
Split vertically |
c |
Close window |
< / > |
Decrease/increase width |
+ / - |
Increase/decrease height |
= |
Equalize window sizes |
u |
Undo close (restore last) |
q / <Esc> |
Exit Window Mode |
Tip: Press
<leader>?to see all available keybindings with which-key
The configuration is organized into modular files:
~/.config/nvim/
βββ init.lua # Entry point & lazy.nvim setup
βββ doc/ # Documentation files
βββ lua/
β βββ config/ # Core Neovim settings
β β βββ options.lua # Vim options
β β βββ keymaps.lua # Basic keybindings
β β βββ autocmds.lua # Autocommands
β βββ plugins/ # Plugin configurations
β βββ dap/ # Debug Adapter Protocol
β β βββ init.lua # DAP setup
β β βββ adapters.lua # Language adapters
β β βββ keymaps.lua # Standalone debug keys
β β βββ python.lua # Python debugging
β β βββ ui.lua # DAP UI configuration
β β βββ signs.lua # Breakpoint signs
β βββ hydra/ # Hydra modal keybindings
β β βββ init.lua # Hydra plugin setup
β β βββ debug.lua # Debug Mode Hydra
β β βββ window.lua # Window Mode Hydra
β β βββ tmux.lua # Tmux navigation
β βββ lspconfig.lua # LSP configuration
β βββ telescope.lua # Fuzzy finder
β βββ completion.lua # blink.cmp setup
β βββ treesitter.lua # Syntax highlighting
β βββ gitsigns.lua # Git integration
β βββ [other plugins...] # Additional plugins
To customize, edit the relevant files and restart Neovim. All plugin configurations use lazy.nvim for fast startup times.
:LspInfo " Check server status
:Mason " Install missing tools
:checkhealth lsp " Diagnose LSP issues- Verify
codelldbanddebugpyare installed via:Mason - Check DAP configuration points to the correct program
- Review
:messagesfor error logs
- Ensure formatter is installed (clang-format, black, etc.)
- Check for project config files (
.clang-format,pyproject.toml) - Verify format-on-save is enabled in your settings
:Lazy profile " Check plugin load times
:checkhealth " Run comprehensive health check- Which-key: Press
<leader>?to discover keybindings - Telescope: Press
<leader>fhto search help tags - Mason: Run
:Masonto manage LSP servers and tools
Contributions are welcome! If you have improvements or bug fixes:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
MIT License - see LICENSE.md for details.
- Built on Kickstart.nvim
- Inspired by the PyTorch development workflow
- Thanks to the Neovim community for amazing plugins
Made with β€οΈ for the PyTorch community
