Skip to content

feat: add separate highlight groups for word under cursor#252

Open
subev wants to merge 1 commit intoRRethy:masterfrom
subev:feat/cursor-highlight-groups
Open

feat: add separate highlight groups for word under cursor#252
subev wants to merge 1 commit intoRRethy:masterfrom
subev:feat/cursor-highlight-groups

Conversation

@subev
Copy link
Copy Markdown

@subev subev commented Dec 27, 2025

Summary

Adds separate highlight groups for references under the cursor, allowing customization of the word under cursor independently from other references.

Motivation

The existing under_cursor configuration option controls whether the word under cursor is highlighted, but does not provide a way to style it differently from other references. This change addresses that limitation by introducing cursor-specific highlight groups.

Changes

  • Added three new highlight groups:
    • IlluminatedWordCursor (Text kind)
    • IlluminatedWordCursorRead (Read kind)
    • IlluminatedWordCursorWrite (Write kind)
  • Modified highlighting logic to detect cursor position and apply appropriate groups
  • Updated documentation in README.md and doc/illuminate.txt

Backward Compatibility

The change is fully backward compatible:

  • New highlight groups default to linking to their non-cursor counterparts
  • Visual appearance remains unchanged unless explicitly customized
  • Existing under_cursor config behavior is preserved
  • No changes required to existing configurations

Implementation Details

The implementation modifies lua/illuminate/highlight.lua to:

  1. Accept an is_under_cursor parameter in the highlighting functions
  2. Detect cursor position for each reference using existing utilities
  3. Select appropriate highlight group based on cursor position and LSP kind
  4. Maintain compatibility with all providers (LSP, treesitter, regex)

This change adds three new highlight groups for references under the cursor:
- IlluminatedWordCursor (Text kind)
- IlluminatedWordCursorRead (Read kind)
- IlluminatedWordCursorWrite (Write kind)

These groups default to linking to their non-cursor counterparts, ensuring
backward compatibility. Users can customize these groups to visually
distinguish the word under cursor from other references.

The implementation:
- Detects cursor position for each reference during highlighting
- Applies cursor-specific highlight groups when appropriate
- Maintains existing behavior when under_cursor config is false
- Works with all providers (LSP, treesitter, regex)
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.

1 participant