Skip to content

Commit

Permalink
Move completion database into a separate crate
Browse files Browse the repository at this point in the history
  • Loading branch information
pfoerster committed Jul 30, 2019
1 parent 6ad870e commit e201b39
Show file tree
Hide file tree
Showing 14 changed files with 135 additions and 84 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ target/
**/*.rs.bk
/.idea
tarpaulin-report.html
src/data/completion.json
crates/texlab_completion_data/src/completion.json
174 changes: 105 additions & 69 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ members = [
"crates/jsonrpc",
"crates/jsonrpc_derive",
"crates/texlab_citeproc",
"crates/texlab_completion_data",
"crates/texlab_syntax",
"crates/texlab_workspace"]

Expand Down Expand Up @@ -42,6 +43,7 @@ serde_repr = "0.1"
stderrlog = "0.4.1"
tempfile = "3"
texlab-citeproc = { path = "crates/texlab_citeproc" }
texlab-completion-data = { path = "crates/texlab_completion_data" }
texlab-syntax = { path = "crates/texlab_syntax" }
texlab-workspace = { path = "crates/texlab_workspace" }
tokio = "0.1"
Expand All @@ -56,9 +58,6 @@ walkdir = "2"
[dev-dependencies]
criterion = "0.2"

[build-dependencies]
reqwest = { version = "0.9", default-features = false, features = ["rustls-tls"] }

[[bench]]
name = "completion"
harness = false
Expand Down
19 changes: 19 additions & 0 deletions crates/texlab_completion_data/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "texlab-completion-data"
version = "0.1.0"
authors = [
"Eric Förster <[email protected]>",
"Patrick Förster <[email protected]>"]
edition = "2018"

[dependencies]
itertools = "0.8.0"
lsp-types = { git = "https://github.com/latex-lsp/lsp-types", rev = "9fcc5d9b9d3013ce84e20ef566267754d594b268", features = ["proposed"] }
once_cell = "0.2.2"
serde = { version = "1.0.97", features = ["derive", "rc"] }
serde_json = "1.0.40"
texlab-syntax = { path = "../texlab_syntax" }
texlab-workspace = { path = "../texlab_workspace" }

[build-dependencies]
reqwest = { version = "0.9", default-features = false, features = ["rustls-tls"] }
2 changes: 1 addition & 1 deletion build.rs → crates/texlab_completion_data/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ fn main() {
.expect("Failed to download completion database")
.text()
.unwrap();
fs::write("src/data/completion.json", text).expect("Failed to save completion database");
fs::write("src/completion.json", text).expect("Failed to save completion database");
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ impl Database {
.for_each(|component| all_components.push(component))
}

log::info!("Components = {:?}", all_components.len());

all_components
.into_iter()
.unique_by(|component| &component.file_names)
Expand Down
2 changes: 1 addition & 1 deletion src/completion/bibtex/command.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::completion::factory::{self, LatexComponentId};
use crate::data::completion::DATABASE;
use texlab_completion_data::DATABASE;
use crate::feature::{FeatureProvider, FeatureRequest};
use futures_boxed::boxed;
use lsp_types::*;
Expand Down
2 changes: 1 addition & 1 deletion src/completion/latex/argument.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::completion::factory;
use crate::completion::latex::combinators::{self, Parameter};
use crate::data::completion::DATABASE;
use texlab_completion_data::DATABASE;
use crate::feature::{FeatureProvider, FeatureRequest};
use futures_boxed::boxed;
use lsp_types::*;
Expand Down
2 changes: 1 addition & 1 deletion src/completion/latex/component.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::completion::factory::{self, LatexComponentId};
use crate::completion::latex::combinators;
use crate::data::completion::DATABASE;
use texlab_completion_data::DATABASE;
use crate::feature::{FeatureProvider, FeatureRequest};
use futures_boxed::boxed;
use lsp_types::*;
Expand Down
2 changes: 1 addition & 1 deletion src/completion/latex/import.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::completion::factory;
use crate::completion::latex::combinators::{self, Parameter};
use crate::data::completion::DATABASE;
use texlab_completion_data::DATABASE;
use crate::feature::{FeatureProvider, FeatureRequest};
use futures_boxed::boxed;
use lsp_types::{CompletionItem, CompletionParams, TextEdit};
Expand Down
1 change: 0 additions & 1 deletion src/data/mod.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
pub mod completion;
pub mod label;
2 changes: 1 addition & 1 deletion src/hover/latex_component.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::data::completion::DATABASE;
use texlab_completion_data::DATABASE;
use crate::feature::{FeatureProvider, FeatureRequest};
use futures_boxed::boxed;
use lsp_types::{Hover, HoverContents, TextDocumentPositionParams};
Expand Down
2 changes: 1 addition & 1 deletion src/hover/latex_preview.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::data::completion::DATABASE;
use texlab_completion_data::DATABASE;
use crate::feature::{FeatureProvider, FeatureRequest};
use crate::tex;
use futures::compat::*;
Expand Down
2 changes: 1 addition & 1 deletion src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::action::{Action, ActionMananger, LintReason};
use crate::build::*;
use crate::client::LspClient;
use crate::completion::{CompletionItemData, CompletionProvider};
use crate::data::completion::DATABASE;
use texlab_completion_data::DATABASE;
use crate::definition::DefinitionProvider;
use crate::diagnostics::{DiagnosticsManager, LatexLintOptions};
use crate::feature::{DocumentView, FeatureProvider, FeatureRequest};
Expand Down

0 comments on commit e201b39

Please sign in to comment.