VS Code Extension

PYNE VS Code extension: LanguageClient host for pyne-lsp, TextMate grammar, snippets, settings, and VSIX 0.5.5.

This page

Abstract

PYNE (hoox-sh.pyne 0.5.5) is a LanguageClient host plus a rich TextMate grammar, branded as part of the HOOX open trading stack. It does not reimplement language intelligence in TypeScript — vscode-languageclient speaks STDIO to pyne-lsp (then alias pynescript-lsp, then python -m pynescript.langserver) and forwards whatever that process advertises in initialize. The VSIX stays 0.5.5; the hosted Python server is hoox-pyne 0.6.31 (src/pynescript/__about__.py). The extension maps .pyne (first-class) plus *.pine / *.pinev5 / *.pinev6 / *.pinescript to language id pinescript, ships snippets, and exposes a broad pynescript.* settings surface with per-feature toggles.

Conceptual model

Diagram

Rendering…

Interface surface

Package identity

From the extension's package.json (hoox-sh/pyne-lsp-vsce):

FieldValue
namepyne
displayNamePYNE Language Support
version0.5.5
publisherhoox-sh
extension idhoox-sh.pyne
iconmedia/icon.png (HOOX mark)
engines.vscode^1.91.0
main./out/extension.js (esbuild bundle)
dependencyvscode-languageclient ^11
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, bitwise operators (&, |, ^, ~, <<, >>), annotations, hex colors, # line comments that do not steal #hex literals, UDT/enum, multiline strings, plot/strategy builtins
  • snippets: snippets/pine.code-snippets — indicator, strategy, library, type, enum, input.* (incl. color/timeframe/session), plot, plotshape, ta.* (incl. macd/bb), strategy.entry/exit/close, if/for/for in/switch, request.security, label.new, array.new<>, multiline string

Hosted pyne-lsp methods (not reimplemented in TypeScript)

The LanguageClient negotiates capabilities from src/pynescript/langserver/config.py (get_server_capabilities). The hosted server now advertises the following; the 0.5.5 extension is still only a host, but adds client-side feature gates so each capability can be toggled without restarting the server.

LSP methodWhat the editor getsFeature page
textDocument/semanticTokens/full + /rangeSame legend, range clipped to the viewportSemantic tokens
textDocument/onTypeFormattingFormat the just-completed line; trigger "\n"Formatting
textDocument/linkedEditingRangeSame-document live ranges for a user ident (keywords / builtin namespaces refused)Linked editing
textDocument/inlayHintDisplay-only parameter-name hints on builtin calls (ta.sma(close, 14) → source: / length:). Hints never insert textInlay hints
textDocument/documentLink + documentLink/resolvehttp:// / https:// URLs in comments (//, /* */, hash # …) and string literals. Resolve fills tooltip with the URL when tooltip is unsetDocument links
textDocument/documentColor + colorPresentation#hex (and named color.* / literal color.rgb / color.new / color() / color.from_gradient) swatches; presentation rewrites as #rrggbb / #rrggbbaaDocument color

Also advertised (unchanged host path): diagnostics, completion + resolve, hover, signature help, definition / references, highlight + rename, document / workspace symbols, full + range formatting, folding, selection range, Convert-to-v6 / W001 / W002 / C002 code actions. Capability table: Architecture.

[pinescript] configuration defaults already set editor.semanticHighlighting.enabled to true and editor.defaultFormatter to hoox-sh.pyne. Format-on-type and linked-editing UX are standard VS Code editor settings (editor.formatOnType, editor.linkedEditing) — they are not pynescript.* keys. Enable them if you want Enter to hit onTypeFormatting or rename-as-you-type to hit linkedEditingRange.

Activation

text
onLanguage:pinescript
onCommand:pynescript.restartServer
onCommand:pynescript.formatDocument
onCommand:pynescript.showLspOutput
onCommand:pynescript.showLspCommand
onCommand:pynescript.convertToV6
onCommand:pynescript.diagnosticsToggle
onCommand:pynescript.completionToggle
onCommand:pynescript.inlayHintsToggle
onCommand:pynescript.foldingToggle
onCommand:pynescript.colorPreviewToggle
onCommand:pynescript.toggleHover
onCommand:pynescript.toggleSignatureHelp
onCommand:pynescript.toggleSemanticTokens
onCommand:pynescript.toggleDocumentHighlight
onCommand:pynescript.toggleLinkedEditing
onCommand:pynescript.toggleSelectionRange
onCommand:pynescript.toggleDocumentLink
onCommand:pynescript.toggleCodeAction
onCommand:pynescript.toggleFormatOnSave
onCommand:pynescript.openDocumentLink
onCommand:pynescript.runOnPro
onCommand:pynescript.installLanguageServer
onCommand:pynescript.installBackend
onCommand:pynescript.startBackend
onCommand:pynescript.testBackend
onCommand:pynescript.selectSyntax
workspaceContains:**/*.pyne
workspaceContains:**/*.pine
workspaceContains:**/*.pinev5
workspaceContains:**/*.pinev6

Settings (pynescript.*)

Appearance

KeyDefaultMeaning
pynescript.syntaxHighlightingvoidPine token palette (TextMate + semantic tokens), independent of the workbench theme. none inherits the active theme.

Language server

KeyDefaultMeaning
pynescript.lsp.enabledtrueStart the language client
pynescript.lsp.commandautoauto (PATH → module), an absolute binary path, or docker
pynescript.lsp.pythonpython3Interpreter for -m pynescript.langserver
pynescript.lsp.args[]Extra server arguments (docker run arguments when command is docker)

Editor features

