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

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

templates.go · 72 lines · 3.3 KBGo Blame HistoryRaw
📦 Turbo MoonBit cc1f595 k33g 10h ago1package moonbitlang
2
3import _ "embed"
4
5// The starter files Turbo MoonBit writes into a project's .turbo-moonbit
6// directory.
7//
8// They live in four files beside this one and are embedded into the binary at
9// compile time. Written out as text rather than encoded from structs because
10// they are meant to be read and edited by a person: the comments in them say
11// what each key is for, which is the whole reason the editor offers to create
12// them at all rather than only to read them.
13//
14// Their contents are the one part of these four files that is about MoonBit
15// rather than about editing, which is why they live here and not in turbo-core.
16//
17// **The .tmpl suffix is not decoration.** Each file is formatted with
18// fmt.Sprintf before it is written, and settings.toml.tmpl holds `theme = %q`
19// — which is not valid TOML. Naming it settings.toml would be a claim it
20// cannot meet: a TOML linter would reject it, and Turbo MoonBit itself would
21// colour it as TOML and draw it as broken. The blanks each one takes are
22// documented on profile.Templates, and templates_test.go holds them to it.
23
24// settingsTemplate is the settings file a project gets when it asks for one.
25//
26// autosave is on: a project that has gone to the trouble of creating a
27// settings file has said what it wants, and the file is the visible, editable
28// place to say otherwise. settings.Default() — what applies with no file at
29// all — stays off.
30//
31//go:embed settings.toml.tmpl
32var settingsTemplate string
33
34// snippetsTemplate is the snippets file a project gets when it asks for one.
35//
36// It lists every language name the editor knows in its `languages` comment,
37// because that comment is where a user finds out what they may write there. A
38// test iterates syntax.Registered() rather than a hardcoded list, so the
39// comment cannot fall behind the registry.
40//
41// Every MoonBit body in it is a TOML *literal* multi-line string — the form
42// written with three apostrophes rather than three double quotes. (Spelling
43// that out in words is deliberate: gofmt rewrites a bare run of apostrophes in
44// a doc comment into typographic quotes.) MoonBit interpolates with \{…}, and
45// a backslash before a brace is not one of TOML's escape sequences — so a body
46// written in basic strings would not parse, and the snippets file the editor
47// had just offered to create would be refused the moment it was read back.
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// Eight 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// `moon check` comes first rather than `moon build`, because it is the command
59// that answers "is this sound?" without producing anything, and it is what the
60// MoonBit toolchain itself puts in a project's pre-commit hook.
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