Skip to content

feat: add cssPeek.peekVariables toggle (#143)#161

Merged
pranaygp merged 1 commit into
masterfrom
worktree-agent-a212e087241893a15
May 17, 2026
Merged

feat: add cssPeek.peekVariables toggle (#143)#161
pranaygp merged 1 commit into
masterfrom
worktree-agent-a212e087241893a15

Conversation

@pranaygp
Copy link
Copy Markdown
Owner

Summary

Adds a new cssPeek.peekVariables setting (boolean, default true) that lets users hide preprocessor variable definitions from peek / go-to-definition results.

  • New setting declared in package.json under contributes.configuration.
  • Settings interface and default settings in server/src/server.ts extended.
  • Setting plumbed through connection.onDefinition and connection.onWorkspaceSymbol via getDocumentSettings / connection.workspace.getConfiguration.
  • findSymbols accepts an { peekVariables?: boolean } options bag (default true) and skips SymbolKind.Variable entries when off. findDefinition forwards the option.

Closes #143

Findings about current variable behavior

I verified what vscode-css-languageservice returns from findDocumentSymbols:

Source Symbols produced for variable definitions
SCSS $primary: red; SymbolKind.Variable with name $primary
LESS @primary: red; SymbolKind.Variable with name @primary
CSS :root { --primary: red; } Not emitted as a symbol (only the :root selector is)

In practice, with the current selector regex in findSymbols, preprocessor variables are not surfaced today because the class/id/tag patterns require the name to begin with ., #, or a word-boundary on the bare identifier — $primary / @primary never match. I confirmed this with a probe against findSymbols directly.

So this PR is mostly defensive: it adds the setting and the filter so that

  1. if the language service ever changes its name encoding (e.g. drops the leading $/@), or
  2. someone broadens the selector regex (e.g. to support CSS custom properties via --foo),
    variables will be filtered correctly when cssPeek.peekVariables=false.

Test plan

  • yarn build — passes with zero TS errors
  • yarn test — 26 tests pass (3 new assertions for the toggle: on, default-on, off, plus a regression check that non-variable symbols are unaffected)
  • yarn lint — clean
  • yarn prettier — clean on changed files

The new tests inject a synthetic SymbolKind.Variable into the cached symbol map (whose name would normally match a class regex) to exercise the filter in isolation from the language service's name encoding.

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 a cssPeek.peekVariables setting (default true) that allows users to filter out preprocessor variable definitions (SymbolKind.Variable) from peek/go-to-definition and workspace symbol results, addressing issue #143.

Changes:

  • Declares the new cssPeek.peekVariables boolean configuration in package.json and extends the Settings interface/defaults in the server.
  • Plumbs the setting through connection.onDefinition and connection.onWorkspaceSymbol (the latter is now async to fetch configuration).
  • Extends findSymbols/findDefinition with an options bag that skips SymbolKind.Variable entries when peekVariables is false.

Reviewed changes

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

File Description
package.json Adds the new cssPeek.peekVariables contribution config.
server/src/server.ts Extends Settings and forwards the option to findDefinition/findSymbols; makes onWorkspaceSymbol async to read config.
server/src/core/findDefinition.ts Adds options.peekVariables (default true) and skips SymbolKind.Variable symbols when off.
tests/src/findDefinition.test.ts Adds tests for the new toggle and a regression check for non-variable symbols.

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

Adds a `cssPeek.peekVariables` setting (default `true`) that lets users
hide preprocessor variable definitions (SCSS `$foo`, LESS `@foo`) from
peek/go-to-definition results. Wires the setting through the LSP config
flow and filters `SymbolKind.Variable` in `findSymbols` when disabled.

Closes #143

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@pranaygp pranaygp force-pushed the worktree-agent-a212e087241893a15 branch from 9beafb7 to e6746c7 Compare May 17, 2026 00:30
@pranaygp pranaygp merged commit c4216e4 into master May 17, 2026
2 checks passed
@pranaygp pranaygp deleted the worktree-agent-a212e087241893a15 branch May 17, 2026 00:32
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.

Disabling the display of variables

2 participants