Skip to content

Language Server: Implement Completion Provider - #1368

Merged
marcoroth merged 7 commits into
mainfrom
language-server-completion-provider
Aug 6, 2026
Merged

marcoroth merged 7 commits into
mainfrom
language-server-completion-provider

Conversation

@marcoroth

@marcoroth marcoroth commented Mar 12, 2026 •

Copy link
Copy Markdown
Owner

HTML tag names completion

CleanShot.2026-03-27.at.20.44.04.mp4

ActionView Tag helpers

CleanShot.2026-03-27.at.20.48.44.mp4

tag.div completion

CleanShot.2026-03-27.at.20.46.21.mp4

content_tag completion

CleanShot.2026-03-27.at.20.48.00.mp4

HTML character reference completion

CleanShot.2026-03-27.at.20.33.12.mp4

Related #1282

@github-actions github-actions Bot added language-server @herb-tools/language-server and Language Server Protocol support typescript TypeScript source across the javascript/ packages labels Mar 12, 2026
@pkg-pr-new

pkg-pr-new Bot commented Mar 12, 2026 •

Copy link
Copy Markdown
npx https://pkg.pr.new/@herb-tools/formatter@1368
npx https://pkg.pr.new/@herb-tools/language-server@1368
npx https://pkg.pr.new/@herb-tools/linter@1368

commit: 59375de

@github-actions

github-actions Bot commented Mar 12, 2026 •

Copy link
Copy Markdown

🌿 Interactive Playground and Documentation Preview

A preview deployment has been built for this pull request. Try out the changes live in the interactive playground:


🌱 Grown from commit 59375de


✅ Preview deployment has been cleaned up.

@marcoroth
marcoroth marked this pull request as ready for review March 27, 2026 19:50
@github-actions github-actions Bot added linter @herb-tools/linter for HTML+ERB templates linter-rule Individual linter rules and their documentation core @herb-tools/core shared AST nodes, interfaces, and utilities labels Mar 27, 2026
@marcoroth
marcoroth force-pushed the language-server-completion-provider branch from 80c8f42 to 6875413 Compare March 27, 2026 20:05
@marcoroth marcoroth added this to the v0.11.0 milestone Jul 30, 2026
@marcoroth marcoroth added the action-view-helpers Action View helper support and metadata label Aug 5, 2026
…registry

The hand-written `action_view_helpers.ts` this branch imported was deleted
in #1611, which replaced it with the generated helper registry in
`@herb-tools/core`. Merging `main` was textually clean but left the
completion provider importing a file that no longer exists, so the package
failed to build.

Source helper completions from `getHelperEntries()` instead, keeping only
public helpers and deduplicating by name (the registry exposes aliased
entries under several keys). This grows the completion list from 7
hand-maintained helpers to 227, and each item now carries the registry
description alongside the documentation link.

Also fix completion context detection inside multi-line ERB tags: the
cursor offset was derived from `position.character` minus the content
start column, which only holds when the tag starts and ends on the same
line. It now goes through document offsets, so

    <%= link_to "Home",
        tag.d %>

completes HTML tag names rather than helpers.
Three follow-ups on the completion provider:

Don't list every view helper for a bare `<% %>`. That tag is usually
control flow, so 197 unfiltered helpers is noise. `<%= %>` exists to
output a value and still offers the full list immediately; `<% %>` waits
until there is a prefix to filter on, which keeps `<% content_for` and
friends working.

Preselect a single item per list. The LSP allows at most one, and left it
to the client to pick when several were marked, so every common tag (and
every helper) competing for it made the choice arbitrary. Mark the entry
that sorts first instead.
@marcoroth
marcoroth merged commit 7330ecf into main Aug 6, 2026
22 checks passed
@marcoroth
marcoroth deleted the language-server-completion-provider branch August 6, 2026 00:20

This branch was successfully deployed

1 active deployment
herb-tools (Preview) — 59375de0 Deployed Aug 5, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action-view-helpers Action View helper support and metadata core @herb-tools/core shared AST nodes, interfaces, and utilities language-server @herb-tools/language-server and Language Server Protocol support linter @herb-tools/linter for HTML+ERB templates linter-rule Individual linter rules and their documentation typescript TypeScript source across the javascript/ packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant