Skip to content

Add Neovim DAP debugging support via fm nvim command#378

Draft
ananyo141 wants to merge 5 commits intortCamp:developfrom
ananyo141:feat/nvim-debugger
Draft

Add Neovim DAP debugging support via fm nvim command#378
ananyo141 wants to merge 5 commits intortCamp:developfrom
ananyo141:feat/nvim-debugger

Conversation

@ananyo141
Copy link
Copy Markdown

@ananyo141 ananyo141 commented Mar 22, 2026

Description

This PR introduces the fm nvim command to provide first-class Neovim debugging support for Frappe developers. Similar to how fm code provisions VSCode environments, fm nvim --debugger automates the setup for Neovim users by generating a project-local .nvim.lua file.

This configuration seamlessly integrates with nvim-dap (and optionally nvim-dap-ui and nvim-dap-python) to allow attaching to the Frappe dev-server, debugging background workers, or executing specific Frappe functions with debugpy already configured for the Docker container.

Proposed Changes

  • New Command (fm nvim): Added to frappe_manager/commands/nvim.py with --debugger (creates .nvim.lua) and --work-dir flags.
  • Bench DevTools Update: Added setup_neovim_debugger and _sync_nvim_config_files in bench_devtools.py to handle the generation and safe-backup of the .nvim.lua workspace config.
  • DAP Configuration: Added the comprehensive NVIM_DAP_LUA script string in site_manager/__init__.py. This Lua script:
    • Resolves container IPs and handles docker-compose execution.
    • Cleans up stale debugpy processes before launch.
    • Registers three nvim-dap configs: fm-frappe-debug, Debug Specific Queue, and Debug Specific Function.
    • Maps Neovim user commands/keymaps (e.g., FmDebugStart, <leader>ds).
  • Dependencies Installation: Automatically installs ruff and debugpy in the container's bench environment during setup.
  • Documentation: Updated README.md and CLI examples.json to highlight Neovim integration.
  • Testing: Added extensive unit tests (test_nvim_command.py and test_bench_devtools_nvim.py) verifying the command flags, config backups, and Lua file contents.

Testing Instructions

  1. Create or start an existing bench (e.g., fm start mybench.localhost).
  2. Run fm nvim mybench.localhost --debugger.
  3. Verify that .nvim.lua is successfully created at the root of the bench workspace (<bench_path>/workspace/frappe-bench/.nvim.lua).
  4. Ensure your Neovim config has vim.opt.exrc = true to allow local config execution.
  5. Open the bench workspace in Neovim.
  6. Verify that nvim-dap recognizes the Frappe configurations and that commands like :FmDebugStart execute and attach to the containerized debugpy session.
  7. Run tests: pytest tests/unit/cli/test_nvim_command.py tests/unit/site_manager/test_bench_devtools_nvim.py

Checklist

  • I have read the contributing guidelines.
  • My code follows the project's code style.
  • I have added tests to cover my changes.
  • I have updated the documentation accordingly (README.md, examples.json).
  • All new and existing tests passed.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Mar 22, 2026

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

@ananyo141 ananyo141 changed the title Add support for neovim debugger Add Neovim DAP debugging support via fm nvim command Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants