summaryrefslogtreecommitdiff
path: root/support/texlab/src/features
diff options
context:
space:
mode:
Diffstat (limited to 'support/texlab/src/features')
-rw-r--r--support/texlab/src/features/build.rs6
-rw-r--r--support/texlab/src/features/completion.rs5
-rw-r--r--support/texlab/src/features/completion/util.rs2
-rw-r--r--support/texlab/src/features/cursor.rs4
-rw-r--r--support/texlab/src/features/highlight/label.rs12
-rw-r--r--support/texlab/src/features/lsp_kinds.rs100
6 files changed, 66 insertions, 63 deletions
diff --git a/support/texlab/src/features/build.rs b/support/texlab/src/features/build.rs
index 6953698a29..5505b9fb70 100644
--- a/support/texlab/src/features/build.rs
+++ b/support/texlab/src/features/build.rs
@@ -8,8 +8,8 @@ use std::{
use anyhow::Result;
use cancellation::CancellationToken;
-use chashmap::CHashMap;
use crossbeam_channel::Sender;
+use dashmap::DashMap;
use encoding_rs_io::DecodeReaderBytesBuilder;
use lsp_types::{
notification::{LogMessage, Progress},
@@ -101,7 +101,7 @@ impl<'a> Drop for ProgressReporter<'a> {
#[derive(Default)]
pub struct BuildEngine {
lock: Mutex<()>,
- pub positions_by_uri: CHashMap<Arc<Uri>, Position>,
+ pub positions_by_uri: DashMap<Arc<Uri>, Position>,
}
impl BuildEngine {
@@ -233,7 +233,7 @@ fn capture_output(
&lsp_sender,
LogMessageParams {
message,
- typ: lsp_types::MessageType::Log,
+ typ: lsp_types::MessageType::LOG,
},
)
.unwrap();
diff --git a/support/texlab/src/features/completion.rs b/support/texlab/src/features/completion.rs
index cb6a66f3cd..2a3f4ea9af 100644
--- a/support/texlab/src/features/completion.rs
+++ b/support/texlab/src/features/completion.rs
@@ -326,14 +326,15 @@ fn convert_internal_items(
.and_then(|cap| cap.snippet_support)
== Some(true)
{
+ let text_edit = TextEdit::new(range, "begin{$1}\n\t$0\n\\end{$1}".into());
CompletionItem {
kind: Some(adjust_kind(
&context.request,
Structure::Snippet.completion_kind(),
)),
data: Some(serde_json::to_value(CompletionItemData::CommandSnippet).unwrap()),
- insert_text: Some("begin{$1}\n\t$0\n\\end{$1}".into()),
- insert_text_format: Some(InsertTextFormat::Snippet),
+ text_edit: Some(CompletionTextEdit::Edit(text_edit)),
+ insert_text_format: Some(InsertTextFormat::SNIPPET),
..CompletionItem::new_simple("begin".into(), component_detail(&[]))
}
} else {
diff --git a/support/texlab/src/features/completion/util.rs b/support/texlab/src/features/completion/util.rs
index 296d6d25d9..5c4d83e4e9 100644
--- a/support/texlab/src/features/completion/util.rs
+++ b/support/texlab/src/features/completion/util.rs
@@ -62,5 +62,5 @@ pub fn adjust_kind(
return kind;
}
}
- CompletionItemKind::Text
+ CompletionItemKind::TEXT
}
diff --git a/support/texlab/src/features/cursor.rs b/support/texlab/src/features/cursor.rs
index d8db0f2aa8..d1de067091 100644
--- a/support/texlab/src/features/cursor.rs
+++ b/support/texlab/src/features/cursor.rs
@@ -46,7 +46,9 @@ impl Cursor {
return Some(Self::Latex(left));
}
- if right.kind() == latex::WHITESPACE && right.parent().kind() == latex::KEY {
+ if matches!(right.kind(), latex::WHITESPACE | latex::LINE_BREAK)
+ && right.parent().kind() == latex::KEY
+ {
return Some(Self::Latex(right));
}
diff --git a/support/texlab/src/features/highlight/label.rs b/support/texlab/src/features/highlight/label.rs
index 9694993033..9394378c09 100644
--- a/support/texlab/src/features/highlight/label.rs
+++ b/support/texlab/src/features/highlight/label.rs
@@ -31,7 +31,7 @@ pub fn find_label_highlights(
highlights.push(DocumentHighlight {
range,
- kind: Some(DocumentHighlightKind::Write),
+ kind: Some(DocumentHighlightKind::WRITE),
});
} else if let Some(label) = latex::LabelReference::cast(node) {
for label_name in label
@@ -46,7 +46,7 @@ pub fn find_label_highlights(
highlights.push(DocumentHighlight {
range,
- kind: Some(DocumentHighlightKind::Read),
+ kind: Some(DocumentHighlightKind::READ),
});
}
} else if let Some(label) = latex::LabelReferenceRange::cast(node) {
@@ -61,7 +61,7 @@ pub fn find_label_highlights(
highlights.push(DocumentHighlight {
range,
- kind: Some(DocumentHighlightKind::Read),
+ kind: Some(DocumentHighlightKind::READ),
});
}
@@ -76,7 +76,7 @@ pub fn find_label_highlights(
highlights.push(DocumentHighlight {
range,
- kind: Some(DocumentHighlightKind::Read),
+ kind: Some(DocumentHighlightKind::READ),
});
}
}
@@ -141,11 +141,11 @@ mod tests {
let expected_highlights = vec![
DocumentHighlight {
range: Range::new_simple(0, 7, 0, 10),
- kind: Some(DocumentHighlightKind::Write),
+ kind: Some(DocumentHighlightKind::WRITE),
},
DocumentHighlight {
range: Range::new_simple(1, 5, 1, 8),
- kind: Some(DocumentHighlightKind::Read),
+ kind: Some(DocumentHighlightKind::READ),
},
];
diff --git a/support/texlab/src/features/lsp_kinds.rs b/support/texlab/src/features/lsp_kinds.rs
index fbfc50cace..82706b5aee 100644
--- a/support/texlab/src/features/lsp_kinds.rs
+++ b/support/texlab/src/features/lsp_kinds.rs
@@ -30,64 +30,64 @@ pub enum Structure {
impl Structure {
pub fn completion_kind(self) -> CompletionItemKind {
match self {
- Self::Command => CompletionItemKind::Function,
- Self::Snippet => CompletionItemKind::Snippet,
- Self::Environment => CompletionItemKind::Enum,
- Self::Section => CompletionItemKind::Module,
- Self::Float => CompletionItemKind::Method,
- Self::Theorem => CompletionItemKind::Variable,
- Self::Equation => CompletionItemKind::Constant,
- Self::Item => CompletionItemKind::EnumMember,
- Self::Label => CompletionItemKind::Constructor,
- Self::Folder => CompletionItemKind::Folder,
- Self::File => CompletionItemKind::File,
- Self::PgfLibrary => CompletionItemKind::Property,
- Self::TikzLibrary => CompletionItemKind::Property,
- Self::Color => CompletionItemKind::Color,
- Self::ColorModel => CompletionItemKind::Color,
- Self::Package => CompletionItemKind::Class,
- Self::Class => CompletionItemKind::Class,
- Self::Entry(BibtexEntryTypeCategory::Misc) => CompletionItemKind::Interface,
- Self::Entry(BibtexEntryTypeCategory::String) => CompletionItemKind::Text,
- Self::Entry(BibtexEntryTypeCategory::Article) => CompletionItemKind::Event,
- Self::Entry(BibtexEntryTypeCategory::Book) => CompletionItemKind::Struct,
- Self::Entry(BibtexEntryTypeCategory::Collection) => CompletionItemKind::TypeParameter,
- Self::Entry(BibtexEntryTypeCategory::Part) => CompletionItemKind::Operator,
- Self::Entry(BibtexEntryTypeCategory::Thesis) => CompletionItemKind::Unit,
- Self::Field => CompletionItemKind::Field,
- Self::Argument => CompletionItemKind::Value,
- Self::GlossaryEntry => CompletionItemKind::Keyword,
+ Self::Command => CompletionItemKind::FUNCTION,
+ Self::Snippet => CompletionItemKind::SNIPPET,
+ Self::Environment => CompletionItemKind::ENUM,
+ Self::Section => CompletionItemKind::MODULE,
+ Self::Float => CompletionItemKind::METHOD,
+ Self::Theorem => CompletionItemKind::VARIABLE,
+ Self::Equation => CompletionItemKind::CONSTANT,
+ Self::Item => CompletionItemKind::ENUM_MEMBER,
+ Self::Label => CompletionItemKind::CONSTRUCTOR,
+ Self::Folder => CompletionItemKind::FOLDER,
+ Self::File => CompletionItemKind::FILE,
+ Self::PgfLibrary => CompletionItemKind::PROPERTY,
+ Self::TikzLibrary => CompletionItemKind::PROPERTY,
+ Self::Color => CompletionItemKind::COLOR,
+ Self::ColorModel => CompletionItemKind::COLOR,
+ Self::Package => CompletionItemKind::CLASS,
+ Self::Class => CompletionItemKind::CLASS,
+ Self::Entry(BibtexEntryTypeCategory::Misc) => CompletionItemKind::INTERFACE,
+ Self::Entry(BibtexEntryTypeCategory::String) => CompletionItemKind::TEXT,
+ Self::Entry(BibtexEntryTypeCategory::Article) => CompletionItemKind::EVENT,
+ Self::Entry(BibtexEntryTypeCategory::Book) => CompletionItemKind::STRUCT,
+ Self::Entry(BibtexEntryTypeCategory::Collection) => CompletionItemKind::TYPE_PARAMETER,
+ Self::Entry(BibtexEntryTypeCategory::Part) => CompletionItemKind::OPERATOR,
+ Self::Entry(BibtexEntryTypeCategory::Thesis) => CompletionItemKind::UNIT,
+ Self::Field => CompletionItemKind::FIELD,
+ Self::Argument => CompletionItemKind::VALUE,
+ Self::GlossaryEntry => CompletionItemKind::KEYWORD,
}
}
pub fn symbol_kind(self) -> SymbolKind {
match self {
- Self::Command => SymbolKind::Function,
+ Self::Command => SymbolKind::FUNCTION,
Self::Snippet => unimplemented!(),
- Self::Environment => SymbolKind::Enum,
- Self::Section => SymbolKind::Module,
- Self::Float => SymbolKind::Method,
- Self::Theorem => SymbolKind::Variable,
- Self::Equation => SymbolKind::Constant,
- Self::Item => SymbolKind::EnumMember,
- Self::Label => SymbolKind::Constructor,
- Self::Folder => SymbolKind::Namespace,
- Self::File => SymbolKind::File,
- Self::PgfLibrary => SymbolKind::Property,
- Self::TikzLibrary => SymbolKind::Property,
+ Self::Environment => SymbolKind::ENUM,
+ Self::Section => SymbolKind::MODULE,
+ Self::Float => SymbolKind::METHOD,
+ Self::Theorem => SymbolKind::VARIABLE,
+ Self::Equation => SymbolKind::CONSTANT,
+ Self::Item => SymbolKind::ENUM_MEMBER,
+ Self::Label => SymbolKind::CONSTRUCTOR,
+ Self::Folder => SymbolKind::NAMESPACE,
+ Self::File => SymbolKind::FILE,
+ Self::PgfLibrary => SymbolKind::PROPERTY,
+ Self::TikzLibrary => SymbolKind::PROPERTY,
Self::Color => unimplemented!(),
Self::ColorModel => unimplemented!(),
- Self::Package => SymbolKind::Class,
- Self::Class => SymbolKind::Class,
- Self::Entry(BibtexEntryTypeCategory::Misc) => SymbolKind::Interface,
- Self::Entry(BibtexEntryTypeCategory::String) => SymbolKind::String,
- Self::Entry(BibtexEntryTypeCategory::Article) => SymbolKind::Event,
- Self::Entry(BibtexEntryTypeCategory::Book) => SymbolKind::Struct,
- Self::Entry(BibtexEntryTypeCategory::Collection) => SymbolKind::TypeParameter,
- Self::Entry(BibtexEntryTypeCategory::Part) => SymbolKind::Operator,
- Self::Entry(BibtexEntryTypeCategory::Thesis) => SymbolKind::Object,
- Self::Field => SymbolKind::Field,
- Self::Argument => SymbolKind::Number,
+ Self::Package => SymbolKind::CLASS,
+ Self::Class => SymbolKind::CLASS,
+ Self::Entry(BibtexEntryTypeCategory::Misc) => SymbolKind::INTERFACE,
+ Self::Entry(BibtexEntryTypeCategory::String) => SymbolKind::STRING,
+ Self::Entry(BibtexEntryTypeCategory::Article) => SymbolKind::EVENT,
+ Self::Entry(BibtexEntryTypeCategory::Book) => SymbolKind::STRUCT,
+ Self::Entry(BibtexEntryTypeCategory::Collection) => SymbolKind::TYPE_PARAMETER,
+ Self::Entry(BibtexEntryTypeCategory::Part) => SymbolKind::OPERATOR,
+ Self::Entry(BibtexEntryTypeCategory::Thesis) => SymbolKind::OBJECT,
+ Self::Field => SymbolKind::FIELD,
+ Self::Argument => SymbolKind::NUMBER,
Self::GlossaryEntry => unimplemented!(),
}
}