use anyhow::{Context, Result};
use escriba_lisp::{ApplyPlan, EscribaPluginSpec};
pub struct BundledPlugin {
pub name: &'static str,
pub source: &'static str,
}
macro_rules! bundled {
($($name:literal),* $(,)?) => {
pub const BUNDLED: &[BundledPlugin] = &[
$(
BundledPlugin {
name: $name,
source: include_str!(concat!("../catalog/", $name, ".escribaplugin.lisp")),
}
),*
];
};
}
bundled! {
"escriba-which-key",
"escriba-comment",
"escriba-todo-comments",
"escriba-surround",
"escriba-autopairs",
"escriba-leap",
"escriba-overseer",
"escriba-oil",
"escriba-tree",
"escriba-gitsigns",
"escriba-fugitive",
"escriba-git-conflict",
"escriba-lspconfig",
"escriba-lspsaga",
"escriba-trouble",
"escriba-lsp-signature",
"escriba-tiny-inline-diagnostic",
"escriba-illuminate",
"escriba-mason",
"escriba-conform",
"escriba-dap",
"escriba-neotest",
"escriba-helm",
"escriba-cmp",
"escriba-lspkind",
"escriba-luasnip",
"escriba-telescope",
"escriba-compass",
"escriba-treesitter",
"escriba-treesitter-textobjects",
"escriba-treesitter-fold",
"escriba-treesitter-context",
"escriba-ts-autotag",
"escriba-ts-context-commentstring",
"escriba-render-markdown",
"escriba-nord",
"escriba-lualine",
"escriba-bufferline",
"escriba-noice",
"escriba-snacks",
"escriba-notify",
"escriba-indent-blankline",
"escriba-colorizer",
"escriba-devicons",
"escriba-mcp-assist",
}
pub fn bundled_plan() -> Result<ApplyPlan> {
bundled_plan_excluding(&std::collections::HashSet::new())
}
pub fn bundled_plan_excluding(disabled: &std::collections::HashSet<String>) -> Result<ApplyPlan> {
let mut plan = ApplyPlan::default();
for bpl in BUNDLED {
if disabled.contains(bpl.name) {
continue;
}
let entry = escriba_lisp::apply_source(bpl.source)
.with_context(|| format!("applying bundled plugin `{}` entry", bpl.name))?;
plan.merge(entry);
let spec = escriba_lisp::read_catalog_meta(bpl.source)
.with_context(|| format!("reading bundled plugin `{}` manifest", bpl.name))?;
let descriptor = escriba_lisp::emit_defplugin_descriptor(&spec);
let desc_plan = escriba_lisp::apply_source(&descriptor)
.with_context(|| format!("applying generated descriptor for `{}`", bpl.name))?;
plan.merge(desc_plan);
}
Ok(plan)
}
#[must_use]
pub fn disabled_from_env() -> std::collections::HashSet<String> {
std::env::var("ESCRIBA_DISABLED_PLUGINS")
.unwrap_or_default()
.split([',', ' '])
.map(str::trim)
.filter(|s| !s.is_empty())
.map(str::to_string)
.collect()
}
pub fn bundled_specs() -> Result<Vec<EscribaPluginSpec>> {
BUNDLED
.iter()
.map(|bpl| {
escriba_lisp::read_catalog_meta(bpl.source)
.with_context(|| format!("reading bundled plugin `{}` manifest", bpl.name))
})
.collect()
}