[VS Code Extension]

PYNE — Pine Script™ for VS Code: HOOX branding, TextMate grammar, LanguageClient wiring, settings, and VSIX build.

VS Code Extension

Abstract

PYNE — Pine Script™ for VS Code 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 spawns pynescript-lsp (or a configured command) over STDIO via vscode-languageclient, maps *.pine / *.pinev5 / *.pinev6 to language id pinescript, and exposes a small settings surface for enablement and feature toggles.

Pine Script™ and TradingView® are trademarks of TradingView, Inc. This project is independent and is not affiliated with or endorsed by TradingView, Inc.

Conceptual model

Interface surface

Package identity

From vscode-extension/package.json:

FieldValue
namepyne
displayNamePYNE — Pine Script™ for VS Code
iconmedia/icon.png (HOOX mark)
engines.vscode^1.85.0
main./out/extension.js
dependencyvscode-languageclient ^9
galleryBanner#050505 dark

Language contribution

  • id: pinescript
  • aliases: Pine Script™, Pine Script, pinescript, Pine
  • extensions: .pine, .pinev5, .pinev6
  • 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:**/*.pine
workspaceContains:**/*.pinev5
workspaceContains:**/*.pinev6

Settings (pynescript.*)

KeyDefaultMeaning
lsp.enabledtrueSkip activation when false
lsp.commandautoServer executable / auto-detect
lsp.pythonpython3Interpreter for module launch
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
}

Commands

CommandAction
pynescript.restartServerclient.stop() then client.start()
pynescript.formatDocumenteditor.action.formatDocument

Client options

  • Document selector: pinescript for file and untitled schemes
  • File watcher: **/*.pine (not automatically the v5/v6 suffixes)
  • Diagnostic collection name: pynescript

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:

const serverOptions: ServerOptions = {
  command: lspCommand,           // default pynescript-lsp
  args: ['--parent-dir', scriptPath],
  transport: TransportKind.stdio,
  options: { env: { ...process.env, PYTHONPATH: scriptPath } },
};

scriptPath is resolved to ../src/pynescript/langserver relative to the extension for monorepo development. Release packaging typically expects pynescript-lsp on PATH (pip or Nuitka binary).

Build

cd vscode-extension
npm ci
npm run compile          # tsc → out/
npx vsce package         # VSIX
# or monorepo:
make build-vscode

Requires Node 22 tooling as noted in project agents docs for packaging.

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 pynescript[lsp] or the Nuitka onefile and set pynescript.lsp.command if not on PATH.
  3. Grammar works without LSP — open a .pine file offline and still get TextMate highlighting.
  4. File watcher only lists **/*.pine; v5/v6 still activate via language id on open.

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”pynescript-lsp missing / wrong command
No squiggles, highlighting OKLSP disabled or server crash; check Output → Pine Script Language Server
Restart does nothingClient never started (lsp.enabled false)

See also