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 ¶
- func Diff(want, have []string) (added, removed []string)
- func InsertItems(src, name string, additions []string) (string, []string)
- func LangCommitsSince(since string) []string
- func LastCommit(dir string) string
- func ParseArray(src, name string) (items []string, ok bool)
- func Run(t Target, src string, write bool) (string, bool, error)
- func RunCLI(t Target)
- func TextMateGrammar() ([]byte, error)
- type Lang
- type Target
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Diff ¶
Diff returns the entries present in want but not in have (added) and in have but not in want (removed).
func InsertItems ¶
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 ¶
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 ¶
LastCommit returns the short hash of the most recent commit touching dir, or "" when the path has no history yet.
func ParseArray ¶
ParseArray returns the string items of the named array in src, or ok=false when the array is absent.
func Run ¶
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 ¶
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.
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.