[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:
| Field | Value |
|---|---|
| name | pyne |
| displayName | PYNE — Pine Script™ for VS Code |
| icon | media/icon.png (HOOX mark) |
| engines.vscode | ^1.85.0 |
| main | ./out/extension.js |
| dependency | vscode-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.*)
| Key | Default | Meaning |
|---|---|---|
lsp.enabled | true | Skip activation when false |
lsp.command | auto | Server executable / auto-detect |
lsp.python | python3 | Interpreter for module launch |
lsp.args | [] | Extra server args |
formatting.enabled | true | Passed as init option |
diagnostics.enabled | true | Passed as init option |
completion.snippets | true | Passed as init option |
Initialization options object:
{
"formattingEnabled": true,
"snippetsEnabled": true,
"diagnosticsEnabled": true
}
Commands
| Command | Action |
|---|---|
pynescript.restartServer | client.stop() then client.start() |
pynescript.formatDocument | editor.action.formatDocument |
Client options
- Document selector:
pinescriptforfileanduntitledschemes - File watcher:
**/*.pine(not automatically the v5/v6 suffixes) - Diagnostic collection name:
pynescript
Internals
| Path | Role |
|---|---|
vscode-extension/src/extension.ts | Activate / deactivate / client |
vscode-extension/package.json | Contributes + scripts |
vscode-extension/syntaxes/pinescript.tmLanguage.json | Grammar |
vscode-extension/language-configuration.json | Brackets / comments |
out/extension.js | Compiled 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
lsp.enabled === falseshort-circuits activate — no client, no restart command registration beyond early return (commands not registered).- Binary vs module: production users should install
pynescript[lsp]or the Nuitka onefile and setpynescript.lsp.commandif not on PATH. - Grammar works without LSP — open a
.pinefile offline and still get TextMate highlighting. - 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
| Symptom | Cause |
|---|---|
| “Language client failed to start” | pynescript-lsp missing / wrong command |
| No squiggles, highlighting OK | LSP disabled or server crash; check Output → Pine Script Language Server |
| Restart does nothing | Client never started (lsp.enabled false) |
See also
- Clients — non-VS Code hosts
- Architecture
- Nuitka build
- Editors guide