nu_cli/completions/
base.rs1use crate::completions::CompletionOptions;
2use nu_protocol::{
3 DeclId, Span,
4 engine::{Stack, StateWorkingSet},
5};
6use reedline::Suggestion;
7
8pub trait Completer {
9 #[allow(clippy::too_many_arguments)]
11 fn fetch(
12 &mut self,
13 working_set: &StateWorkingSet,
14 stack: &Stack,
15 prefix: impl AsRef<str>,
16 span: Span,
17 offset: usize,
18 options: &CompletionOptions,
19 ) -> Vec<SemanticSuggestion>;
20}
21
22#[derive(Debug, Default, PartialEq)]
23pub struct SemanticSuggestion {
24 pub suggestion: Suggestion,
25 pub kind: Option<SuggestionKind>,
26}
27
28#[derive(Clone, Debug, PartialEq)]
30pub enum SuggestionKind {
31 Command(nu_protocol::engine::CommandType, Option<DeclId>),
32 Value(nu_protocol::Type),
33 CellPath,
34 Directory,
35 File,
36 Flag,
37 Module,
38 Operator,
39 Variable,
40}
41
42impl From<Suggestion> for SemanticSuggestion {
43 fn from(suggestion: Suggestion) -> Self {
44 Self {
45 suggestion,
46 ..Default::default()
47 }
48 }
49}