Skip to content

feat: add hover provider (#147)#159

Merged
pranaygp merged 1 commit into
masterfrom
feat/hover-provider-147
May 17, 2026
Merged

feat: add hover provider (#147)#159
pranaygp merged 1 commit into
masterfrom
feat/hover-provider-147

Conversation

@pranaygp
Copy link
Copy Markdown
Owner

Closes #147.

Summary

  • Cmd+hover didn't show a preview because the language server only advertised definitionProvider/workspaceSymbolProvider — VSCode's hover popup is driven by the LSP hoverProvider API.
  • Add hoverProvider: true to server capabilities and wire up connection.onHover in server/src/server.ts.
  • New server/src/core/findHover.ts reuses findSelector + findSymbols, then renders the first matching rule's CSS source as a fenced markdown code block, truncated to 20 lines.

Test plan

  • yarn build (zero TS errors)
  • yarn test — added tests/src/findHover.test.ts covering class match, id match, and no-match (null). All 27 tests pass.
  • yarn lint clean.
  • Manual: open an HTML doc that references a known CSS class, Cmd+hover, confirm preview box renders the CSS rule.

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings May 16, 2026 20:32
Copy link
Copy Markdown

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

Adds LSP hover support so CSS Peek can show a CSS rule preview when hovering supported source selectors.

Changes:

  • Advertises hoverProvider capability and wires connection.onHover.
  • Adds findHover to resolve selectors to stylesheet symbols and return markdown fenced CSS snippets.
  • Adds tests for class, id, and no-match hover behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
server/src/server.ts Registers hover capability and delegates hover requests to selector/style lookup.
server/src/core/findHover.ts Builds hover markdown from the first matching stylesheet symbol.
tests/src/findHover.test.ts Covers hover output for matching and non-matching selectors.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Cmd+hover didn't display a preview popup because the language server
only advertised definitionProvider and workspaceSymbolProvider — VSCode's
hover preview is driven by the hover provider API.

Add `hoverProvider: true` to server capabilities and implement an
onHover handler that reuses the selector-extraction (findSelector) and
symbol-lookup (findSymbols) logic. The hover renders the first matching
rule's CSS source as a fenced markdown code block, truncated to ~20
lines to keep the popover compact.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@pranaygp pranaygp force-pushed the feat/hover-provider-147 branch from c89ea2f to 33490a1 Compare May 17, 2026 00:33
@pranaygp pranaygp merged commit 8a3c7d6 into master May 17, 2026
2 checks passed
@pranaygp pranaygp deleted the feat/hover-provider-147 branch May 17, 2026 00:34
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.

CMD + Hover doesn't show the preview box

2 participants