VS Code Extension

PYNE VS Code extension: HOOX branding, TextMate grammar, LanguageClient wiring, settings, and VSIX build.

This page

VS Code Extension

Abstract

PYNE (hoox-sh.pyne 0.4.4) is a LanguageClient host plus a rich TextMate grammar, branded as part of the HOOX open trading stack. It does not reimplement diagnostics or completion in TypeScript; it resolves pyne-lsp (then alias pynescript-lsp, then python -m pynescript.langserver) or a configured command over STDIO via vscode-languageclient, maps .pyne (first-class) plus *.pine / *.pinev5 / *.pinev6 / *.pinescript to language id pinescript, and exposes a small settings surface for enablement and feature toggles.

Conceptual model

Diagram

Rendering…

Interface surface

Package identity

From vscode-extension/package.json:

FieldValue
namepyne
displayNamePYNE Language Support
version0.4.4
publisherhoox-sh
extension idhoox-sh.pyne
iconmedia/icon.png (HOOX mark)
engines.vscode^1.91.0
main./out/extension.js (esbuild bundle)
dependencyvscode-languageclient ^10
galleryBanner#050505 dark

Language contribution

  • id: pinescript
  • aliases: PYNE, pyne, pinescript, Pine
  • extensions: .pyne (first), .pine, .pinev5, .pinev6, .pinescript
  • configuration: language-configuration.json
  • grammar: syntaxes/pinescript.tmLanguage.json (scopeName: source.pinescript) — namespaces, annotations, hex colors, UDT/enum, multiline strings, plot/strategy builtins

Activation

onLanguage:pinescript
workspaceContains:**/*.pyne
workspaceContains:**/*.pine
workspaceContains:**/*.pinev5
workspaceContains:**/*.pinev6

Settings (pynescript.*)

KeyDefaultMeaning
lsp.enabledtrueSkip activation when false
lsp.commandautoauto = PATH pyne-lsppynescript-lsppython -m pynescript.langserver. Or an absolute path. "docker" plus lsp.args can launch ghcr.io/hoox-sh/pyne/lsp (${workspaceFolder} is expanded).
lsp.pythonpython3Interpreter for module launch when neither binary is on PATH (pip install "hoox-pyne[lsp]")
lsp.args[]Extra server args
formatting.enabledtruePassed as init option
diagnostics.enabledtruePassed as init option
completion.snippetstruePassed as init option

Initialization options object:

{
  "formattingEnabled": true,
  "snippetsEnabled": true,
  "diagnosticsEnabled": true
}

The Python server does not read these flags today. They are client-side documentation for hosts; capability advertisement is unconditional in config.py.

Commands

Command paletteIDAction
PYNE: Restart Language Serverpynescript.restartServerStop then start the language client
PYNE: Format Documentpynescript.formatDocumenteditor.action.formatDocument (.pyne / .pine)
PYNE: Convert to Pine v6pynescript.convertToV6Rewrite v1-v5 source toward v6 (LSP command or local Python)
PYNE: Show Language Server Outputpynescript.showLspOutputOpen Output channel / status-bar target
PYNE: Show Resolved LSP Launch Commandpynescript.showLspCommandShow and copy resolved pyne-lsp launch

Client options

  • Document selector: pinescript for file and untitled schemes
  • File watcher: **/*.{pyne,pine,pinev5,pinev6,pinescript}
  • Diagnostic collection name: pynescript
  • Default formatter id: hoox-sh.pyne

Internals

PathRole
vscode-extension/src/extension.tsActivate / deactivate / client
vscode-extension/package.jsonContributes + scripts
vscode-extension/syntaxes/pinescript.tmLanguage.jsonGrammar
vscode-extension/language-configuration.jsonBrackets / comments
out/extension.jsCompiled JS

Server launch (resolveLspLaunch in extension.ts):

  1. If pynescript.lsp.command is not auto, spawn that command with lsp.args.
  2. Else try pyne-lsp, then pynescript-lsp, on PATH.
  3. Else try pynescript.lsp.python (then python3 / python) with -m pynescript.langserver.
  4. Else status-bar error: install hoox-pyne[lsp].

No --parent-dir / PYTHONPATH rewrite. Transport is STDIO. Release packaging expects pyne-lsp on PATH (pip, Nuitka onefile, or docker run -i ghcr.io/hoox-sh/pyne/lsp:0.4.4).

Build

cd vscode-extension
npm ci
npm run compile          # esbuild.mjs → out/extension.js
npm run package          # pyne-vscode-0.4.4.vsix
# or monorepo:
make build-vscode

Requires Node 22. compile:tsc is typecheck-only (tsc --noEmit).

Site download: https://hoox.sh/pyne-vscode.vsix (unversioned alias). Versioned pyne-vscode-0.4.4.vsix is built in-tree (vscode-extension/) and on GitHub Releases.

Invariants and edge cases

  1. lsp.enabled === false short-circuits activate — no client, no restart command registration beyond early return (commands not registered).
  2. Binary vs module: production users should install hoox-pyne[lsp] or the Nuitka onefile (pynescript-lsp-* on GitHub Releases) and set pynescript.lsp.command if not on PATH.
  3. Grammar works without LSP — open a .pyne or .pine file offline and still get TextMate highlighting.
  4. .pyne is first-class in package.json extensions + activation; legacy .pine* / .pinescript remain fully supported.
  5. File watcher covers every associated suffix (pyne, pine, pinev5, pinev6, pinescript).

Worked example — extension development

pip install -e ".[lsp]"
cd vscode-extension && npm ci && npm run compile
# Launch Extension Development Host pointing at vscode-extension

Open a fixture .pine file; confirm Problems panel shows parse/lint diagnostics from the Python server.

Failure modes

SymptomCause
“Language client failed to start”pyne-lsp missing / wrong command
No squiggles, highlighting OKLSP disabled or server crash; check Output → PYNE Language Server
Restart does nothingClient never started (lsp.enabled false)

See also