Reference: profile
Neutral, exhaustive description of
rickub.com/turbo-editors/turbo-core/profile.
Profile is the value an editor built on turbo-core differs by. Every field that would otherwise be a hardcoded name, path or command is here.
Profile
| Field | Type | Default | Description |
|---|---|---|---|
Name |
string |
"" |
What the editor calls itself, in window titles and the About box. "Turbo Go". Also sent to the language server as the client's name. |
Slug |
string |
"" |
Its one-word name. "turbo-go". The binary, the project directory, the user directory and the environment variables are all derived from it. |
Language |
string |
"" |
What the editor is for, in prose meant to be read. "Go", "Rust". Appears in messages and in the About box, not in file formats. |
ToolsMenu |
string |
"" |
The label of the toolchain menu, with its hot key marked between tildes. "~G~o", "Rus~t~". |
RootMarkers |
[]string |
nil |
Files that mark a project's root, in the order they are looked for. ["go.mod"], ["Cargo.toml"]. Empty means no walk up. |
Server |
Server |
zero | The language server. The zero value means the editor runs without one. |
Templates |
Templates |
zero | The starter files the editor offers to write. |
Derived values
| Method | Returns | Example for Slug: "turbo-go" |
|---|---|---|
ProjectDir() |
string |
".turbo-go" |
UserDir() |
string |
"~/.config/turbo-go", or "" when the system has no configuration directory |
ThemeDir() |
string |
"~/.config/turbo-go/themes", or "" |
DirEnvVar() |
string |
"TURBO_GO_DIR" |
ThemeDirEnvVar() |
string |
"TURBO_GO_THEME_DIR" |
SnippetDirEnvVar() |
string |
"TURBO_GO_SNIPPET_DIR" |
UserDir returns the value of DirEnvVar when it is set. ThemeDir returns the value of ThemeDirEnvVar when it is set, and that variable names the theme directory itself rather than the directory above it.
A slug's dashes become underscores in an environment variable name: turbo-rust gives TURBO_RUST_THEME_DIR.
Server
| Field | Type | Default | Description |
|---|---|---|---|
Command |
string |
"" |
The executable's name, looked up on PATH first. "gopls", "rust-analyzer". |
Args |
[]string |
nil |
The arguments it is started with. gopls takes ["serve"]; rust-analyzer takes none. |
InstallHint |
string |
"" |
One command the user can copy when the server is missing. Shown on the status bar, so it must fit on a line. |
Dirs |
[]string |
nil |
Extra directories searched after PATH, in order. Empty strings are skipped. |
Example
profile.Server{
Command: "gopls",
Args: []string{"serve"},
InstallHint: "go install golang.org/x/tools/gopls@latest",
Dirs: []string{goBinDir()},
}
Templates
| Field | Type | Formatting arguments, in order |
|---|---|---|
Settings |
string |
the theme name (%q), the autosave delay (%q) |
Snippets |
string |
the ungrouped group's name (%s), the user's own snippets path (%s) |
Tools |
string |
none |
A template with the wrong number of verbs produces %!s(MISSING) or %!(EXTRA …) in the file that is written; nothing checks it for you.
Example
const settingsTemplate = `# turbo-go project settings.
[editor]
theme = %q
autosave = false
autosave_delay = %q
`
Errors
profile returns no errors. A Profile with an empty Slug produces a project directory called "." and environment variables called _DIR; nothing refuses it.
See also
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
|