types.rs

 1mod lsp;
 2mod slash_command;
 3
 4use std::ops::Range;
 5
 6pub use lsp::*;
 7pub use slash_command::*;
 8
 9/// A list of environment variables.
10pub type EnvVars = Vec<(String, String)>;
11
12/// A command.
13pub struct Command {
14    /// The command to execute.
15    pub command: String,
16    /// The arguments to pass to the command.
17    pub args: Vec<String>,
18    /// The environment variables to set for the command.
19    pub env: EnvVars,
20}
21
22/// A label containing some code.
23#[derive(Debug, Clone)]
24pub struct CodeLabel {
25    /// The source code to parse with Tree-sitter.
26    pub code: String,
27    /// The spans to display in the label.
28    pub spans: Vec<CodeLabelSpan>,
29    /// The range of the displayed label to include when filtering.
30    pub filter_range: Range<usize>,
31}
32
33/// A span within a code label.
34#[derive(Debug, Clone)]
35pub enum CodeLabelSpan {
36    /// A range into the parsed code.
37    CodeRange(Range<usize>),
38    /// A span containing a code literal.
39    Literal(CodeLabelSpanLiteral),
40}
41
42/// A span containing a code literal.
43#[derive(Debug, Clone)]
44pub struct CodeLabelSpanLiteral {
45    /// The literal text.
46    pub text: String,
47    /// The name of the highlight to use for this literal.
48    pub highlight_name: Option<String>,
49}