mirror of https://github.com/helix-editor/helix
core: Add a provider type to track the origin of a completion
parent
f0fa905622
commit
018081a5b1
|
@ -1,6 +1,6 @@
|
||||||
use std::borrow::Cow;
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use crate::Transaction;
|
use crate::{diagnostic::LanguageServerId, Transaction};
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Clone)]
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
pub struct CompletionItem {
|
pub struct CompletionItem {
|
||||||
|
@ -9,4 +9,17 @@ pub struct CompletionItem {
|
||||||
pub kind: Cow<'static, str>,
|
pub kind: Cow<'static, str>,
|
||||||
/// Containing Markdown
|
/// Containing Markdown
|
||||||
pub documentation: String,
|
pub documentation: String,
|
||||||
|
pub provider: CompletionProvider,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
|
||||||
|
pub enum CompletionProvider {
|
||||||
|
Lsp(LanguageServerId),
|
||||||
|
Path,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<LanguageServerId> for CompletionProvider {
|
||||||
|
fn from(id: LanguageServerId) -> Self {
|
||||||
|
CompletionProvider::Lsp(id)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ use std::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use futures_util::{future::BoxFuture, FutureExt as _};
|
use futures_util::{future::BoxFuture, FutureExt as _};
|
||||||
use helix_core::{self as core, Selection, Transaction};
|
use helix_core::{self as core, completion::CompletionProvider, Selection, Transaction};
|
||||||
use helix_event::TaskHandle;
|
use helix_event::TaskHandle;
|
||||||
use helix_stdx::path::{self, canonicalize, fold_home_dir, get_path_suffix};
|
use helix_stdx::path::{self, canonicalize, fold_home_dir, get_path_suffix};
|
||||||
use helix_view::Document;
|
use helix_view::Document;
|
||||||
|
@ -103,6 +103,7 @@ pub(crate) fn path_completion(
|
||||||
label: file_name.into(),
|
label: file_name.into(),
|
||||||
transaction,
|
transaction,
|
||||||
documentation,
|
documentation,
|
||||||
|
provider: CompletionProvider::Path,
|
||||||
}))
|
}))
|
||||||
})
|
})
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
|
|
Loading…
Reference in New Issue