Skip to content

Add Neovim (nvim) IDE detection support#58

Merged
technicalpickles merged 4 commits intomainfrom
add-nvim-ide-detection
Oct 21, 2025
Merged

Add Neovim (nvim) IDE detection support#58
technicalpickles merged 4 commits intomainfrom
add-nvim-ide-detection

Conversation

@technicalpickles
Copy link
Copy Markdown
Owner

Summary

This PR adds comprehensive detection for Neovim (nvim) as an IDE, supporting both :terminal and :!command execution modes.

Changes

  • Add nvim mapping to IDE detectors in src/detectors/env_mapping.rs with priority 4 (highest)
  • Detection via environment variables:
    • NVIM: Present in :terminal mode (socket path)
    • VIMRUNTIME: Present in :!command mode
    • MYVIMRC: Present in both modes
  • Returns 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 (at least one must be present):

  1. NVIM - Socket path in :terminal mode
  2. VIMRUNTIME - Runtime directory in :!command mode
  3. MYVIMRC - Config file path in both modes

Priority 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 :terminal detection
  • detects_nvim_command_mode - Validates :!command detection
  • nvim_takes_precedence_over_ghostty - Nested terminal scenario
  • nvim_inside_vscode_detects_as_nvim - Priority precedence test
  • snapshot_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:

# From nvim :!command mode
:!envsense check ide.id
# Returns: nvim

# From nvim :terminal mode
:terminal
envsense check ide.id
# Returns: nvim

# Get full detection info
:!envsense info --json | jq '.traits.ide'
# Returns: { "id": "nvim" }

Testing

Tested with real Neovim environment data from both execution modes on macOS with Homebrew-installed Neovim 0.11.2.

🤖 Generated with Claude Code

technicalpickles and others added 3 commits October 2, 2025 11:37
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>
Copilot AI review requested due to automatic review settings October 21, 2025 12:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, and MYVIMRC environment 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>
@technicalpickles technicalpickles merged commit 8085ed0 into main Oct 21, 2025
4 checks passed
@technicalpickles technicalpickles deleted the add-nvim-ide-detection branch October 21, 2025 13:53
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