pluginsync

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package pluginsync extracts the authoritative Gad language vocabulary (keywords, atoms, constants, builtin functions) from the gad/token packages and keeps the editor plugins (codemirror-gad, prism-gad) in sync with it.

The plugins hand-maintain JS/TS arrays of keywords and builtins; this package derives the current sets from the compiler so the cmd/update-*-plugin tools can add what is missing and report drift, instead of editing by hand.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Diff

func Diff(want, have []string) (added, removed []string)

Diff returns the entries present in want but not in have (added) and in have but not in want (removed).

func InsertItems

func InsertItems(src, name string, additions []string) (string, []string)

InsertItems adds additions to the named array (just before its closing `]`), indented like a fresh trailing line. It returns the new source and the items actually added (those not already present).

func LangCommitsSince

func LangCommitsSince(since string) []string

LangCommitsSince lists the one-line commits that touched the language sources (token, parser, compiler, builtins) since the given commit. When since is empty it returns the most recent such commits.

func LastCommit

func LastCommit(dir string) string

LastCommit returns the short hash of the most recent commit touching dir, or "" when the path has no history yet.

func ParseArray

func ParseArray(src, name string) (items []string, ok bool)

ParseArray returns the string items of the named array in src, or ok=false when the array is absent.

func Run

func Run(t Target, src string, write bool) (string, bool, error)

Run syncs a target file against the current language vocabulary. Missing entries are added (when write is set); plugin-only entries are reported but never removed (some are intentional contextual keywords). It also prints the language commits since the plugin's last update. Returns whether the file changed.

func RunCLI

func RunCLI(t Target)

RunCLI is the shared entry point for the update-*-plugin commands: it parses the `-w` flag, runs the sync against t.File and writes the result back when `-w` is given and something changed.

func TextMateGrammar

func TextMateGrammar() ([]byte, error)

TextMateGrammar generates the Gad TextMate grammar (source.gad) from the current language vocabulary, for the VS Code extension's syntax highlighting.

Types

type Lang

type Lang struct {
	Keywords  []string // `with`, `for`, `defer_ok`, … (word keywords)
	Atoms     []string // true, false, yes, no, nil
	Constants []string // STDIN, STDOUT, STDERR
	Builtins  []string // global builtin function names (no import)
}

Lang is the language vocabulary the plugins highlight.

func Extract

func Extract() Lang

Extract reads the current vocabulary from the compiler packages.

type Target

type Target struct {
	Name   string   // display name, e.g. "codemirror-gad"
	Dir    string   // plugin directory (for git history)
	File   string   // source file holding the vocabulary arrays
	Arrays []string // array names to sync: keywords, atoms, constants, builtins
}

Target describes a plugin to keep in sync.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL