Skip to content

Feat/lsp and ide experience#32

Merged
ulysse-bouchet-simvia merged 9 commits intomainfrom
feat/lsp-and-ide-experience
Apr 27, 2026
Merged

Feat/lsp and ide experience#32
ulysse-bouchet-simvia merged 9 commits intomainfrom
feat/lsp-and-ide-experience

Conversation

@ulysse-bouchet-simvia
Copy link
Copy Markdown
Collaborator

[1.10.0] - 2026-04-27

A broad LSP and IDE-experience pass: cave-driven catalog resolution, a TypeScript-style hover layer, context-aware autocompletion, edit-time diagnostics with quick fixes, a .comm formatter, a guided setup flow, and a new activity-bar panel that doubles as a command dictionary. The status bar slims to an icon and Output channels are grouped under a single code_aster: prefix.

Added

  • Catalog from cave — the language server now reads its catalog directly from the Docker image of the cave-selected code_aster version (extracted on demand to ~/.cache/vs-code-aster/catalogs/<version>/ and cached). A bundled 16.7 catalog ships as a zero-config fallback, so the editor still works when Docker / cave aren't installed. The selection follows ~/.cave live and an in-memory reconcile clears orphan caches when an image is removed.
  • Cave version picker — right-aligned status-bar item modeled on VS Code's Python interpreter chip. Shows the current version, click to switch / install / remove. Install runs cave use <v> with y piped in and reports progress through phases (Pulling / Downloading / Extracting / Finalizing). Cancellable.
  • Guided setup flow — a one-shot toast chain on first .comm / .export open walks the user through Python LSP deps (auto-installed into a managed venv at <globalStorage>/.venv), ruff, Docker, cave, and a code_aster image. Each step is opt-in with Install / Not now / Don't ask again, and the new code_aster: Run setup checks command re-fires the chain.
  • Activity-bar sidebar panel with seven groups: Setup (Setup (n/5), top when failing, bottom when healthy), Quick actions (filtered per active editor), Command browser (only when a .comm is active), Versions, Settings, External links, and the bottom Setup. The brand mark gets a tightened monochrome icon for the activity bar plus light/dark variants for in-tree use.
  • Command browser — five canonical families (Mesh / Material / BC & Loads / Analysis / Output), each listing the file's commands first (✓) then the rest of the catalog dim. Title-bar action runs a fuzzy Cmd+P-style QuickPick over every catalog command. Reads from CommandRegistry so it updates live without saving.
  • Hover rewrite — TypeScript-style cards inside a python code fence (signature → description → details → doc link). Required vs optional read as Python defaults, BLOC branches filter by the parameters already typed at the call site, regles rules render as a bullet list, and the doc link points at demo-docaster.simvia-app.fr/versions/v17/. Surfaces the translation={...} short labels when present and is locale-aware (FR / EN via LANG). Variants for command, keyword, allowed-value literal, factor marker, plain-Python variable assignment, and legacy-command notes.
  • Context-aware autocompletion — forward scanner replaces the old backward one (no longer confused by mid-edit unmatched quotes). Detects nested _F(...) scopes, suggests allowed into values when the cursor is in a value position, suggests previously-defined variables compatible with the SIMP's expected class (resolves callable sd_prod via __all__=True), and filters already-typed kwargs at every depth (not just the outer call). Snippet inserts: LIRE_MAILLAGE($0), KEY=$0, KEY=_F($0) — each retriggers the popup. Trigger characters expanded to (, ,, =, space; client-side hide-then-trigger keeps the suggest widget from sticking on "No suggestions".
  • Edit-time diagnostics for .comm files with quick-fix code actions: unknown command, unknown keyword, value not in into, missing required keyword, regles violations, undefined variable, type mismatch, and a soft information note for legacy commands. Quick fixes offer fuzzy-matched replacements (Levenshtein) and allowed-value swaps. Wrapped end-to-end so a CATA quirk can never block hover, completion, or formatting.
  • .comm formatter via python -m ruff format --quote-style=preserve --line-length=100. First-open prompt offers to install ruff with one click into the managed venv; PEP-668 retry with --user.
  • .comm syntax grammar overhaul — TextMate rules rewritten around a function-call begin/end block with a nested parens sub-block so _F(...), tuples, and multi-line kwargs all color correctly. Lowercase scientific notation, Python constants (None/True/False), and lowercase kwarg names are now recognized. Single-quote auto-close added; wordPattern keeps _ attached.
  • External links group in the sidebar (Star on GitHub, Rate on Marketplace, Browse code_aster website / documentation, Visit simvia.tech). Always at the bottom, always expanded.

