turbo-editors/turbo-golopublic Fork 0
main
Commits
Clone
git clone https://git.rickub.com/turbo-editors/turbo-golo.git
git clone ssh://git@rickub.com/turbo-editors/turbo-golo.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

templates.go · 72 lines · 3.3 KBGo Blame HistoryRaw
📦 Turbo Golo d710c1b k33g 23h ago1package gololang
2
3import _ "embed"
4
5// The starter files Turbo Golo writes into a project's .turbo-golo directory.
6//
7// They live in four files beside this one and are embedded into the binary at
8// compile time. Written out as text rather than encoded from structs because
9// they are meant to be read and edited by a person: the comments in them say
10// what each key is for, which is the whole reason the editor offers to create
11// them at all rather than only to read them.
12//
13// Their contents are the one part of these four files that is about Golo
14// rather than about editing, which is why they live here and not in turbo-core.
15//
16// **The .tmpl suffix is not decoration.** Each file is formatted with
17// fmt.Sprintf before it is written, and settings.toml.tmpl holds `theme = %q`
18// — which is not valid TOML. Naming it settings.toml would be a claim it
19// cannot meet: a TOML linter would reject it, and Turbo Golo itself would
20// colour it as TOML and draw it as broken. The blanks each one takes are
21// documented on profile.Templates, and templates_test.go holds them to it.
22
23// settingsTemplate is the settings file a project gets when it asks for one.
24//
25// autosave is on: a project that has gone to the trouble of creating a
26// settings file has said what it wants, and the file is the visible, editable
27// place to say otherwise. settings.Default() — what applies with no file at
28// all — stays off.
29//
30//go:embed settings.toml.tmpl
31var settingsTemplate string
32
33// snippetsTemplate is the snippets file a project gets when it asks for one.
34//
35// It lists every language name the editor knows in its `languages` comment,
36// because that comment is where a user finds out what they may write there. A
37// test iterates syntax.Registered() rather than a hardcoded list, so the
38// comment cannot fall behind the registry.
39//
40// Every Golo body in it is a TOML *literal* multi-line string — the form
41// written with three apostrophes rather than three double quotes. (Spelling
42// that out in words is deliberate: gofmt rewrites a bare run of apostrophes in
43// a doc comment into typographic quotes.) Golo strings carry \n and \" the way
44// Go's do, and TOML's basic strings would interpret those escapes before the
45// editor ever saw them — so a snippet with a newline in a string would be
46// inserted with a real line break in it. In a literal string a backslash is
47// just a backslash, which is what a Golo snippet needs.
48//
49//go:embed snippets.toml.tmpl
50var snippetsTemplate string
51
52// toolsTemplate is the tools file a project gets when it asks for one.
53//
54// Nine commands, and the two features that are invisible otherwise: a
55// {{placeholder}} that asks for a value before the command runs, and the
56// `menu` key that puts a tool in a menu of its own.
57//
58// Run comes first, because Golo is a scripting language and running the file
59// is the thing a Golo programmer does most. It gets a terminal rather than a
60// popup, because a script that reads the keyboard has to be answerable.
61//
62//go:embed tools.toml.tmpl
63var toolsTemplate string
64
65// agentsTemplate is the agents file a project gets when it asks for one.
66//
67// It takes two blanks, in this order: the editor's own project directory —
68// which the example agent's arguments point into — and the path to the user's
69// own agents file, which a comment names.
70//
71//go:embed acp.toml.tmpl
72var agentsTemplate string