Move workspace module to a separate crate

This commit is contained in:
Patrick Förster 2019-12-12 10:00:37 +01:00
parent 24abeaf8d5
commit 864a109ab8
79 changed files with 203 additions and 162 deletions

17
Cargo.lock generated
View file

@ -2025,6 +2025,7 @@ dependencies = [
"texlab-distro 0.1.0",
"texlab-protocol 0.1.0",
"texlab-syntax 0.1.0",
"texlab-workspace 0.1.0",
"tokio 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"tokio-util 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"url 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2080,6 +2081,22 @@ dependencies = [
"texlab-protocol 0.1.0",
]
[[package]]
name = "texlab-workspace"
version = "0.1.0"
dependencies = [
"futures 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"futures-boxed 0.1.0",
"itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
"once_cell 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.44 (registry+https://github.com/rust-lang/crates.io-index)",
"texlab-distro 0.1.0",
"texlab-protocol 0.1.0",
"texlab-syntax 0.1.0",
]
[[package]]
name = "textwrap"
version = "0.11.0"

View file

@ -18,7 +18,8 @@ members = [
"crates/jsonrpc_derive",
"crates/texlab_distro",
"crates/texlab_protocol",
"crates/texlab_syntax"]
"crates/texlab_syntax",
"crates/texlab_workspace"]
[dependencies]
base64 = "0.11.0"
@ -51,6 +52,7 @@ tempfile = "3"
texlab-distro = { path = "crates/texlab_distro" }
texlab-protocol = { path = "crates/texlab_protocol" }
texlab-syntax = { path = "crates/texlab_syntax" }
texlab-workspace = { path = "crates/texlab_workspace" }
tokio = { version = "0.2", features = ["fs", "process"] }
tokio-util = { version = "0.2", features = ["codec"] }
uuid = { version = "0.8", features = ["v4"] }

View file

@ -0,0 +1,19 @@
[package]
name = "texlab-workspace"
version = "0.1.0"
authors = [
"Eric Förster <efoerster@users.noreply.github.com>",
"Patrick Förster <pfoerster@users.noreply.github.com>"]
edition = "2018"
[dependencies]
futures = "0.3"
futures-boxed = { path = "../futures_boxed" }
itertools = "0.8.2"
log = "0.4.6"
once_cell = "1.2.0"
serde = { version = "1.0.103", features = ["derive", "rc"] }
serde_json = "1.0.44"
texlab-distro = { path = "../texlab_distro" }
texlab-protocol = { path = "../texlab_protocol" }
texlab-syntax = { path = "../texlab_syntax" }

View file

@ -1,4 +1,4 @@
use crate::workspace::Document;
use super::document::Document;
use itertools::Itertools;
use once_cell::sync::Lazy;
use serde::{Deserialize, Serialize};
@ -120,6 +120,6 @@ pub struct Metadata {
pub description: Option<String>,
}
const JSON: &str = include_str!("data.json");
const JSON: &str = include_str!("completion.json");
pub static DATABASE: Lazy<Database> = Lazy::new(|| serde_json::from_str(JSON).unwrap());
pub static COMPLETION_DATABASE: Lazy<Database> = Lazy::new(|| serde_json::from_str(JSON).unwrap());

View file

@ -0,0 +1,36 @@
use std::time::SystemTime;
use texlab_distro::{Language, Resolver};
use texlab_protocol::*;
use texlab_syntax::{SyntaxTree, SyntaxTreeContext};
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct Document {
pub uri: Uri,
pub text: String,
pub tree: SyntaxTree,
pub modified: SystemTime,
}
impl Document {
pub fn new(uri: Uri, text: String, tree: SyntaxTree) -> Self {
Self {
uri,
text,
tree,
modified: SystemTime::now(),
}
}
pub fn parse(resolver: &Resolver, uri: Uri, text: String, language: Language) -> Self {
let context = SyntaxTreeContext {
resolver,
uri: &uri,
};
let tree = SyntaxTree::parse(context, &text, language);
Self::new(uri, text, tree)
}
pub fn is_file(&self) -> bool {
self.uri.scheme() == "file"
}
}

View file

