nvrim/
cli.rs

1//! CLI flag generation helpers for search tools (`fd`, `rg`).
2//!
3//! Centralizes glob blacklist + base flags; exposes a dictionary with per‑tool flag builders for Lua.
4
5use nvim_oxi::Dictionary;
6
7mod fd;
8mod rg;
9
10/// A list of glob patterns to exclude from searches.
11pub const GLOB_BLACKLIST: [&str; 6] = [
12    "**/.git/*",
13    "**/target/*",
14    "**/_build/*",
15    "**/deps/*",
16    "**/.elixir_ls/*",
17    "**/node_modules/*",
18];
19
20/// [`Dictionary`] of CLI flag generators.
21pub fn dict() -> Dictionary {
22    dict! {
23        "get_fd_flags": fn_from!(fd::FdCliFlags::get),
24        "get_rg_flags": fn_from!(rg::RgCliFlags::get),
25    }
26}
27
28/// Trait for generating CLI flags for search tools.
29pub trait CliFlags {
30    /// Returns the base flags for the CLI tool.
31    fn base_flags() -> Vec<&'static str>;
32
33    /// Converts a glob pattern to a CLI flag.
34    fn glob_flag(glob: &str) -> String;
35
36    /// Generates the complete list of CLI flags.
37    fn get((): ()) -> Vec<String> {
38        Self::base_flags()
39            .into_iter()
40            .map(Into::into)
41            .chain(GLOB_BLACKLIST.into_iter().map(Self::glob_flag))
42            .collect::<Vec<_>>()
43    }
44}