feat(dist): generate completions, editor syntax, man pages, translations
Ports Ghostty's build-data helpers (main_build_data.zig, src/extra/*, build/mdgen) as the ghostty-build-data binary: bash/zsh/fish completions, Vim syntax/ftdetect/ftplugin/compiler, Sublime syntax (also used by bat), terminfo source and ghostty(1)/ghostty(5) markdown. With the version set to the installed 1.3.1-arch2, all generated files are byte-identical to the installed Ghostty's. - `just docs` renders man pages and HTML with pandoc. - po/: Ghostty's 29 translation catalogs; `just locales` compiles them into the com.mitchellh.ghostty gettext domain. - `just install PREFIX FLATPAK SYSTEM_PACKAGE` installs everything incl. terminfo text/termcap outputs and mirrors GhosttyResources.zig install modes (Flatpak D-Bus template without systemd; lib/systemd/user for system packages). - Build metadata (version, tip/stable channel, commit, build mode) is derived at build time like build_config.zig; GTK/libadwaita compile-time versions come from pkg-config instead of constants. Test Plan: - cargo run -p ghostty-build-data -- +bash | diff - \ /usr/share/bash-completion/completions/ghostty (same for zsh/fish/vim) - just install /tmp/prefix
This commit is contained in:
1 parent
79486601b5
commit
2dc1c6028d
56 files changed
+12614
-16
No files matched your search
@@ -0,0 +1,95 @@
|
||||
//! Zsh completions (port of `extra/zsh.zig`).
|
||||
|
||||
use std::fmt::Write as _;
|
||||
|
||||
use ghostty_config::cli_args::FieldKind;
|
||||
|
||||
use crate::chunks_zsh::{C0, C1, C2, C3};
|
||||
use crate::{actions, config_fields, join_names, join_packed};
|
||||
|
||||
const EQUALS_REQUIRED: &str = "=-:::";
|
||||
|
||||
#[must_use]
|
||||
pub fn completions() -> String {
|
||||
let mut w = String::new();
|
||||
w.push_str(C0);
|
||||
w.push_str("_config() {\n");
|
||||
w.push_str(" _arguments \\\n");
|
||||
w.push_str(" \"--help\" \\\n");
|
||||
w.push_str(" \"--version\" \\\n");
|
||||
for f in config_fields() {
|
||||
let _ = write!(w, " \"--{}", f.name);
|
||||
if f.name.starts_with("font-family") {
|
||||
let _ = write!(w, "{EQUALS_REQUIRED}_fonts");
|
||||
} else if f.name == "theme" {
|
||||
let _ = write!(w, "{EQUALS_REQUIRED}_themes");
|
||||
} else if f.name == "working-directory" {
|
||||
let _ = write!(w, "{EQUALS_REQUIRED}{{_files -/}}");
|
||||
} else if f.kind == FieldKind::RepeatablePath {
|
||||
let _ = write!(w, "{EQUALS_REQUIRED}_files");
|
||||
} else {
|
||||
match f.kind {
|
||||
FieldKind::Bool => {}
|
||||
FieldKind::Enum(names) => {
|
||||
let _ = write!(w, "{EQUALS_REQUIRED}({})", join_names(names));
|
||||
}
|
||||
FieldKind::Packed(names) => {
|
||||
let _ = write!(w, "{EQUALS_REQUIRED}({})", join_packed(names));
|
||||
}
|
||||
_ => {
|
||||
let _ = write!(w, "{EQUALS_REQUIRED}( )");
|
||||
}
|
||||
}
|
||||
}
|
||||
w.push_str("\" \\\n");
|
||||
}
|
||||
w.push_str("\n}\n\n");
|
||||
|
||||
w.push_str(C1);
|
||||
let padding = " ";
|
||||
for a in actions() {
|
||||
let _ = writeln!(w, "{padding}'+{}'", a.name());
|
||||
}
|
||||
w.push_str(C2);
|
||||
|
||||
for a in actions() {
|
||||
let opts = a.option_fields();
|
||||
if opts.is_empty() {
|
||||
continue;
|
||||
}
|
||||
let _ = writeln!(w, "{padding}(+{})", a.name());
|
||||
let _ = writeln!(w, "{padding} _arguments \\");
|
||||
for (name, kind) in &opts {
|
||||
let _ = write!(w, "{padding} '--{name}");
|
||||
match kind {
|
||||
FieldKind::Bool => {}
|
||||
FieldKind::Enum(names) => {
|
||||
let _ = write!(w, "{EQUALS_REQUIRED}({})", join_names(names));
|
||||
}
|
||||
FieldKind::OptionalEnum(names) => {
|
||||
let _ = write!(w, "{EQUALS_REQUIRED}({})", join_names(names));
|
||||
}
|
||||
FieldKind::OptionalBool | FieldKind::OptionalOther => {
|
||||
w.push_str(EQUALS_REQUIRED);
|
||||
if *name == "config-file" {
|
||||
w.push_str("_files");
|
||||
} else {
|
||||
w.push_str("( )");
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
w.push_str(EQUALS_REQUIRED);
|
||||
if *name == "config-file" {
|
||||
w.push_str("_files");
|
||||
} else {
|
||||
w.push_str("( )");
|
||||
}
|
||||
}
|
||||
}
|
||||
w.push_str("' \\\n");
|
||||
}
|
||||
let _ = writeln!(w, "{padding};;");
|
||||
}
|
||||
w.push_str(C3);
|
||||
w
|
||||
}
|
||||
Reference in new issue
Block a user