1mod context_server;
 2mod dap;
 3mod lsp;
 4mod slash_command;
 5
 6use std::{ops::Range, path::PathBuf};
 7
 8use util::redact::should_redact;
 9
10pub use context_server::*;
11pub use dap::*;
12pub use lsp::*;
13pub use slash_command::*;
14
15/// A list of environment variables.
16pub type EnvVars = Vec<(String, String)>;
17
18/// A command.
19pub struct Command {
20    /// The command to execute.
21    pub command: PathBuf,
22    /// The arguments to pass to the command.
23    pub args: Vec<String>,
24    /// The environment variables to set for the command.
25    pub env: EnvVars,
26}
27
28impl std::fmt::Debug for Command {
29    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
30        let filtered_env = self
31            .env
32            .iter()
33            .map(|(k, v)| (k, if should_redact(k) { "[REDACTED]" } else { v }))
34            .collect::<Vec<_>>();
35
36        f.debug_struct("Command")
37            .field("command", &self.command)
38            .field("args", &self.args)
39            .field("env", &filtered_env)
40            .finish()
41    }
42}
43
44/// A label containing some code.
45#[derive(Debug, Clone)]
46pub struct CodeLabel {
47    /// The source code to parse with Tree-sitter.
48    pub code: String,
49    /// The spans to display in the label.
50    pub spans: Vec<CodeLabelSpan>,
51    /// The range of the displayed label to include when filtering.
52    pub filter_range: Range<usize>,
53}
54
55/// A span within a code label.
56#[derive(Debug, Clone)]
57pub enum CodeLabelSpan {
58    /// A range into the parsed code.
59    CodeRange(Range<usize>),
60    /// A span containing a code literal.
61    Literal(CodeLabelSpanLiteral),
62}
63
64/// A span containing a code literal.
65#[derive(Debug, Clone)]
66pub struct CodeLabelSpanLiteral {
67    /// The literal text.
68    pub text: String,
69    /// The name of the highlight to use for this literal.
70    pub highlight_name: Option<String>,
71}