pub enum DetectMethod {
Path(&'static str),
#[cfg(target_os = "macos")]
MacosApp(&'static str),
Always,
}
pub struct EditorEntry {
pub aliases: &'static [&'static str],
pub display: &'static str,
pub command: &'static str,
pub detect: DetectMethod,
}
const BASE: &[(&[&str], &str, &str, &str)] = &[
(&["cursor"], "Cursor", "cursor .", "cursor"),
(&["vscode", "code"], "VS Code", "code .", "code"),
(&["zed"], "Zed", "zed .", "zed"),
(&["subl"], "Sublime Text", "subl .", "subl"),
(&["nvim"], "Neovim", "nvim .", "nvim"),
(&["vim"], "Vim", "vim .", "vim"),
(&["tmux"], "tmux", "tmux", "tmux"),
(
&["alacritty"],
"Alacritty",
"alacritty --working-directory .",
"alacritty",
),
(&["kitty"], "Kitty", "kitty --directory .", "kitty"),
(&["wezterm"], "WezTerm", "wezterm start --cwd .", "wezterm"),
];
#[must_use]
#[allow(unused_mut)]
pub fn all_entries() -> Vec<EditorEntry> {
let mut v: Vec<EditorEntry> = BASE
.iter()
.map(|&(aliases, display, command, binary)| EditorEntry {
aliases,
display,
command,
detect: DetectMethod::Path(binary),
})
.collect();
#[cfg(target_os = "macos")]
{
use DetectMethod::{Always, MacosApp};
v.push(EditorEntry {
aliases: &["terminal"],
display: "Terminal",
command: "open -a Terminal .",
detect: Always,
});
v.push(EditorEntry {
aliases: &["iterm", "iterm2"],
display: "iTerm2",
command: "open -a iTerm .",
detect: MacosApp("iTerm"),
});
v.push(EditorEntry {
aliases: &["warp"],
display: "Warp",
command: "open -a Warp .",
detect: MacosApp("Warp"),
});
v.push(EditorEntry {
aliases: &["ghostty"],
display: "Ghostty",
command: "open -a Ghostty .",
detect: MacosApp("Ghostty"),
});
}
#[cfg(target_os = "windows")]
v.push(EditorEntry {
aliases: &["wt", "windowsterminal", "terminal"],
display: "Windows Terminal",
command: "wt -d .",
detect: DetectMethod::Path("wt"),
});
v
}