mirror of
https://github.com/latex-lsp/texlab.git
synced 2025-12-23 09:19:21 +00:00
Always enable completion feature
This commit is contained in:
parent
d83adbc133
commit
c9bd0e02be
4 changed files with 24 additions and 36 deletions
|
|
@ -33,10 +33,6 @@ test = false
|
|||
[lib]
|
||||
doctest = false
|
||||
|
||||
[features]
|
||||
default = ["completion"]
|
||||
completion = ["fuzzy-matcher"]
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.58"
|
||||
byteorder = "1.4.3"
|
||||
|
|
@ -52,7 +48,7 @@ encoding_rs = "0.8.31"
|
|||
encoding_rs_io = "0.1.7"
|
||||
fern = "0.6"
|
||||
flate2 = "1.0.24"
|
||||
fuzzy-matcher = { version = "0.3.7", optional = true }
|
||||
fuzzy-matcher = { version = "0.3.7" }
|
||||
human_name = { version = "1.0.3", default-features = false }
|
||||
isocountry = "0.3.2"
|
||||
itertools = "0.10.1"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
mod build;
|
||||
#[cfg(feature = "completion")]
|
||||
mod completion;
|
||||
mod cursor;
|
||||
mod definition;
|
||||
|
|
@ -21,10 +20,9 @@ use lsp_types::Url;
|
|||
|
||||
use crate::{Document, Workspace};
|
||||
|
||||
#[cfg(feature = "completion")]
|
||||
pub use self::completion::{complete, CompletionItemData, COMPLETION_LIMIT};
|
||||
pub use self::{
|
||||
build::{BuildEngine, BuildParams, BuildResult, BuildStatus},
|
||||
completion::{complete, CompletionItemData, COMPLETION_LIMIT},
|
||||
definition::goto_definition,
|
||||
execute_command::execute_command,
|
||||
folding::find_foldings,
|
||||
|
|
|
|||
|
|
@ -9,11 +9,14 @@ use crossbeam_channel::{Receiver, Sender};
|
|||
use log::{error, info, warn};
|
||||
use lsp_server::{Connection, Message, RequestId};
|
||||
use lsp_types::{notification::*, request::*, *};
|
||||
use rowan::ast::AstNode;
|
||||
use serde::Serialize;
|
||||
use threadpool::ThreadPool;
|
||||
|
||||
use crate::{
|
||||
citation,
|
||||
client::{send_notification, send_request, ReqQueue},
|
||||
component_db::COMPONENT_DATABASE,
|
||||
debouncer,
|
||||
diagnostics::DiagnosticManager,
|
||||
dispatch::{NotificationDispatcher, RequestDispatcher},
|
||||
|
|
@ -22,9 +25,10 @@ use crate::{
|
|||
execute_command, find_all_references, find_document_highlights, find_document_links,
|
||||
find_document_symbols, find_foldings, find_hover, find_workspace_symbols,
|
||||
format_source_code, goto_definition, prepare_rename_all, rename_all, BuildEngine,
|
||||
BuildParams, BuildResult, BuildStatus, FeatureRequest, ForwardSearchResult,
|
||||
ForwardSearchStatus,
|
||||
BuildParams, BuildResult, BuildStatus, CompletionItemData, FeatureRequest,
|
||||
ForwardSearchResult, ForwardSearchStatus,
|
||||
},
|
||||
syntax::bibtex,
|
||||
ClientCapabilitiesExt, Document, DocumentData, DocumentLanguage, Environment, LineIndex,
|
||||
LineIndexExt, Options, Workspace, WorkspaceEvent,
|
||||
};
|
||||
|
|
@ -100,7 +104,6 @@ impl Server {
|
|||
definition_provider: Some(OneOf::Left(true)),
|
||||
references_provider: Some(OneOf::Left(true)),
|
||||
hover_provider: Some(HoverProviderCapability::Simple(true)),
|
||||
#[cfg(feature = "completion")]
|
||||
completion_provider: Some(CompletionOptions {
|
||||
resolve_provider: Some(true),
|
||||
trigger_characters: Some(vec![
|
||||
|
|
@ -543,7 +546,6 @@ impl Server {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(feature = "completion")]
|
||||
fn completion(&self, id: RequestId, params: CompletionParams) -> Result<()> {
|
||||
let uri = Arc::new(params.text_document_position.text_document.uri.clone());
|
||||
|
||||
|
|
@ -555,15 +557,7 @@ impl Server {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(feature = "completion")]
|
||||
fn completion_resolve(&self, id: RequestId, mut item: CompletionItem) -> Result<()> {
|
||||
use rowan::ast::AstNode;
|
||||
|
||||
use crate::{
|
||||
citation, component_db::COMPONENT_DATABASE, features::CompletionItemData,
|
||||
syntax::bibtex,
|
||||
};
|
||||
|
||||
self.spawn(move |server| {
|
||||
match serde_json::from_value(item.data.clone().unwrap()).unwrap() {
|
||||
CompletionItemData::Package | CompletionItemData::Class => {
|
||||
|
|
@ -572,19 +566,22 @@ impl Server {
|
|||
.map(Documentation::MarkupContent);
|
||||
}
|
||||
CompletionItemData::Citation { uri, key } => {
|
||||
if let Some(document) = server.workspace.documents_by_uri.get(&uri) {
|
||||
if let Some(data) = document.data.as_bibtex() {
|
||||
let root = bibtex::SyntaxNode::new_root(data.green.clone());
|
||||
item.documentation = bibtex::Root::cast(root)
|
||||
.and_then(|root| root.find_entry(&key))
|
||||
.and_then(|entry| citation::render(&entry))
|
||||
.map(|value| {
|
||||
Documentation::MarkupContent(MarkupContent {
|
||||
kind: MarkupKind::Markdown,
|
||||
value,
|
||||
})
|
||||
});
|
||||
}
|
||||
if let Some(data) = server
|
||||
.workspace
|
||||
.documents_by_uri
|
||||
.get(&uri)
|
||||
.and_then(|document| document.data.as_bibtex())
|
||||
{
|
||||
let root = bibtex::SyntaxNode::new_root(data.green.clone());
|
||||
item.documentation = bibtex::Root::cast(root)
|
||||
.and_then(|root| root.find_entry(&key))
|
||||
.and_then(|entry| citation::render(&entry))
|
||||
.map(|value| {
|
||||
Documentation::MarkupContent(MarkupContent {
|
||||
kind: MarkupKind::Markdown,
|
||||
value,
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
|
|
@ -762,12 +759,10 @@ impl Server {
|
|||
})?
|
||||
.on::<WorkspaceSymbol, _>(|id, params| self.workspace_symbols(id, params))?
|
||||
.on::<Completion, _>(|id, params| {
|
||||
#[cfg(feature = "completion")]
|
||||
self.completion(id, params)?;
|
||||
Ok(())
|
||||
})?
|
||||
.on::<ResolveCompletionItem, _>(|id, params| {
|
||||
#[cfg(feature = "completion")]
|
||||
self.completion_resolve(id, params)?;
|
||||
Ok(())
|
||||
})?
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
#[cfg(feature = "completion")]
|
||||
mod completion;
|
||||
mod definition;
|
||||
mod did_change_configuration;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue