Skip to content

lsp: show literal hover types and initialize server info#127

Open
bneiswander wants to merge 3 commits into
purefunctor:mainfrom
bneiswander:pr/lsp-literal-hover-server-info
Open

lsp: show literal hover types and initialize server info#127
bneiswander wants to merge 3 commits into
purefunctor:mainfrom
bneiswander:pr/lsp-literal-hover-server-info

Conversation

@bneiswander

@bneiswander bneiswander commented May 15, 2026

Copy link
Copy Markdown
Contributor

lsp: show literal hover types and initialize server info

Base branch: main

Review Order

This PR is independent and can be reviewed against main at any time. It is intentionally small LSP polish and does not depend on the execute-command or diagnostics-refresh PRs.

Summary

  • Return simple hover results for literal expressions instead of falling through to checked-node lookup.
  • Include server_info in the LSP initialize result so clients can display the analyzer name/version.

Motivation

Hovering on basic literals is a common editor interaction. For literals such as strings, chars, booleans, integers, and numbers, the type is known directly from the lowered expression kind, so the hover path does not need to depend on later checked-node metadata.

The initialize response also benefits from including server identity metadata. Some clients surface this in logs, status output, or server selection UI.

Motivating Example

In an editor, hovering over these literal expressions should return the obvious PureScript type:

name = "alexandrite" -- hover: String
count = 42          -- hover: Int
enabled = true      -- hover: Boolean

Implementation Notes

  • Adds direct hover handling for String, Char, Boolean, Integer, and Number expression kinds.
  • Adds a small helper for scalar PureScript hover text.
  • Sets initialize server_info to the analyzer package name and version.

Tests

Validation run locally:

cargo check -p purescript-analyzer --tests

Return ServerInfo name/version in initialize response so clients can confirm which binary/version they are running when debugging behavior.
@coderabbitai

coderabbitai Bot commented May 15, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: db3c5411-a9bc-4cb5-a182-54febe1153b1

📥 Commits

Reviewing files that changed from the base of the PR and between 6f8e1a1 and eaaf5a5.

📒 Files selected for processing (1)
  • compiler-bin/src/lsp.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • compiler-bin/src/lsp.rs

Walkthrough

The PR adds server metadata to the LSP initialize response and returns direct hover results for primitive expression kinds via a new helper, avoiding the generic checked-type fallback.

Changes

LSP Server Improvements

Layer / File(s) Summary
Server initialization metadata
compiler-bin/src/lsp.rs
LSP initialize response now sets server_info with name "purescript-analyzer" and version from CARGO_PKG_VERSION instead of None.
Primitive expression hover support
compiler-lsp/analyzer/src/hover.rs
hover_expression matches ExpressionKind::{String, Char, Boolean, Integer, Number} and returns a Hover via a new hover_simple_type helper that produces a scalar MarkedString (language "purescript") and range = None.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A tiny hop of server name and ver,

primitives glow when hovers stir,
Strings and Numbers hum in place,
the analyzer shows their face,
a carrot-sized patch, clever and terse.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description clearly describes the two main changes: hover results for literal expressions and server_info initialization, with examples and motivation.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@bneiswander bneiswander changed the title Pr/lsp literal hover server info lsp: show literal hover types and initialize server info May 15, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
compiler-bin/src/lsp.rs (1)

119-120: ⚡ Quick win

Derive server name from Cargo metadata to avoid drift.

Using env!("CARGO_PKG_NAME") keeps name/version sourced from the same metadata and avoids manual string mismatch later.

Proposed patch
             server_info: Some(ServerInfo {
-                name: "purescript-analyzer".to_string(),
+                name: env!("CARGO_PKG_NAME").to_string(),
                 version: Some(env!("CARGO_PKG_VERSION").to_string()),
             }),
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@compiler-bin/src/lsp.rs` around lines 119 - 120, Replace the hardcoded server
name string with Cargo metadata so name/version come from the same source;
specifically change the field where name is set (currently name:
"purescript-analyzer".to_string()) to use env!("CARGO_PKG_NAME").to_string()
while keeping version as env!("CARGO_PKG_VERSION").to_string() so both name and
version are derived from Cargo package metadata.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@compiler-bin/src/lsp.rs`:
- Around line 119-120: Replace the hardcoded server name string with Cargo
metadata so name/version come from the same source; specifically change the
field where name is set (currently name: "purescript-analyzer".to_string()) to
use env!("CARGO_PKG_NAME").to_string() while keeping version as
env!("CARGO_PKG_VERSION").to_string() so both name and version are derived from
Cargo package metadata.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8e454781-0992-4a95-9a09-9fdba9317f06

📥 Commits

Reviewing files that changed from the base of the PR and between 608aeb5 and 6f8e1a1.

📒 Files selected for processing (2)
  • compiler-bin/src/lsp.rs
  • compiler-lsp/analyzer/src/hover.rs

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