summaryrefslogtreecommitdiff
path: root/support/texlab/crates/base-db/src
diff options
context:
space:
mode:
Diffstat (limited to 'support/texlab/crates/base-db/src')
-rw-r--r--support/texlab/crates/base-db/src/config.rs54
-rw-r--r--support/texlab/crates/base-db/src/deps/graph.rs6
-rw-r--r--support/texlab/crates/base-db/src/deps/root.rs4
-rw-r--r--support/texlab/crates/base-db/src/semantics/auxiliary.rs2
-rw-r--r--support/texlab/crates/base-db/src/semantics/tex.rs63
-rw-r--r--support/texlab/crates/base-db/src/workspace.rs2
6 files changed, 51 insertions, 80 deletions
diff --git a/support/texlab/crates/base-db/src/config.rs b/support/texlab/crates/base-db/src/config.rs
index 9814e3e674..e4c827e61c 100644
--- a/support/texlab/crates/base-db/src/config.rs
+++ b/support/texlab/crates/base-db/src/config.rs
@@ -3,9 +3,8 @@ use std::time::Duration;
use parser::SyntaxConfig;
use regex::Regex;
-#[derive(Debug)]
+#[derive(Debug, Default)]
pub struct Config {
- pub root_dir: Option<String>,
pub build: BuildConfig,
pub diagnostics: DiagnosticsConfig,
pub formatting: FormattingConfig,
@@ -36,7 +35,7 @@ pub struct DiagnosticsConfig {
pub delay: Duration,
}
-#[derive(Debug)]
+#[derive(Debug, Default)]
pub struct ChktexConfig {
pub on_open: bool,
pub on_save: bool,
@@ -65,13 +64,13 @@ pub enum Formatter {
LatexIndent,
}
-#[derive(Debug)]
+#[derive(Debug, Default)]
pub struct LatexIndentConfig {
pub local: Option<String>,
pub modify_line_breaks: bool,
}
-#[derive(Debug)]
+#[derive(Debug, Default)]
pub struct SymbolConfig {
pub allowed_patterns: Vec<Regex>,
pub ignored_patterns: Vec<Regex>,
@@ -96,22 +95,6 @@ pub enum MatchingAlgo {
PrefixIgnoreCase,
}
-impl Default for Config {
- fn default() -> Self {
- Self {
- root_dir: None,
- build: BuildConfig::default(),
- diagnostics: DiagnosticsConfig::default(),
- formatting: FormattingConfig::default(),
- synctex: None,
- symbols: SymbolConfig::default(),
- syntax: SyntaxConfig::default(),
- completion: CompletionConfig::default(),
- inlay_hints: InlayHintConfig::default(),
- }
- }
-}
-
impl Default for BuildConfig {
fn default() -> Self {
Self {
@@ -141,17 +124,6 @@ impl Default for DiagnosticsConfig {
}
}
-impl Default for ChktexConfig {
- fn default() -> Self {
- Self {
- on_open: false,
- on_save: false,
- on_edit: false,
- additional_args: Vec::new(),
- }
- }
-}
-
impl Default for FormattingConfig {
fn default() -> Self {
Self {
@@ -163,24 +135,6 @@ impl Default for FormattingConfig {
}
}
-impl Default for LatexIndentConfig {
- fn default() -> Self {
- Self {
- local: None,
- modify_line_breaks: false,
- }
- }
-}
-
-impl Default for SymbolConfig {
- fn default() -> Self {
- Self {
- allowed_patterns: Vec::new(),
- ignored_patterns: Vec::new(),
- }
- }
-}
-
impl Default for InlayHintConfig {
fn default() -> Self {
Self {
diff --git a/support/texlab/crates/base-db/src/deps/graph.rs b/support/texlab/crates/base-db/src/deps/graph.rs
index e07368d078..4b2399b7f8 100644
--- a/support/texlab/crates/base-db/src/deps/graph.rs
+++ b/support/texlab/crates/base-db/src/deps/graph.rs
@@ -22,7 +22,7 @@ pub struct Edge {
#[derive(Debug, PartialEq, Eq, Clone, Hash)]
pub enum EdgeData {
- DirectLink(DirectLinkData),
+ DirectLink(Box<DirectLinkData>),
AdditionalFiles,
Artifact,
}
@@ -159,7 +159,7 @@ impl Graph {
for target_uri in file_names
.iter()
.flat_map(|file_name| {
- util::expand_relative_path(&file_name, &start.root.src_dir, workspace.folders())
+ util::expand_relative_path(file_name, &start.root.src_dir, workspace.folders())
})
.chain(distro_files)
{
@@ -179,7 +179,7 @@ impl Graph {
self.edges.push(Edge {
source: start.source.uri.clone(),
target: target.uri.clone(),
- data: EdgeData::DirectLink(link_data),
+ data: EdgeData::DirectLink(Box::new(link_data)),
});
break;
diff --git a/support/texlab/crates/base-db/src/deps/root.rs b/support/texlab/crates/base-db/src/deps/root.rs
index a8cec6604a..03fd41a9a0 100644
--- a/support/texlab/crates/base-db/src/deps/root.rs
+++ b/support/texlab/crates/base-db/src/deps/root.rs
@@ -31,11 +31,11 @@ impl ProjectRoot {
}
let Ok(parent) = current.join("..") else {
- break Self::from_config(workspace, &dir);
+ break Self::from_config(workspace, dir);
};
if current == parent || Some(&parent) == home_dir.as_ref() {
- break Self::from_config(workspace, &dir);
+ break Self::from_config(workspace, dir);
}
current = parent;
diff --git a/support/texlab/crates/base-db/src/semantics/auxiliary.rs b/support/texlab/crates/base-db/src/semantics/auxiliary.rs
index 489a7d1ac6..8c9fe012e6 100644
--- a/support/texlab/crates/base-db/src/semantics/auxiliary.rs
+++ b/support/texlab/crates/base-db/src/semantics/auxiliary.rs
@@ -36,7 +36,7 @@ impl Semantics {
Some(group)
})?;
- let text = group.content_text()?.replace('{', "").replace('}', "");
+ let text = group.content_text()?.replace(['{', '}'], "");
self.label_numbers.insert(name, text);
Some(())
}
diff --git a/support/texlab/crates/base-db/src/semantics/tex.rs b/support/texlab/crates/base-db/src/semantics/tex.rs
index 1ad8969a80..7e4c926f5d 100644
--- a/support/texlab/crates/base-db/src/semantics/tex.rs
+++ b/support/texlab/crates/base-db/src/semantics/tex.rs
@@ -116,6 +116,11 @@ impl Semantics {
return;
};
+ let name = Span::from(&name);
+ if name.text.contains('#') {
+ return;
+ }
+
let full_range = latex::small_range(&label);
let mut objects = Vec::new();
for node in label.syntax().ancestors() {
@@ -185,7 +190,7 @@ impl Semantics {
self.labels.push(Label {
kind: LabelKind::Definition,
- name: Span::from(&name),
+ name,
targets: objects,
full_range,
});
@@ -198,33 +203,42 @@ impl Semantics {
let full_range = latex::small_range(&label);
for name in name_list.keys() {
- self.labels.push(Label {
- kind: LabelKind::Reference,
- name: Span::from(&name),
- targets: Vec::new(),
- full_range,
- });
+ let name = Span::from(&name);
+ if !name.text.contains('#') {
+ self.labels.push(Label {
+ kind: LabelKind::Reference,
+ name,
+ targets: Vec::new(),
+ full_range,
+ });
+ }
}
}
fn process_label_reference_range(&mut self, label: latex::LabelReferenceRange) {
let full_range = latex::small_range(&label);
if let Some(from) = label.from().and_then(|group| group.key()) {
- self.labels.push(Label {
- kind: LabelKind::ReferenceRange,
- name: Span::from(&from),
- targets: Vec::new(),
- full_range,
- });
+ let name = Span::from(&from);
+ if !name.text.contains('#') {
+ self.labels.push(Label {
+ kind: LabelKind::ReferenceRange,
+ name,
+ targets: Vec::new(),
+ full_range,
+ });
+ }
}
if let Some(to) = label.to().and_then(|group| group.key()) {
- self.labels.push(Label {
- kind: LabelKind::ReferenceRange,
- name: Span::from(&to),
- targets: Vec::new(),
- full_range,
- });
+ let name = Span::from(&to);
+ if !name.text.contains('#') {
+ self.labels.push(Label {
+ kind: LabelKind::ReferenceRange,
+ name,
+ targets: Vec::new(),
+ full_range,
+ });
+ }
}
}
@@ -232,10 +246,13 @@ impl Semantics {
let full_range = latex::small_range(&citation);
if let Some(list) = citation.key_list() {
for key in list.keys() {
- self.citations.push(Citation {
- name: Span::from(&key),
- full_range,
- });
+ let name = Span::from(&key);
+ if !name.text.contains('#') {
+ self.citations.push(Citation {
+ name: Span::from(&key),
+ full_range,
+ });
+ }
}
}
}
diff --git a/support/texlab/crates/base-db/src/workspace.rs b/support/texlab/crates/base-db/src/workspace.rs
index 75674dcf8d..f2564ed415 100644
--- a/support/texlab/crates/base-db/src/workspace.rs
+++ b/support/texlab/crates/base-db/src/workspace.rs
@@ -99,7 +99,7 @@ impl Workspace {
Cow::Owned(text) => text,
};
- let owner = if self.distro.file_name_db.contains(&path) {
+ let owner = if self.distro.file_name_db.contains(path) {
Owner::Distro
} else {
Owner::Server