Changed

  • Status bar down to a single icon: $(symbol-namespace) neutral when 3+ command families are present in the file, $(circle-outline) warning-tinted otherwise. Click opens and expands the sidebar's Command browser group.
  • Output channels unified under a code_aster: prefix — code_aster: Language Server (replaces the misleading Python Language Server), code_aster: Catalog, code_aster: Formatter. LSP error toasts updated accordingly.
  • Language aliases are now code_aster (comm) and code_aster (export).
  • Hover layout: signature first, then italic description, then details and rules, then doc-link footer. Drops the per-keyword inline # … doc strings to keep the signature scannable.
  • Dream background off by default for new users (existing explicit-on choices preserved).

Fixed

  • LSP restart() no longer recreates the LanguageClient, so hover / completion / code-action providers don't duplicate after cave use. Server env (catalog path) is refreshed by mutating serverOptions.options.env in place before bouncing.
  • Sidebar and status bar wait for an LspServer.onReady event to re-probe, so the Command browser populates without a file switch even when the LSP starts after activation.
  • Stale ~/.cave selections (image removed via docker rmi) now correctly fall back to the bundled catalog. The trash button on the version picker also clears the matching extracted-catalog cache.
  • .comm CommandRegistry falls back to a full reparse when a single-line edit is outside any tracked command, so newly-typed top-level commands register immediately.
  • pip install for ruff / LSP deps no longer passes --user unconditionally (broke venv installs); retried with --user only on PEP-668 errors.

…atter

- Catalog path now resolved from the cave-selected code_aster version: extract
  `code_aster/Cata/` from the matching Docker image to a per-version cache and
  inject via `VS_CODE_ASTER_CATA_PATH` so the LSP serves completion / hover /
  signatures for the version the user actually runs. Falls back to the bundled
  vendored catalog when Docker/cave are unavailable.
- New right-aligned status bar item (`CaveStatusBar`) mirrors VS Code's Python
  interpreter picker: click to switch, install (with auto-confirmed `y` prompt
  and progress notification), or remove versions. Reconciles orphan caches on
  startup and when images are removed.
- `HoverManager` rewritten as TypeScript-style Markdown: signature rendered as
  a python code fence (theme-highlighted), description italic paragraph below,
  rules list, `Search documentation for …` link. Handles command, keyword,
  factor marker, allowed-value literal, variable reference, and plain literal
  assignment hovers. Localized EN/FR via LANG env.
- `.comm` grammar rewritten around a `function-call` begin/end block with a
  nested `parens` sub-block so `_F(...)`, tuples, and multi-line kwargs all
  color correctly. Lowercase `e` in scientific notation, Python constants
  (`None/True/False`), and lowercase kwarg names are now supported.
- New `CommFormatter` shells out to `python -m ruff format --quote-style=preserve`
  for `.comm` files. First-open flow probes for ruff and offers a one-click
  `pip install ruff` with progress; retries with `--user` under PEP 668.
- Language aliases: `code_aster (comm)` and `code_aster (export)`.
- `examples/lsp_showcase.comm`: demo file exercising every LSP surface.
…ted-factor suggestions

Rewrites the completion path around a single forward scan that walks from
the enclosing command's start to the cursor, tracking paren depth, string
state, factor frames, and per-frame written kwargs. Replaces the previous
backward scan, which broke on mid-edit unmatched quotes.