KeyDefaultMeaning
pynescript.formatting.enabledtrueFormatting — full document, selection, on-type
pynescript.formatOnSave.enabledfalseFormat on save (requires formatting.enabled)
pynescript.diagnostics.enabledtrueErrors, warnings, and hints
pynescript.diagnostics.severity{}Remap severity by lint-code prefix, e.g. {"W": "Hint"}
pynescript.diagnostics.stylefalseShow C001/C002/C004 style findings
pynescript.diagnostics.semanticfalseOpt-in UDT/enum member and user-function arity checks
pynescript.completion.snippetstrueSnippets for builtins and declarations
pynescript.hover.enabledtrueHover cards (signature, docs, types)
pynescript.inlayHints.parameterstrueParameter-name hints in calls
pynescript.signatureHelp.enabledtrueParameter hints while typing a call
pynescript.semanticTokens.enabledtrueSemantic token colorization
pynescript.documentHighlight.enabledtrueHighlight other occurrences of an identifier
pynescript.linkedEditing.enabledtrueRename-as-you-type (needs editor.linkedEditing)
pynescript.selectionRange.enabledtrueSmart expand/shrink selection
pynescript.documentLink.enabledtrueClickable http(s) URLs in comments and strings
pynescript.codeAction.enabledtrueCode actions (Convert to v6, W001 quick fix)

Feature settings are sent to the server through workspace/didChangeConfiguration and take effect without restarting the client. Only pynescript.lsp.* changes restart the language server.

Installation

KeyDefaultMeaning
pynescript.install.autoInstallfalseInstall the server with pip when missing, without prompting
pynescript.install.autoPrompttrueAsk once before installing a missing server
pynescript.install.packagehoox-pyne[lsp]pip requirement installed by PYNE: Install Language Server
pynescript.install.python""Python for pip (empty = lsp.python → python3 → python → py)
pynescript.install.args[]Extra pip arguments (e.g. ["--no-cache-dir"])
pynescript.install.createVenvtrueIsolated venv when the system Python is PEP 668 managed
pynescript.install.venv""Explicit venv directory (empty = extension storage)

Pro & backend

KeyDefaultMeaning
pynescript.pro.enabledfalseEnable PYNE Pro (Run on Pro)
pynescript.pro.apiKey""Pro API key, minted with POST /auth/create_key; stored in settings in plain text
pynescript.backend.urlhttp://127.0.0.1:5002Self-hosted backend base URL (no /run)
pynescript.backend.useHostedfalseUse pynescript.online instead of backend.url
pynescript.backend.hostedUrlhttps://pynescript.onlineHosted backend base URL
pynescript.backend.packagehoox-pyne[pro,lsp]pip requirement installed by PYNE: Install Backend (Pro API)
pynescript.backend.path""PYNE checkout for PYNE: Start Backend (empty = first workspace folder)

Themes (AXIS Void / Hoox Signal / PYNE Volt)

The extension contributes three color themes. Pick one from the normal VS Code Preferences: Color Theme picker — the extension never changes workbench.colorTheme automatically, not on activation and not on install.

ThemeAccentSurfaces
AXIS Voidperiwinkle #939FFFNear-black with a whisper of indigo; dark-grey panels
Hoox Signalsignal orange #FE6A00Near-black, neutral surfaces
PYNE Voltlime #B7EF09Near-black with a whisper of lime

Hover, suggest, peek, inlay, and the other floating widgets share AXIS popover chrome (1px hairline, elevated plate, accent selection). Hover and completion Markdown use the same kind-kicker card.

Comments are always neutral gray in every theme. Keywords and functions take the accent, strings a light accent tint, numbers the foreground, and punctuation / series builtins gray — so a file stays calm even with a vivid accent.

Pine syntax highlighting is independent of the workbench theme:

OptionSettingValuesnone means
Syntax highlightingpynescript.syntaxHighlightingnone · void · signal · voltUse the active theme's Pine colors

It writes language-scoped [pinescript] token colors, so it composes with any workbench theme — including your own. Switch it with PYNE: Select Syntax Highlighting or set the key directly. Default: void.

Invariants and edge cases

  1. lsp.enabled === false skips starting the client — output channel, status bar, and palette commands still register so the palette never shows “command not found”; restart then no-ops until the setting is true.
  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).
  6. VSIX 0.5.5 does not pin server methods. Range tokens, on-type format, linked editing, inlay parameter names, document links + resolve tooltip, and document color appear only when the spawned pyne-lsp is new enough to advertise them (this tree: 0.6.31). Feature gates are client-side and read live settings.

Worked example — extension development

bash
pip install -e ".[lsp]"
git clone https://github.com/hoox-sh/pyne-lsp-vsce.git
cd pyne-lsp-vsce && npm ci && npm run compile
# Launch Extension Development Host pointing at the pyne-lsp-vsce checkout

Open a fixture .pine file; confirm Problems panel shows parse/lint diagnostics from the Python server. With a current pyne-lsp, also expect #hex color swatches, clickable https:// links in comments, source: / length: inlay labels on ta.sma(close, 14), and range semantic tokens while scrolling.

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)
No inlay param names / color swatches / document linksSpawned pyne-lsp is older than this tree (need 0.6.31)
Enter does not reformat the previous lineeditor.formatOnType is off (not a pynescript.* key)
Identifiers do not multi-cursor as you typeeditor.linkedEditing is off (not a pynescript.* key)
A feature does nothing after togglingIts pynescript.<feature>.enabled key is false
Run on Pro says “disabled”Set pynescript.pro.enabled (and pro.apiKey for hosted)
Run on Pro request failsCheck pynescript.backend.url / backend.useHosted (base URL, no /run) and that the backend is reachable

See also