@narumitw/pi-starship 0.66.0 → 0.67.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +4 -2
- package/dist/chunks/{chunk-BOMYDCT7.ts → chunk-URY35OTN.ts} +3 -3
- package/dist/chunks/{chunk-CUXPMKBQ.ts → chunk-VK26JO5L.ts} +16 -3
- package/dist/chunks/chunk-VK26JO5L.ts.map +7 -0
- package/dist/chunks/{chunk-UZJIMIWL.ts → chunk-WZ2FWJHK.ts} +2 -2
- package/dist/chunks/{command-configuration-menu-N3SP6R3I.ts → command-configuration-menu-3MMJJX4D.ts} +3 -3
- package/dist/chunks/{command-settings-chat-4NLO3RDC.ts → command-settings-chat-NB6YCNUD.ts} +4 -4
- package/dist/chunks/{commands-MSJ67CTR.ts → commands-HT6MGWJV.ts} +6 -6
- package/dist/index.ts +68 -30
- package/dist/index.ts.map +2 -2
- package/package.json +1 -1
- package/skills/configure-pi-starship/SKILL.md +3 -1
- package/skills/configure-pi-starship/references/configuration.md +81 -14
- package/skills/configure-pi-starship/references/module-catalog.md +5 -3
- package/skills/configure-pi-starship/references/modules.md +4 -1
- package/src/config.ts +2 -1
- package/src/modules/extension-status.ts +3 -2
- package/src/modules/inspection.ts +3 -2
- package/src/modules/render.ts +78 -31
- package/src/root-references.ts +15 -0
- package/dist/chunks/chunk-CUXPMKBQ.ts.map +0 -7
- /package/dist/chunks/{chunk-BOMYDCT7.ts.map → chunk-URY35OTN.ts.map} +0 -0
- /package/dist/chunks/{chunk-UZJIMIWL.ts.map → chunk-WZ2FWJHK.ts.map} +0 -0
- /package/dist/chunks/{command-configuration-menu-N3SP6R3I.ts.map → command-configuration-menu-3MMJJX4D.ts.map} +0 -0
- /package/dist/chunks/{command-settings-chat-4NLO3RDC.ts.map → command-settings-chat-NB6YCNUD.ts.map} +0 -0
- /package/dist/chunks/{commands-MSJ67CTR.ts.map → commands-HT6MGWJV.ts.map} +0 -0
package/package.json
CHANGED
|
@@ -91,7 +91,9 @@ Do not redirect this workflow to `starship.toml`, `pi-statusline.json`, project-
|
|
|
91
91
|
|
|
92
92
|
Preserve comments, ordering, unknown fields, and unrelated custom settings unless the user explicitly requests a complete replacement.
|
|
93
93
|
|
|
94
|
-
Keep the root `format` limited to module names and `$
|
|
94
|
+
Keep the root `format` limited to module names, `$all`, and exact `${extension_status.<raw-key>}` references as defined in [individual extension statuses](references/configuration.md#individual-extension-statuses).
|
|
95
|
+
|
|
96
|
+
Do not infer status-key aliases or convert `:` to `.` in raw keys.
|
|
95
97
|
|
|
96
98
|
Keep each module's `format` limited to that module's documented variables and style variables.
|
|
97
99
|
|
|
@@ -286,18 +286,7 @@ Module-specific options are catalog-owned and type-checked; unknown options warn
|
|
|
286
286
|
[Version formats](#version-formats) support raw and numeric component variables.
|
|
287
287
|
Detection arrays inspect one bounded listing of the current directory; replacement and fallback rules are [module-specific](modules.md#reachability-and-collection-rules).
|
|
288
288
|
Language and Kubernetes file detectors support leading `!` rejection rules; [environment detectors](modules.md#environment-detection-and-messages) have separate presence rules.
|
|
289
|
-
|
|
290
|
-
Icon matching uses the exact key, the longest `:*` wildcard, a leading status emoji, then `fallback`/`🔌`.
|
|
291
|
-
An empty configured icon suppresses only the icon.
|
|
292
|
-
`foo:*` matches `foo:server` but not `foo`, `foobar`, or `foo/server`.
|
|
293
|
-
`[extension_status].styles` applies a Starship style to each complete status (icon and text) by exact raw key, then longest `:*` wildcard, then optional `fallback`; unmatched statuses inherit the module's `style`.
|
|
294
|
-
Separators retain the module style. An explicit `none` style removes the inherited module style for that status.
|
|
295
|
-
|
|
296
|
-
Pi does not expose status ownership, so exact raw keys are the reliable third-party contract.
|
|
297
|
-
pi-starship does not inspect installed packages, infer aliases, assign known-extension icons, or bridge compatibility keys.
|
|
298
|
-
Extension authors may use `<extension-id>` or `<extension-id>:<stable-slot>` for interoperability, but pi-starship does not require it.
|
|
299
|
-
|
|
300
|
-
**Icon migration:** configurations that relied on package-ID aliases, built-in known-extension icons, or compatibility mappings must use an exact raw status key, an explicit namespace wildcard, a leading emoji in the status value, or `fallback`.
|
|
289
|
+
See [individual extension statuses](#individual-extension-statuses) for exact-key placement, aggregate selection, and `[extension_status]` icon/style matching.
|
|
301
290
|
|
|
302
291
|
## Configuration schema and validation
|
|
303
292
|
|
|
@@ -307,7 +296,7 @@ A settings document is one TOML table with these accepted root keys:
|
|
|
307
296
|
|
|
308
297
|
| Key | Type | Behavior |
|
|
309
298
|
| --- | --- | --- |
|
|
310
|
-
| `format` | string | Root layout whose variables are module names or `$
|
|
299
|
+
| `format` | string | Root layout whose variables are module names, `$all`, or exact `${extension_status.<raw-key>}` references. |
|
|
311
300
|
| `palette` | string | Selects one exact table name from `[palettes.<name>]`. |
|
|
312
301
|
| `palettes` | table of tables | Defines direct color names used by style expressions. |
|
|
313
302
|
| `<module>` | table | Configures one module listed in [the complete module catalog](module-catalog.md). |
|
|
@@ -456,11 +445,89 @@ Unknown fields and comments remain in the settings document even though they are
|
|
|
456
445
|
- Styled groups: `[format string](style string)`.
|
|
457
446
|
- Conditional groups: `(format string)` render only when a nested variable has a non-empty value.
|
|
458
447
|
- Nested groups are supported.
|
|
459
|
-
- `$all` expands enabled modules in the default order and omits modules already referenced explicitly.
|
|
448
|
+
- `$all` expands enabled modules in the default order and omits modules already referenced explicitly; individual extension-status references exclude only their selected keys, not the aggregate module.
|
|
460
449
|
|
|
461
450
|
Module formats can use `$style` in a style expression.
|
|
462
451
|
Module output keeps its own style when embedded in an outer styled group.
|
|
463
452
|
|
|
453
|
+
### Individual extension statuses
|
|
454
|
+
|
|
455
|
+
Use `${extension_status.<raw-key>}` in the root `format` to place one exact key from Pi's public status map.
|
|
456
|
+
Keep the braces and a non-empty suffix; the complete suffix is the raw key, including case, dots, colons, or slashes.
|
|
457
|
+
These references are not module-local variables or style variables, and root references do not support wildcard matching or per-status configuration tables.
|
|
458
|
+
A `*` in a reference is literal raw-key text, not a wildcard.
|
|
459
|
+
Invalid references produce configuration diagnostics; a valid reference to an absent key renders empty without a warning.
|
|
460
|
+
Keys that cannot fit the existing braced-variable grammar remain available through `$extension_status`.
|
|
461
|
+
|
|
462
|
+
This example places `usage` beside Provider/Model, remaining statuses on an optional line, and `sync` on the final optional line:
|
|
463
|
+
|
|
464
|
+
```toml
|
|
465
|
+
format = """
|
|
466
|
+
$provider$model( ${extension_status.usage})
|
|
467
|
+
$directory$git_branch$git_status(
|
|
468
|
+
$extension_status)(
|
|
469
|
+
${extension_status.sync})"""
|
|
470
|
+
|
|
471
|
+
[extension_status.styles]
|
|
472
|
+
usage = "bold cyan"
|
|
473
|
+
sync = "yellow"
|
|
474
|
+
lsp = "green"
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
All explicit status keys are collected from the complete root format, including nested conditional and styled groups, before rendering.
|
|
478
|
+
Every `$extension_status` excludes those keys regardless of their position or whether their containing group is visible.
|
|
479
|
+
When `$all` reaches `extension_status`, it uses the same remaining-status group.
|
|
480
|
+
An individual reference does not remove that aggregate module from `$all`; an explicit `$extension_status` does.
|
|
481
|
+
Repeated individual or aggregate references render at every written occurrence; they do not consume statuses or share an allowance.
|
|
482
|
+
|
|
483
|
+
Empty or whitespace-only values, including values left empty after terminal-control removal, and pi-starship's own `starship` key are filtered before selection and limiting.
|
|
484
|
+
Statuses whose formatted content is empty, such as a prefix-only value with its icon suppressed, are also omitted before the limit and module format are applied.
|
|
485
|
+
Each expansion selects its requested key or the remaining group in public-map order, then applies `[extension_status].max_statuses` independently.
|
|
486
|
+
The default limit is `5`, with an accepted range of `0` through `100`.
|
|
487
|
+
An individual reference selects at most one status and does not use the aggregate's allowance; its position in the original map does not prevent selection.
|
|
488
|
+
`max_statuses = 0` or `[extension_status].disabled = true` hides all individual and aggregate expansions.
|
|
489
|
+
|
|
490
|
+
Every non-empty expansion reuses `[extension_status].format`, `symbol`, `style`, `separator`, `icons`, `styles`, and the selected palette.
|
|
491
|
+
For an individual reference, `$statuses` contains that one formatted status and `$count` is `1`.
|
|
492
|
+
For the aggregate, `$statuses` joins the selected statuses and `$count` is their number after exclusion and limiting.
|
|
493
|
+
An expansion with no visible status is empty before its module format runs, so static labels, symbols, counts, and separators do not remain.
|
|
494
|
+
Put associated whitespace or a newline inside a conditional group, as above, to hide it with the expansion; literals outside the group remain.
|
|
495
|
+
|
|
496
|
+
Both expansion forms use the same raw-key icon and style maps.
|
|
497
|
+
Quote dotted raw keys in TOML maps: an unquoted `example.worker` defines a nested table rather than one exact key.
|
|
498
|
+
For a hypothetical publisher that emits `example.worker`, use `${extension_status.example.worker}` for placement and quote the key in both maps:
|
|
499
|
+
|
|
500
|
+
```toml
|
|
501
|
+
[extension_status.icons]
|
|
502
|
+
"example.worker" = "◆"
|
|
503
|
+
"foo:*" = "🧪"
|
|
504
|
+
fallback = "•"
|
|
505
|
+
|
|
506
|
+
[extension_status.styles]
|
|
507
|
+
"example.worker" = "bold green"
|
|
508
|
+
"foo:*" = "bold yellow"
|
|
509
|
+
"foo:error" = "bold red"
|
|
510
|
+
fallback = "dimmed white"
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
Icon matching uses the exact raw key, the longest `:*` namespace wildcard, a leading status emoji, then configured `fallback` or `🔌`.
|
|
514
|
+
An empty configured icon suppresses only the icon.
|
|
515
|
+
`foo:*` matches `foo:server` but not `foo`, `foobar`, `foo/server`, or `foo.server`.
|
|
516
|
+
There is no `.*` wildcard; use quoted exact dotted keys.
|
|
517
|
+
`styles` applies a Starship style to each complete status (icon and text) by exact raw key, then longest `:*` wildcard, then optional `fallback`.
|
|
518
|
+
Unmatched statuses inherit the module's `style`; explicit `none` removes that inherited style for the status.
|
|
519
|
+
Separators retain the module style, and a raw key keeps the same configured icon/style rules in both forms.
|
|
520
|
+
|
|
521
|
+
Pi does not expose status ownership, so exact raw keys are the reliable third-party contract.
|
|
522
|
+
pi-starship does not normalize, split, or rewrite keys, convert `:` to `.`, inspect installed packages, infer aliases, assign known-extension icons, or bridge compatibility keys.
|
|
523
|
+
Repository-owned publishers currently use only bare aggregate keys; `pi-lsp` publishes only `lsp`, not per-language statuses.
|
|
524
|
+
Authors may use `<extension-id>` for one aggregate status or `<extension-id>.<stable-slot>` for independent channels, but pi-starship neither requires this convention nor creates channels from references.
|
|
525
|
+
Status values and configured display text are sanitized at the display boundary before text transforms or layout; raw keys retain their identity for matching.
|
|
526
|
+
|
|
527
|
+
**Icon migration:** configurations that relied on package-ID aliases, built-in known-extension icons, or compatibility mappings must use an exact raw status key, an explicit `:*` namespace wildcard, a leading emoji in the status value, or `fallback`.
|
|
528
|
+
Existing settings, profiles, presets, and history are not rewritten automatically.
|
|
529
|
+
Before downgrading to a release without individual references, remove those references or restore an earlier TOML document.
|
|
530
|
+
|
|
464
531
|
## 🎨 Styles and palettes
|
|
465
532
|
|
|
466
533
|
Style expressions support:
|
|
@@ -1247,6 +1247,8 @@ Accepted style fields:
|
|
|
1247
1247
|
### `extension_status`
|
|
1248
1248
|
|
|
1249
1249
|
Statuses published through Pi's extension-neutral status map.
|
|
1250
|
+
Use root `$extension_status` for the remaining group or `${extension_status.<raw-key>}` for one exact status; both use this module's settings and format.
|
|
1251
|
+
See [individual extension statuses](configuration.md#individual-extension-statuses) for selection, `$all` exclusions, counts, empty output, and icon/style matching.
|
|
1250
1252
|
|
|
1251
1253
|
- Format variables: `$symbol`, `$statuses`, `$count`.
|
|
1252
1254
|
- Style variables in `format`: `$style`.
|
|
@@ -1265,6 +1267,6 @@ Additional options:
|
|
|
1265
1267
|
| Option | Type | Default | Constraints and meaning |
|
|
1266
1268
|
| --- | --- | --- | --- |
|
|
1267
1269
|
| `separator` | string | `" • "` | Text inserted between rendered extension statuses. |
|
|
1268
|
-
| `max_statuses` | integer | `5` | Inclusive range 0 through 100.
|
|
1269
|
-
| `icons` | string-to-string table | `{}` | Exact raw status keys,
|
|
1270
|
-
| `styles` | string-to-style table | `{}` | Valid Starship styles by exact raw key, namespace wildcard, or fallback. |
|
|
1270
|
+
| `max_statuses` | integer | `5` | Inclusive range 0 through 100. Limit per expansion after selection and exclusion; zero hides all expansions. |
|
|
1271
|
+
| `icons` | string-to-string table | `{}` | Exact raw status keys, `:*` namespace wildcards, and optional `fallback`; quote dotted keys. |
|
|
1272
|
+
| `styles` | string-to-style table | `{}` | Valid Starship styles by exact raw key, `:*` namespace wildcard, or `fallback`; quote dotted keys. |
|
|
@@ -63,7 +63,10 @@ For exact default formats, symbols, enabled state, accepted style fields, displa
|
|
|
63
63
|
## Reachability and collection rules
|
|
64
64
|
|
|
65
65
|
A module contributes work only when it is enabled and reachable from the root `format` directly or through `$all`.
|
|
66
|
-
|
|
66
|
+
A valid root `${extension_status.<raw-key>}` also makes `extension_status` reachable without the aggregate variable; it reads Pi's existing status map, not a producer or collector.
|
|
67
|
+
For that module, inspection uses the status expansions that participate in the layout, including individual-only layouts.
|
|
68
|
+
See [individual extension statuses](configuration.md#individual-extension-statuses) for exact-key selection, aggregate exclusions, limits, and shared formatting.
|
|
69
|
+
For modules with a collector, reachability activates it at module scope, even when the module format references only `$symbol`.
|
|
67
70
|
Omitting a data variable does not prevent the package, deployment, cloud, or execution collectors from reading that reachable module's allowlisted files and environment metadata.
|
|
68
71
|
Language project detection also runs at module scope. Version commands, requirement-file reads, and optional Python/Rust values are variable-gated, except for explicitly enabled Node.js/Go requirement styling as described below.
|
|
69
72
|
The mise health, direnv status, Pixi version, and Terraform/OpenTofu version commands are likewise variable-gated, but their module-level detection and non-command metadata reads still occur when reachable.
|
package/src/config.ts
CHANGED
|
@@ -19,6 +19,7 @@ import { type FormatNode, formatVariables, parseFormat, styleVariables } from ".
|
|
|
19
19
|
import { type ColorPalette, isValidStyle, parseColor } from "./format/style.js";
|
|
20
20
|
import { MODULE_DEFINITIONS, MODULE_NAMES, type ModuleName } from "./modules/catalog.js";
|
|
21
21
|
import type { ModuleDisplayConfig, ModuleOptionSchema, ModuleOptionValue, ModuleStyleRule } from "./modules/types.js";
|
|
22
|
+
import { extensionStatusKey } from "./root-references.js";
|
|
22
23
|
|
|
23
24
|
export const CONFIG_FILE_NAME = "pi-starship.toml";
|
|
24
25
|
export { MODULE_NAMES, type ModuleName } from "./modules/catalog.js";
|
|
@@ -641,7 +642,7 @@ function validateFormatVariables(
|
|
|
641
642
|
diagnostics: ConfigDiagnostic[],
|
|
642
643
|
) {
|
|
643
644
|
for (const variable of formatVariables(ast)) {
|
|
644
|
-
if (allowed.has(variable)) continue;
|
|
645
|
+
if (allowed.has(variable) || (path === "format" && extensionStatusKey(variable) !== undefined)) continue;
|
|
645
646
|
diagnostics.push(
|
|
646
647
|
diagnostic("warning", path, `Unknown variable ${JSON.stringify(variable)} in ${path} was ignored`),
|
|
647
648
|
);
|
|
@@ -13,8 +13,9 @@ export const extensionStatusModule = defineModule({
|
|
|
13
13
|
values: ({ runtime, extensionStatus, palette }) => {
|
|
14
14
|
const statuses = [...runtime.extensionStatuses.entries()]
|
|
15
15
|
.filter(([key, value]) => key !== "starship" && value.trim())
|
|
16
|
-
.
|
|
17
|
-
.
|
|
16
|
+
.map(([key, value]) => ({ key, text: formatExtensionStatus(key, value, extensionStatus.icons) }))
|
|
17
|
+
.filter(({ text }) => text.trim())
|
|
18
|
+
.slice(0, extensionStatus.maxStatuses);
|
|
18
19
|
if (statuses.length === 0) return undefined;
|
|
19
20
|
const { separator, styles } = extensionStatus;
|
|
20
21
|
const content =
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { stripVTControlCharacters } from "node:util";
|
|
2
2
|
import type { StarshipConfig } from "../config.js";
|
|
3
3
|
import { formatVariables } from "../format/formatter.js";
|
|
4
|
+
import { referencesModule } from "../root-references.js";
|
|
4
5
|
import { MODULE_DEFINITIONS, type ModuleName } from "./catalog.js";
|
|
5
6
|
import { reachableModuleRequirements, renderStatusline } from "./render.js";
|
|
6
7
|
import type { StarshipRuntimeSnapshot } from "./types.js";
|
|
@@ -52,7 +53,7 @@ export function inspectStatuslineModules(
|
|
|
52
53
|
definition,
|
|
53
54
|
state,
|
|
54
55
|
preview,
|
|
55
|
-
includeAll || rootVariables
|
|
56
|
+
includeAll || referencesModule(rootVariables, definition.name),
|
|
56
57
|
reachable,
|
|
57
58
|
);
|
|
58
59
|
});
|
|
@@ -76,7 +77,7 @@ export function inspectUnavailableModules(config: StarshipConfig): StatuslineIns
|
|
|
76
77
|
definition,
|
|
77
78
|
state,
|
|
78
79
|
"",
|
|
79
|
-
includeAll || rootVariables
|
|
80
|
+
includeAll || referencesModule(rootVariables, definition.name),
|
|
80
81
|
reachable,
|
|
81
82
|
);
|
|
82
83
|
}),
|
package/src/modules/render.ts
CHANGED
|
@@ -11,10 +11,12 @@ import {
|
|
|
11
11
|
} from "../format/style.js";
|
|
12
12
|
import { sanitizeFormatText } from "../format/terminal-safety.js";
|
|
13
13
|
import type { ThemeColors } from "../format/theme-colors.js";
|
|
14
|
+
import { extensionStatusKey, referencesModule } from "../root-references.js";
|
|
14
15
|
import { MODULE_DEFINITIONS, MODULE_NAMES, type ModuleName } from "./catalog.js";
|
|
15
16
|
import { directoryAlternateFormat } from "./directory.js";
|
|
16
17
|
import { resolveStyleRule } from "./style-rules.js";
|
|
17
18
|
import type {
|
|
19
|
+
ModuleDefinition,
|
|
18
20
|
ModuleOptionValue,
|
|
19
21
|
ModuleStyleContext,
|
|
20
22
|
ModuleValueContext,
|
|
@@ -30,6 +32,15 @@ export function renderStatusline(
|
|
|
30
32
|
themeColors?: ThemeColors,
|
|
31
33
|
): RenderedStatusline<ModuleName> {
|
|
32
34
|
const palette = activePalette(config);
|
|
35
|
+
const explicitModules = formatVariables(config.formatAst);
|
|
36
|
+
const statusReferences = new Map(
|
|
37
|
+
[...explicitModules].flatMap((reference) => {
|
|
38
|
+
const key = extensionStatusKey(reference);
|
|
39
|
+
return key === undefined ? [] : [[reference, key] as const];
|
|
40
|
+
}),
|
|
41
|
+
);
|
|
42
|
+
const selectedKeys = new Set(statusReferences.values());
|
|
43
|
+
const statusChunks = new Map<string, StyledChunk[]>();
|
|
33
44
|
const modules = {} as Record<ModuleName, StyledChunk[]>;
|
|
34
45
|
const layoutModules = {} as Record<ModuleName, LayoutChunk[]>;
|
|
35
46
|
for (const name of MODULE_NAMES) {
|
|
@@ -40,46 +51,47 @@ export function renderStatusline(
|
|
|
40
51
|
const name = definition.name;
|
|
41
52
|
const module = config.modules[name];
|
|
42
53
|
const context = valueContext(config, name, runtime, palette);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
);
|
|
65
|
-
const alternate = definition.resolveFormat?.(context, values);
|
|
66
|
-
const rendered = renderModule(
|
|
67
|
-
alternate === undefined ? module : { ...module, formatAst: parseFormat(alternate) },
|
|
68
|
-
contentValues,
|
|
69
|
-
styleVariables,
|
|
70
|
-
palette,
|
|
71
|
-
);
|
|
54
|
+
if (name === "extension_status" && statusReferences.size > 0) {
|
|
55
|
+
const statuses = context.runtime.extensionStatuses;
|
|
56
|
+
for (const [reference, key] of statusReferences) {
|
|
57
|
+
const value = statuses.get(key);
|
|
58
|
+
const selected = new Map(value === undefined ? [] : [[key, value]]);
|
|
59
|
+
statusChunks.set(
|
|
60
|
+
reference,
|
|
61
|
+
renderDefinition(
|
|
62
|
+
definition,
|
|
63
|
+
module,
|
|
64
|
+
{ ...context, runtime: { ...context.runtime, extensionStatuses: selected } },
|
|
65
|
+
runtime,
|
|
66
|
+
) ?? [],
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
context.runtime = {
|
|
70
|
+
...context.runtime,
|
|
71
|
+
extensionStatuses: new Map([...statuses].filter(([key]) => !selectedKeys.has(key))),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
const rendered = renderDefinition(definition, module, context, runtime);
|
|
75
|
+
if (!rendered) continue;
|
|
72
76
|
modules[name] = rendered;
|
|
73
77
|
layoutModules[name] =
|
|
74
78
|
definition.layout === "fill" && !module.disabled ? [{ type: "fill", pattern: rendered }] : rendered;
|
|
75
79
|
}
|
|
76
80
|
|
|
77
|
-
const explicitModules = formatVariables(config.formatAst);
|
|
78
81
|
const all = MODULE_NAMES.flatMap((name) =>
|
|
79
82
|
explicitModules.has(name) || config.modules[name].disabled ? [] : layoutModules[name],
|
|
80
83
|
);
|
|
81
84
|
const rootVariables: Record<string, FormatValue> = { all };
|
|
82
85
|
for (const name of MODULE_NAMES) rootVariables[name] = layoutModules[name];
|
|
86
|
+
for (const [reference, rendered] of statusChunks) rootVariables[reference] = rendered;
|
|
87
|
+
if (statusReferences.size > 0) {
|
|
88
|
+
// Inspection shows participating expansions once, not statuses absent from the layout.
|
|
89
|
+
modules.extension_status = [...explicitModules].flatMap((reference) =>
|
|
90
|
+
reference === "extension_status" || (reference === "all" && !explicitModules.has("extension_status"))
|
|
91
|
+
? modules.extension_status
|
|
92
|
+
: (statusChunks.get(reference) ?? []),
|
|
93
|
+
);
|
|
94
|
+
}
|
|
83
95
|
const layout = renderFormat(config.formatAst, { variables: rootVariables, palette });
|
|
84
96
|
const chunks = resolveFillLayout(layout, width);
|
|
85
97
|
return {
|
|
@@ -89,6 +101,41 @@ export function renderStatusline(
|
|
|
89
101
|
};
|
|
90
102
|
}
|
|
91
103
|
|
|
104
|
+
function renderDefinition(
|
|
105
|
+
definition: ModuleDefinition<ModuleName>,
|
|
106
|
+
module: ModuleConfig,
|
|
107
|
+
context: ModuleValueContext,
|
|
108
|
+
runtime: StarshipRuntimeSnapshot,
|
|
109
|
+
): StyledChunk[] | undefined {
|
|
110
|
+
const values = definition.values(context);
|
|
111
|
+
if (!values) return undefined;
|
|
112
|
+
const styleContext: ModuleStyleContext = {
|
|
113
|
+
runtime,
|
|
114
|
+
style: module.style,
|
|
115
|
+
styles: module.styles,
|
|
116
|
+
display: module.display,
|
|
117
|
+
options: context.options,
|
|
118
|
+
};
|
|
119
|
+
const baseStyleVariables = definition.resolveStyleVariables
|
|
120
|
+
? definition.resolveStyleVariables(styleContext)
|
|
121
|
+
: { style: module.style };
|
|
122
|
+
if (!baseStyleVariables) return undefined;
|
|
123
|
+
const ruleStyle = definition.styleRuleSelectors
|
|
124
|
+
? resolveStyleRule(module.styleRules, definition.styleRuleSelectors, styleContext)
|
|
125
|
+
: undefined;
|
|
126
|
+
const styleVariables = ruleStyle === undefined ? baseStyleVariables : { ...baseStyleVariables, style: ruleStyle };
|
|
127
|
+
const contentValues: Record<string, FormatValue> = Object.fromEntries(
|
|
128
|
+
definition.variables.flatMap((variable) => (Object.hasOwn(values, variable) ? [[variable, values[variable]]] : [])),
|
|
129
|
+
);
|
|
130
|
+
const alternate = definition.resolveFormat?.(context, values);
|
|
131
|
+
return renderModule(
|
|
132
|
+
alternate === undefined ? module : { ...module, formatAst: parseFormat(alternate) },
|
|
133
|
+
contentValues,
|
|
134
|
+
styleVariables,
|
|
135
|
+
context.palette,
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
92
139
|
function valueContext(
|
|
93
140
|
config: StarshipConfig,
|
|
94
141
|
name: ModuleName,
|
|
@@ -194,7 +241,7 @@ export function reachableModuleRequirements(config: StarshipConfig): ReadonlyMap
|
|
|
194
241
|
const requirements = new Map<ModuleName, ReadonlySet<string>>();
|
|
195
242
|
for (const definition of MODULE_DEFINITIONS) {
|
|
196
243
|
if (config.modules[definition.name].disabled) continue;
|
|
197
|
-
if (!includeAll && !rootVariables
|
|
244
|
+
if (!includeAll && !referencesModule(rootVariables, definition.name)) continue;
|
|
198
245
|
const variables = formatVariables(config.modules[definition.name].formatAst);
|
|
199
246
|
if (definition.name === "directory") {
|
|
200
247
|
const alternate = directoryAlternateFormat(config.modules.directory.options, config.modules.directory.styles);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const EXTENSION_STATUS_PREFIX = "extension_status.";
|
|
2
|
+
|
|
3
|
+
/** The suffix is an exact public status key, not a path or namespace selector. */
|
|
4
|
+
export function extensionStatusKey(reference: string): string | undefined {
|
|
5
|
+
if (!reference.startsWith(EXTENSION_STATUS_PREFIX)) return undefined;
|
|
6
|
+
const key = reference.slice(EXTENSION_STATUS_PREFIX.length);
|
|
7
|
+
return key.length > 0 ? key : undefined;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function referencesModule(references: ReadonlySet<string>, module: string): boolean {
|
|
11
|
+
return (
|
|
12
|
+
references.has(module) ||
|
|
13
|
+
(module === "extension_status" && [...references].some((reference) => extensionStatusKey(reference) !== undefined))
|
|
14
|
+
);
|
|
15
|
+
}
|