Highlights:
- Trigger chars expanded to (, ',', =, space; client-side hide-then-trigger
  re-pops the suggest widget on each so it never sticks in "No suggestions".
- Snippet inserts: command → NAME($0) and re-triggers; kwarg → NAME=$0;
  factor kwarg → NAME=_F($0); value/variable → trailing ", " + retrigger
  unless it's the last param.
- Value position dispatch: shows allowed `into` literals, then variables
  whose source command's sd_prod is type-compatible (issubclass) with the
  expected SIMP class — including callable sd_prod resolved by inspecting
  its signature and passing __all__=True.
- Nested _F(...) keyword completion via factor path; written-kwarg filter
  also works inside factor scopes.
- Empty results in value position return is_incomplete=True so VS Code
  re-queries on the next keystroke.
- Registry: on_document_change falls back to a full reparse when the
  change line isn't in any tracked command, so newly-typed commands
  register without waiting for a multi-line edit.
- Disable editor.wordBasedSuggestions for [comm] so empty LSP results
  don't get padded with file-word noise.
- Showcase example removed; it served its purpose during development.
The LSP channel was previously named "Python Language Server" — misleading
since it serves code_aster, not Python. Renamed to "code_aster: Language
Server" and aligned the catalog/formatter channels to the same prefix so
they group together in VS Code's Output dropdown. LSP error toasts updated
accordingly. Internal LanguageClient id is unchanged to preserve any
saved user trace settings.
Collapses the install path from 8 manual README steps to "open a .comm
or .export file and click yes on the toasts". Setup is opt-in at every
step, with persisted "Don't ask again" choices in globalState.

Pieces:
- PythonEnv: shared probe/install helpers; auto-creates a managed venv
  in globalStorageUri when the user hasn't picked an interpreter, runs
  `pip install pygls numpy medcoupling` (PEP-668 fallback), and writes
  the venv path back to vs-code-aster.pythonExecutablePath.
- SetupOnboarding: orchestrates Python deps → ruff → Docker → cave →
  code_aster image. Cave install runs in an integrated terminal (sudo
  visible), then polls `which cave` for up to 5 min and chains into the
  version-install picker on success. Native Windows skips the auto path
  and opens the cave install instructions instead.
- SidebarView: new activity-bar view container with Setup / Quick
  actions / Versions / Settings groups. Setup auto-collapses when all
  five probes are green; per-setting icons; clicking a version row runs
  `cave use` directly, "Install another version…" goes straight to the
  install picker. Activity-bar icon is the simvia logo recolored to
  currentColor with a tightened viewBox to remove the original padding.
- CommFormatter is constructed with the extension context now and uses
  the shared Python helpers; the embedded ruff prompt moves into the
  onboarding chain.
- Two new commands: vs-code-aster.runSetup (force the chain) and
  vs-code-aster.switchCaveVersion / .installCaveVersion (sidebar-only
  direct entry points).
Surfaces eight categories of issue as VS Code Diagnostics, all sourced
from the existing CommandRegistry + CATA introspection: unknown
command, unknown keyword, value-not-in-into, missing required keyword,
regles violation, undefined variable, variable type mismatch, and a
soft information-level note for legacy/boilerplate commands. Quick
fixes are offered for the high-confidence cases (fuzzy-match command
or keyword name; pick from allowed values).

Robustness — every CATA touch is wrapped so a single quirky catalog
entry can't crash the LSP or shadow other features. validate() always
returns a (possibly empty) list, never raises; the publish helper
swallows exceptions and falls back to clearing diagnostics.

The extra `---` HR before the doc link in hovers is removed: when VS
Code stacks multiple hover contributions (our hover + a diagnostic),
the rule was only as wide as our block and looked broken.

New: validators.py (shared CATA helpers), diagnostics_manager.py,
code_action_manager.py, position-aware parse_keyword_positions on
CommandRegistry. Wired into handlers.py with a 200ms debounce on
didChange.
Previously each restart constructed a new LanguageClient, which
re-registered hover/completion/code-action providers on top of the
existing ones — hence duplicate tooltips after every cave use. The
intermediate fix (dispose the old client) introduced a different bug:
VS Code kept calling the disposed client's code-action provider until
its provider list was purged, throwing "Client got disposed and can't
be restarted".

Solution: keep a single LanguageClient for the extension lifetime and
just stop()/start() it on restart. Server-side env (catalog path) is
refreshed by mutating the saved serverOptions.options.env in place;
LanguageClient re-reads it on each spawn.
Cosmetic feature was opt-in by intent but shipped opt-out. Users who
explicitly enabled it keep their preference; users on the original
default switch to off on next reload. Updates package.json, the
webview-side fallbacks, and the popup's reset target so all four
defaults agree.
…links

Rework the sidebar into a single home for navigation, browsing, and
discovery so the status bar can shed its drilldown.

- Command browser: a new collapsible group lists the five canonical
  command families with the file's commands first (✓) and the rest of
  the catalog dim. Visible only when a .comm file is active. Search
  action in the view title bar runs a fuzzy QuickPick over the full
  catalog.
- Quick actions reshape per active editor: New export file / Restart
  language server / Show catalog info are always there; Run with
  code_aster only on .export; Open mesh viewer only on .comm and
  configured MED extensions. Run setup checks moved out (still
  reachable via the Setup group rows or palette).
- External group at the very end, always expanded: Star on GitHub /
  Rate on Marketplace / Browse code_aster website / Browse code_aster
  documentation / Visit simvia.tech. The website row uses light/dark
  variants of the brand mark so it matches the surrounding codicon
  foreground.
- Setup floats: at the top when any probe fails (auto-expanded), at
  the bottom as `Setup (n/5)` when healthy (collapsed).

Status bar now a single icon — neutral when 3+ command families are
present in the file, warning-tinted otherwise — that opens and expands
the Command browser group on click. The disk-read analyzer in
status_bar_manager.py is replaced by a registry walk so unsaved edits
are reflected immediately.

LspServer fires an `onReady` event on start/restart; the sidebar and
status bar listen so their first probe (which lands before the server
is up) self-corrects without a file switch.
@ulysse-bouchet-simvia ulysse-bouchet-simvia self-assigned this Apr 27, 2026
@ulysse-bouchet-simvia ulysse-bouchet-simvia merged commit bd6272f into main Apr 27, 2026
5 checks passed
@ulysse-bouchet-simvia ulysse-bouchet-simvia deleted the feat/lsp-and-ide-experience branch April 27, 2026 15:11
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