Add Neovim (nvim) IDE detection support#58
Merged
technicalpickles merged 4 commits intomainfrom Oct 21, 2025
Merged
Conversation
Amp-Thread-ID: https://ampcode.com/threads/T-c0634e4b-8388-478a-80c2-c844aa9e8c1d Co-authored-by: Amp <amp@ampcode.com>
This commit adds comprehensive detection for Neovim environments, supporting both :terminal and :!command execution modes. ## Changes - Add nvim mapping to IDE detectors with priority 4 (highest) - Detect via NVIM variable (terminal mode) or VIMRUNTIME/MYVIMRC (command mode) - Return ide.id = "nvim" when detected - Add 4 unit tests covering both execution modes and nested scenarios - Add 2 snapshot tests with real nvim environment data - Include test fixtures based on actual nvim environment output ## Detection Strategy The implementation uses a declarative approach with three optional indicators: - NVIM: Present in :terminal mode (socket path) - VIMRUNTIME: Present in :!command mode - MYVIMRC: Present in both modes Priority 4 ensures nvim detection takes precedence over other IDEs (VS Code, Cursor, etc.) when running nested. ## Test Coverage All 308 unit tests + 19 snapshot tests pass: - detects_nvim_terminal_mode - detects_nvim_command_mode - nvim_takes_precedence_over_ghostty - nvim_inside_vscode_detects_as_nvim - snapshot_nvim_terminal_mode - snapshot_nvim_command_mode 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds comprehensive detection support for Neovim (nvim) as an IDE, enabling envsense to identify when code is running within Neovim's :terminal or :!command execution modes.
Key Changes:
- Added nvim environment mapping with priority 4 detection using
NVIM,VIMRUNTIME, andMYVIMRCenvironment variables - Implemented 4 unit tests covering terminal mode, command mode, and priority precedence scenarios
- Added 2 snapshot tests with real Neovim environment fixtures from macOS
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/detectors/env_mapping.rs | Adds nvim mapping with three optional indicators for IDE detection |
| src/detectors/ide_declarative.rs | Adds 4 unit tests validating nvim detection across different execution modes |
| tests/info_snapshots.rs | Adds 2 snapshot tests for nvim terminal and command modes |
| tests/snapshots/nvim_terminal_mode.env | Test fixture with real nvim terminal mode environment data |
| tests/snapshots/nvim_command_mode.env | Test fixture with real nvim command mode environment data |
| tests/snapshots/info_snapshots__nvim_terminal_mode.snap | Expected JSON output snapshot for terminal mode detection |
| tests/snapshots/info_snapshots__nvim_command_mode.snap | Expected JSON output snapshot for command mode detection |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
- Add test for nvim detection without MYVIMRC to validate edge case where users run nvim -u NONE or without a config file - Document priority rationale explaining why priority 4 ensures correct detection in nested IDE scenarios (nvim inside VS Code/Cursor terminals) - All 309 unit tests + 19 snapshot tests pass 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds comprehensive detection for Neovim (nvim) as an IDE, supporting both
:terminaland:!commandexecution modes.Changes
src/detectors/env_mapping.rswith priority 4 (highest)NVIM: Present in:terminalmode (socket path)VIMRUNTIME: Present in:!commandmodeMYVIMRC: Present in both modeside.id = "nvim"when detectedDetection Strategy
The implementation uses a declarative approach with three optional indicators (at least one must be present):
NVIM- Socket path in:terminalmodeVIMRUNTIME- Runtime directory in:!commandmodeMYVIMRC- Config file path in both modesPriority 4 ensures nvim detection takes precedence over other IDEs (VS Code priority 1, Cursor priority 3) when running nested scenarios (e.g., nvim inside VS Code terminal).
Test Coverage
✅ All 308 unit tests + 19 snapshot tests pass
New tests:
detects_nvim_terminal_mode- Validates:terminaldetectiondetects_nvim_command_mode- Validates:!commanddetectionnvim_takes_precedence_over_ghostty- Nested terminal scenarionvim_inside_vscode_detects_as_nvim- Priority precedence testsnapshot_nvim_terminal_mode- Full JSON output validation (terminal)snapshot_nvim_command_mode- Full JSON output validation (command)Usage
Once merged and released, users can detect nvim from within the editor:
Testing
Tested with real Neovim environment data from both execution modes on macOS with Homebrew-installed Neovim 0.11.2.
🤖 Generated with Claude Code