core: Add a provider type to track the origin of a completion

pull/12778/head
Pascal Kuthe 2025-02-01 12:36:55 -05:00 committed by Michael Davis
parent f0fa905622
commit 018081a5b1
No known key found for this signature in database
2 changed files with 16 additions and 2 deletions

View File

@ -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)
}
} }

View File

@ -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<_>>()