@ -1,9 +1,28 @@
use super::{Document, DocumentView, Workspace, WorkspaceBuilder};
use super::document::Document;
use super::workspace::{Workspace, WorkspaceBuilder};
use futures_boxed::boxed;
use std::sync::Arc;
use texlab_distro::{Distribution, UnknownDistribution};
use texlab_protocol::*;
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct DocumentView {
pub workspace: Arc<Workspace>,
pub document: Arc<Document>,
pub related_documents: Vec<Arc<Document>>,
}
impl DocumentView {
pub fn new(workspace: Arc<Workspace>, document: Arc<Document>) -> Self {
let related_documents = workspace.related_documents(&document.uri);
Self {
workspace,
document,
related_documents,
}
}
}
pub struct FeatureRequest<P> {
pub params: P,
pub view: DocumentView,

View file

@ -0,0 +1,11 @@
mod completion;
mod document;
mod feature;
mod outline;
mod workspace;
pub use self::completion::*;
pub use self::document::Document;
pub use self::feature::*;
pub use self::outline::*;
pub use self::workspace::*;

View file

@ -1,7 +1,6 @@
use super::{Document, DocumentView};
use crate::workspace::Uri;
use super::document::Document;
use super::feature::DocumentView;
use std::collections::HashSet;
use texlab_protocol::RangeExt;
use texlab_protocol::*;
use texlab_syntax::*;

View file

@ -1,10 +1,5 @@
mod feature;
mod outline;
pub use self::feature::*;
pub use self::outline::*;
use crate::completion::DATABASE;
use super::completion::COMPLETION_DATABASE;
use super::document::Document;
use futures::executor::block_on;
use log::*;
use std::env;
@ -12,43 +7,10 @@ use std::ffi::OsStr;
use std::fs;
use std::path::{Path, PathBuf};
use std::sync::{Arc, Mutex};
use std::time::SystemTime;
use texlab_distro::{Distribution, Language, Resolver};
use texlab_protocol::*;
use texlab_syntax::*;
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct Document {
pub uri: Uri,
pub text: String,
pub tree: SyntaxTree,
pub modified: SystemTime,
}
impl Document {
pub fn new(uri: Uri, text: String, tree: SyntaxTree) -> Self {
Self {
uri,
text,
tree,
modified: SystemTime::now(),
}
}
pub fn parse(resolver: &Resolver, uri: Uri, text: String, language: Language) -> Self {
let context = SyntaxTreeContext {
resolver,
uri: &uri,
};
let tree = SyntaxTree::parse(context, &text, language);
Self::new(uri, text, tree)
}
pub fn is_file(&self) -> bool {
self.uri.scheme() == "file"
}
}
#[derive(Debug, PartialEq, Eq, Clone, Default)]
pub struct Workspace {
pub documents: Vec<Arc<Document>>,
@ -143,7 +105,7 @@ impl Workspace {
if include
.paths()
.iter()
.all(|name| DATABASE.contains(name.text()))
.all(|name| COMPLETION_DATABASE.contains(name.text()))
{
continue;
}
@ -183,24 +145,6 @@ impl Workspace {
}
}
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct DocumentView {
pub workspace: Arc<Workspace>,
pub document: Arc<Document>,
pub related_documents: Vec<Arc<Document>>,
}
impl DocumentView {
pub fn new(workspace: Arc<Workspace>, document: Arc<Document>) -> Self {
let related_documents = workspace.related_documents(&document.uri);
Self {
workspace,
document,
related_documents,
}
}
}
#[derive(Debug)]
pub enum LoadError {
UnknownLanguage,

View file

@ -1,4 +1,4 @@
use crate::workspace::*;
use texlab_workspace::*;
use futures::future::{AbortHandle, Abortable, Aborted};
use futures::lock::Mutex;
use futures::prelude::*;

View file

@ -1,10 +1,8 @@
use crate::completion::factory::{self, LatexComponentId};
use crate::completion::DATABASE;
use crate::workspace::*;
use futures_boxed::boxed;
use texlab_protocol::RangeExt;
use texlab_protocol::*;
use texlab_syntax::*;
use texlab_workspace::*;
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub struct BibtexCommandCompletionProvider;
@ -26,7 +24,7 @@ impl FeatureProvider for BibtexCommandCompletionProvider {
range.start.character += 1;
let component = LatexComponentId::kernel();
for command in &DATABASE.kernel().commands {
for command in &COMPLETION_DATABASE.kernel().commands {
let text_edit = TextEdit::new(range, (&command.name).into());
let item = factory::command(
request,

View file

@ -1,7 +1,6 @@
use crate::completion::factory;
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use texlab_protocol::RangeExt;
use texlab_protocol::*;
use texlab_syntax::*;

View file

@ -1,9 +1,8 @@
use crate::completion::factory;
use crate::workspace::*;
use futures_boxed::boxed;
use texlab_protocol::RangeExt;
use texlab_protocol::{CompletionItem, CompletionParams, Range, TextEdit};
use texlab_protocol::*;
use texlab_syntax::*;
use texlab_workspace::*;
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub struct BibtexFieldNameCompletionProvider;

View file

@ -1,6 +1,6 @@
use crate::formatting::bibtex::{self, BibtexFormattingParams};
use crate::lsp_kind::Structure;
use crate::workspace::*;
use texlab_workspace::*;
use once_cell::sync::Lazy;
use regex::Regex;
use serde::{Deserialize, Serialize};

View file

@ -1,9 +1,9 @@
use super::combinators::{self, Parameter};
use crate::completion::{factory, DATABASE};
use crate::workspace::*;
use crate::completion::factory;
use futures_boxed::boxed;
use std::iter;
use texlab_protocol::*;
use texlab_workspace::*;
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub struct LatexArgumentCompletionProvider;
@ -15,7 +15,7 @@ impl FeatureProvider for LatexArgumentCompletionProvider {
#[boxed]
async fn execute<'a>(&'a self, request: &'a FeatureRequest<Self::Params>) -> Self::Output {
let mut all_items = Vec::new();
for component in DATABASE.related_components(request.related_documents()) {
for component in COMPLETION_DATABASE.related_components(request.related_documents()) {
for command in &component.commands {
let name = format!("\\{}", command.name);
for (i, parameter) in command.parameters.iter().enumerate() {
@ -52,8 +52,7 @@ impl FeatureProvider for LatexArgumentCompletionProvider {
#[cfg(test)]
mod tests {
use super::*;
use texlab_protocol::RangeExt;
use texlab_protocol::{Position, Range};
use texlab_protocol::{Position, Range, RangeExt};
#[test]
fn test_inside_mathbb_empty() {

View file

@ -1,6 +1,6 @@
use super::combinators;
use crate::completion::factory::{self, LatexComponentId};
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use texlab_protocol::{CompletionItem, CompletionParams};

View file

@ -1,6 +1,6 @@
use super::combinators::{self, Parameter};
use crate::completion::factory;
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use texlab_protocol::{CompletionItem, CompletionParams, TextEdit};
use texlab_syntax::*;

View file

@ -1,6 +1,6 @@
use super::combinators::{self, Parameter};
use crate::completion::factory;
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use texlab_protocol::{CompletionItem, CompletionParams, TextEdit};
use texlab_syntax::*;

View file

@ -1,6 +1,6 @@
use super::combinators::{self, Parameter};
use crate::completion::factory;
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use texlab_protocol::{CompletionItem, CompletionParams, TextEdit};
use texlab_syntax::LANGUAGE_DATA;

View file

@ -1,4 +1,4 @@
use crate::workspace::*;
use texlab_workspace::*;
use std::future::Future;
use std::sync::Arc;
use texlab_protocol::RangeExt;

View file

@ -1,9 +1,8 @@
use super::combinators;
use crate::completion::factory::{self, LatexComponentId};
use crate::completion::DATABASE;
use crate::workspace::*;
use futures_boxed::boxed;
use texlab_protocol::*;
use texlab_workspace::*;
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub struct LatexComponentCommandCompletionProvider;
@ -18,7 +17,8 @@ impl FeatureProvider for LatexComponentCommandCompletionProvider {
async move {
let range = command.short_name_range();
let mut items = Vec::new();
for component in DATABASE.related_components(request.related_documents()) {
for component in COMPLETION_DATABASE.related_components(request.related_documents())
{
let file_names = component.file_names.iter().map(AsRef::as_ref).collect();
let id = LatexComponentId::Component(file_names);
for command in &component.commands {
@ -53,7 +53,7 @@ impl FeatureProvider for LatexComponentEnvironmentCompletionProvider {
combinators::environment(request, |context| {
async move {
let mut items = Vec::new();
for component in DATABASE.related_components(request.related_documents()) {
for component in COMPLETION_DATABASE.related_components(request.related_documents()) {
let file_names = component.file_names.iter().map(AsRef::as_ref).collect();
let id = LatexComponentId::Component(file_names);
for environment in &component.environments {

View file

@ -1,6 +1,6 @@
use super::combinators::{self, Parameter};
use crate::completion::factory;
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use texlab_protocol::{CompletionItem, CompletionParams, TextEdit};
use texlab_syntax::LatexGlossaryEntryKind::*;

View file

@ -1,6 +1,6 @@
use super::combinators::{self, Parameter};
use crate::completion::{factory, DATABASE};
use crate::workspace::*;
use crate::completion::factory;
use texlab_workspace::*;
use futures_boxed::boxed;
use texlab_protocol::{CompletionItem, CompletionParams, TextEdit};
use texlab_syntax::*;
@ -54,7 +54,7 @@ where
combinators::argument(request, parameters, |context| {
async move {
let resolver = request.distribution.resolver().await;
DATABASE
COMPLETION_DATABASE
.components
.iter()
.flat_map(|comp| comp.file_names.iter())

View file

@ -1,6 +1,6 @@
use super::combinators::{self, Parameter};
use crate::completion::factory;
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use std::path::{Path, PathBuf};
use texlab_protocol::RangeExt;

View file

@ -1,6 +1,6 @@
use super::combinators::{self, ArgumentContext, Parameter};
use crate::completion::factory;
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use std::sync::Arc;
use texlab_protocol::RangeExt;

View file

@ -1,6 +1,6 @@
use super::combinators;
use crate::completion::factory::{self, LatexComponentId};
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use texlab_protocol::{CompletionItem, CompletionParams, TextEdit};
use texlab_syntax::*;

View file

@ -1,6 +1,6 @@
use super::combinators::{self, Parameter};
use crate::completion::factory;
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use texlab_protocol::{CompletionItem, CompletionParams, TextEdit};
use texlab_syntax::LANGUAGE_DATA;

View file

@ -1,6 +1,6 @@
use super::combinators;
use crate::completion::factory::{self, LatexComponentId};
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use itertools::Itertools;
use texlab_protocol::*;

View file

@ -1,15 +1,14 @@
mod bibtex;
mod data;
mod factory;
mod latex;
mod preselect;
mod quality;
pub use self::factory::CompletionItemData;
use self::bibtex::command::BibtexCommandCompletionProvider;
use self::bibtex::entry_type::BibtexEntryTypeCompletionProvider;
use self::bibtex::field_name::BibtexFieldNameCompletionProvider;
pub use self::data::DATABASE;
pub use self::factory::CompletionItemData;
use self::latex::argument::LatexArgumentCompletionProvider;
use self::latex::begin_command::LatexBeginCommandCompletionProvider;
use self::latex::citation::LatexCitationCompletionProvider;
@ -25,7 +24,7 @@ use self::latex::tikz::*;
use self::latex::user::*;
use self::preselect::PreselectCompletionProvider;
use self::quality::OrderByQualityCompletionProvider;
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use itertools::Itertools;
use std::hash::{Hash, Hasher};

View file

@ -1,4 +1,4 @@
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use texlab_protocol::RangeExt;
use texlab_protocol::{CompletionItem, CompletionParams};

View file

@ -1,4 +1,4 @@
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use std::borrow::Cow;
use texlab_protocol::RangeExt;

View file

@ -1,4 +1,4 @@
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use texlab_protocol::*;
use texlab_syntax::*;

View file

@ -1,4 +1,4 @@
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use texlab_protocol::RangeExt;
use texlab_protocol::{LocationLink, TextDocumentPositionParams};

View file

@ -1,4 +1,4 @@
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use texlab_protocol::{LocationLink, TextDocumentPositionParams};
use texlab_syntax::*;

View file

@ -1,5 +1,5 @@
use crate::symbol::build_section_tree;
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use std::sync::Arc;
use texlab_protocol::RangeExt;

View file

@ -7,7 +7,7 @@ use self::bibtex_string::BibtexStringDefinitionProvider;
use self::latex_citation::LatexCitationDefinitionProvider;
use self::latex_command::LatexCommandDefinitionProvider;
use self::latex_label::LatexLabelDefinitionProvider;
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use texlab_protocol::{LocationLink, TextDocumentPositionParams};

View file

@ -1,4 +1,4 @@
use crate::workspace::Document;
use texlab_workspace::Document;
use texlab_protocol::{Diagnostic, DiagnosticSeverity, Position, Range};
use texlab_syntax::*;

View file

@ -1,4 +1,4 @@
use crate::workspace::Document;
use texlab_workspace::Document;
use once_cell::sync::Lazy;
use path_clean::PathClean;
use regex::{Match, Regex};

View file

@ -1,4 +1,4 @@
use crate::workspace::Document;
use texlab_workspace::Document;
use once_cell::sync::Lazy;
use regex::Regex;
use std::collections::HashMap;

View file

@ -7,8 +7,8 @@ pub use self::bibtex::BibtexErrorCode;
use self::bibtex::BibtexDiagnosticsProvider;
use self::build::BuildDiagnosticsProvider;
use self::latex::LatexDiagnosticsProvider;
use crate::workspace::Document;
use texlab_protocol::Diagnostic;
use texlab_workspace::Document;
#[derive(Debug, PartialEq, Eq, Clone, Default)]
pub struct DiagnosticsManager {

View file

@ -1,4 +1,4 @@
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use texlab_protocol::{FoldingRange, FoldingRangeKind, FoldingRangeParams};
use texlab_syntax::*;

View file

@ -1,4 +1,4 @@
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use texlab_protocol::{FoldingRange, FoldingRangeKind, FoldingRangeParams};
use texlab_syntax::*;

View file

@ -1,4 +1,4 @@
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use texlab_protocol::{FoldingRange, FoldingRangeKind, FoldingRangeParams};
use texlab_syntax::*;

View file

@ -5,7 +5,7 @@ mod latex_section;
use self::bibtex_declaration::BibtexDeclarationFoldingProvider;
use self::latex_environment::LatexEnvironmentFoldingProvider;
use self::latex_section::LatexSectionFoldingProvider;
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use texlab_protocol::{FoldingRange, FoldingRangeParams};

View file

@ -1,4 +1,4 @@
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use texlab_protocol::RangeExt;
use texlab_protocol::{DocumentHighlight, DocumentHighlightKind, TextDocumentPositionParams};

View file

@ -1,7 +1,7 @@
mod latex_label;
use self::latex_label::LatexLabelHighlightProvider;
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use texlab_protocol::{DocumentHighlight, TextDocumentPositionParams};

View file

@ -1,4 +1,4 @@
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use texlab_protocol::RangeExt;
use texlab_protocol::*;

View file

@ -1,4 +1,4 @@
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use texlab_protocol::RangeExt;
use texlab_protocol::*;

View file

@ -1,5 +1,5 @@
use crate::formatting::bibtex::{self, BibtexFormattingParams};
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use texlab_protocol::*;
use texlab_syntax::*;

View file

@ -1,5 +1,5 @@
use crate::citeproc::render_citation;
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use log::warn;
use texlab_protocol::RangeExt;

View file

@ -1,9 +1,7 @@
use crate::completion::DATABASE;
use crate::workspace::*;
use futures_boxed::boxed;
use texlab_protocol::RangeExt;
use texlab_protocol::{Hover, HoverContents, TextDocumentPositionParams};
use texlab_protocol::*;
use texlab_syntax::*;
use texlab_workspace::*;
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct LatexComponentHoverProvider;
@ -24,7 +22,7 @@ impl FeatureProvider for LatexComponentHoverProvider {
{
for path in include.paths() {
if path.range().contains(request.params.position) {
let documentation = DATABASE.documentation(path.text())?;
let documentation = COMPLETION_DATABASE.documentation(path.text())?;
return Some(Hover {
contents: HoverContents::Markup(documentation),
range: Some(path.range()),

View file

@ -1,4 +1,4 @@
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use texlab_protocol::RangeExt;
use texlab_protocol::*;

View file

@ -1,4 +1,4 @@
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use std::sync::Arc;
use texlab_protocol::RangeExt;

View file

@ -1,5 +1,3 @@
use crate::completion::DATABASE;
use crate::workspace::*;
use futures_boxed::boxed;
use image::png::PNGEncoder;
use image::{DynamicImage, GenericImage, GenericImageView};
@ -13,6 +11,7 @@ use texlab_distro::*;
use texlab_protocol::*;
use texlab_protocol::{ClientCapabilitiesExt, RangeExt};
use texlab_syntax::*;
use texlab_workspace::*;
use tokio::process::Command;
const PREVIEW_ENVIRONMENTS: &[&str] = &[
@ -176,7 +175,7 @@ impl LatexPreviewHoverProvider {
.paths()
.iter()
.map(|path| format!("{}.sty", path.text()))
.any(|name| !DATABASE.exists(&name))
.any(|name| !COMPLETION_DATABASE.exists(&name))
{
continue;
}

View file

@ -15,7 +15,7 @@ use self::latex_component::LatexComponentHoverProvider;
use self::latex_include::LatexIncludeHoverProvider;
use self::latex_label::LatexLabelHoverProvider;
use self::latex_preview::LatexPreviewHoverProvider;
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use texlab_protocol::{Hover, TextDocumentPositionParams};

View file

@ -17,4 +17,3 @@ pub mod reference;
pub mod rename;
pub mod server;
pub mod symbol;
pub mod workspace;

View file

@ -1,4 +1,4 @@
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use texlab_protocol::{DocumentLink, DocumentLinkParams};
use texlab_syntax::*;

View file

@ -1,7 +1,7 @@
mod latex_include;
use crate::link::latex_include::LatexIncludeLinkProvider;
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use texlab_protocol::{DocumentLink, DocumentLinkParams};

View file

@ -31,6 +31,10 @@ async fn main() -> Result<(), Box<dyn Error>> {
stderrlog::new()
.module(module_path!())
.module("jsonrpc")
.module("texlab-distro")
.module("texlab-protocol")
.module("texlab-syntax")
.module("texlab-workspace")
.verbosity(matches.occurrences_of("verbosity") as usize)
.quiet(matches.is_present("quiet"))
.timestamp(Timestamp::Off)

View file

@ -1,4 +1,4 @@
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use texlab_protocol::RangeExt;
use texlab_protocol::{Location, ReferenceParams};

View file

@ -1,4 +1,4 @@
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use texlab_protocol::RangeExt;
use texlab_protocol::{Location, Position, ReferenceParams, Url};

View file

@ -1,4 +1,4 @@
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use texlab_protocol::RangeExt;
use texlab_protocol::{Location, ReferenceParams};

View file

@ -5,7 +5,7 @@ mod latex_label;
use self::bibtex_entry::BibtexEntryReferenceProvider;
use self::bibtex_string::BibtexStringReferenceProvider;
use self::latex_label::LatexLabelReferenceProvider;
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use texlab_protocol::{Location, ReferenceParams};

View file

@ -1,4 +1,4 @@
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use std::collections::HashMap;
use texlab_protocol::RangeExt;

View file

@ -1,4 +1,4 @@
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use std::collections::HashMap;
use std::sync::Arc;

View file

@ -1,4 +1,4 @@
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use std::collections::HashMap;
use texlab_protocol::RangeExt;

View file

@ -1,4 +1,4 @@
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use std::collections::HashMap;
use texlab_protocol::RangeExt;

View file

@ -7,7 +7,7 @@ use self::bibtex_entry::*;
use self::latex_command::*;
use self::latex_environment::*;
use self::latex_label::*;
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use texlab_protocol::*;

View file

@ -1,7 +1,7 @@
use crate::action::{Action, ActionManager, LintReason};
use crate::build::*;
use crate::citeproc::render_citation;
use crate::completion::{CompletionItemData, CompletionProvider, DATABASE};
use crate::completion::{CompletionItemData, CompletionProvider};
use crate::definition::DefinitionProvider;
use crate::diagnostics::DiagnosticsManager;
use crate::folding::FoldingProvider;
@ -13,7 +13,6 @@ use crate::link::LinkProvider;
use crate::reference::ReferenceProvider;
use crate::rename::{PrepareRenameProvider, RenameProvider};
use crate::symbol::{self, SymbolProvider};
use crate::workspace::*;
use futures::lock::Mutex;
use futures_boxed::boxed;
use jsonrpc::server::{Middleware, Result};
@ -28,6 +27,7 @@ use std::sync::Arc;
use texlab_distro::{Distribution, DistributionKind, Language};
use texlab_protocol::*;
use texlab_syntax::*;
use texlab_workspace::*;
use walkdir::WalkDir;
pub struct LatexLspServer<C> {
@ -150,7 +150,7 @@ impl<C: LspClient + Send + Sync + 'static> LatexLspServer<C> {
selection_range_provider: None,
};
Lazy::force(&DATABASE);
Lazy::force(&COMPLETION_DATABASE);
Ok(InitializeResult { capabilities })
}
@ -229,7 +229,7 @@ impl<C: LspClient + Send + Sync + 'static> LatexLspServer<C> {
let data: CompletionItemData = serde_json::from_value(item.data.clone().unwrap()).unwrap();
match data {
CompletionItemData::Package | CompletionItemData::Class => {
item.documentation = DATABASE
item.documentation = COMPLETION_DATABASE
.documentation(&item.label)
.map(Documentation::MarkupContent);
}

View file

@ -1,5 +1,5 @@
use super::{LatexSymbol, LatexSymbolKind};
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use texlab_protocol::*;
use texlab_syntax::*;

View file

@ -1,5 +1,5 @@
use super::{LatexSymbol, LatexSymbolKind};
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use texlab_protocol::*;
use texlab_syntax::*;

View file

@ -1,6 +1,6 @@
use super::{label_name, selection_range};
use crate::symbol::{LatexSymbol, LatexSymbolKind};
use crate::workspace::*;
use texlab_workspace::*;
use texlab_protocol::Range;
use texlab_protocol::RangeExt;
use texlab_syntax::*;

View file

@ -1,6 +1,6 @@
use super::{label_name, selection_range};
use crate::symbol::{LatexSymbol, LatexSymbolKind};
use crate::workspace::*;
use texlab_workspace::*;
use texlab_protocol::Range;
use texlab_syntax::*;

View file

@ -1,6 +1,6 @@
use super::{label_name, selection_range};
use crate::symbol::{LatexSymbol, LatexSymbolKind};
use crate::workspace::*;
use texlab_workspace::*;
use texlab_syntax::*;
pub fn symbols(view: &DocumentView, tree: &LatexSyntaxTree) -> Vec<LatexSymbol> {

View file

@ -4,7 +4,7 @@ mod float;
mod theorem;
use super::{LatexSymbol, LatexSymbolKind};
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use texlab_protocol::RangeExt;
use texlab_protocol::*;

View file

@ -1,6 +1,6 @@
use super::{label_name, selection_range};
use crate::symbol::{LatexSymbol, LatexSymbolKind};
use crate::workspace::*;
use texlab_workspace::*;
use texlab_syntax::*;
pub fn symbols(view: &DocumentView, tree: &LatexSyntaxTree) -> Vec<LatexSymbol> {

View file

@ -8,7 +8,7 @@ use self::bibtex_string::BibtexStringSymbolProvider;
use self::latex_section::LatexSectionSymbolProvider;
use self::project_order::ProjectOrdering;
use crate::lsp_kind::Structure;
use crate::workspace::*;
use texlab_workspace::*;
use futures_boxed::boxed;
use std::cmp::Reverse;
use std::sync::Arc;

View file

@ -1,4 +1,4 @@
use crate::workspace::*;
use texlab_workspace::*;
use petgraph::algo::tarjan_scc;
use petgraph::{Directed, Graph};
use std::collections::HashSet;