feat: add hover provider (#147)#159
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds LSP hover support so CSS Peek can show a CSS rule preview when hovering supported source selectors.
Changes:
- Advertises
hoverProvidercapability and wiresconnection.onHover. - Adds
findHoverto 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>
c89ea2f to
33490a1
Compare
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.
Closes #147.
Summary
definitionProvider/workspaceSymbolProvider— VSCode's hover popup is driven by the LSPhoverProviderAPI.hoverProvider: trueto server capabilities and wire upconnection.onHoverinserver/src/server.ts.server/src/core/findHover.tsreusesfindSelector+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— addedtests/src/findHover.test.tscovering class match, id match, and no-match (null). All 27 tests pass.yarn lintclean.🤖 Generated with Claude Code