summaryrefslogtreecommitdiff
path: root/support/texlab/crates/completion/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'support/texlab/crates/completion/src/lib.rs')
-rw-r--r--support/texlab/crates/completion/src/lib.rs29
1 files changed, 28 insertions, 1 deletions
diff --git a/support/texlab/crates/completion/src/lib.rs b/support/texlab/crates/completion/src/lib.rs
index 6acec28d49..7fc5bba174 100644
--- a/support/texlab/crates/completion/src/lib.rs
+++ b/support/texlab/crates/completion/src/lib.rs
@@ -45,6 +45,7 @@ impl<'a> CompletionItem<'a> {
#[derive(Debug, PartialEq, Eq)]
pub enum CompletionItemData<'a> {
Command(CommandData<'a>),
+ CommandLikeDelimiter(&'a str, &'a str),
BeginEnvironment,
Citation(CitationData<'a>),
Environment(EnvironmentData<'a>),
@@ -66,6 +67,7 @@ impl<'a> CompletionItemData<'a> {
pub fn label<'b: 'a>(&'b self) -> &'a str {
match self {
Self::Command(data) => data.name,
+ Self::CommandLikeDelimiter(left, _) => left,
Self::BeginEnvironment => "begin",
Self::Citation(data) => &data.entry.name.text,
Self::Environment(data) => data.name,
@@ -83,6 +85,30 @@ impl<'a> CompletionItemData<'a> {
Self::TikzLibrary(name) => name,
}
}
+
+ /// Returns a number that can be used to sort the completion items further before resorting to the label.
+ /// This is useful for making snippets more visible.
+ pub fn sort_index(&self) -> u8 {
+ match self {
+ Self::Command(_) => 1,
+ Self::CommandLikeDelimiter(_, _) => 0,
+ Self::BeginEnvironment => 1,
+ Self::Citation(_) => 1,
+ Self::Environment(_) => 1,
+ Self::GlossaryEntry(_) => 1,
+ Self::Label(_) => 1,
+ Self::Color(_) => 1,
+ Self::ColorModel(_) => 1,
+ Self::File(_) => 1,
+ Self::Directory(_) => 1,
+ Self::Argument(_) => 1,
+ Self::Package(_) => 1,
+ Self::DocumentClass(_) => 1,
+ Self::EntryType(_) => 1,
+ Self::Field(_) => 1,
+ Self::TikzLibrary(_) => 1,
+ }
+ }
}
#[derive(PartialEq, Eq)]
@@ -171,7 +197,8 @@ pub fn complete<'a>(params: &'a CompletionParams<'a>) -> CompletionResult<'a> {
providers::complete_citations(params, &mut builder);
providers::complete_acronyms(params, &mut builder);
providers::complete_glossaries(params, &mut builder);
- providers::complete_labels(params, &mut builder);
+ providers::complete_label_references(params, &mut builder);
+ providers::complete_label_definitions(params, &mut builder);
providers::complete_colors(params, &mut builder);
providers::complete_color_models(params, &mut builder);
providers::complete_includes(params, &mut builder);