feat: allow running server with loading font once and on rootless files (#94)

* dev: change system config

* docs: update config doc

* dev: clean up tightly coupled world

* dev: load font once

* docs: add more comments to tinymist-query

* dev: merge compiler layers

* feat: allow run lsp on rootless files

* build: bump ts

* fix: workspace dep

* build: bump preview

* dev: correctly check inactive state

* fix: weird cargo default features
This commit is contained in:
Myriad-Dreamin 2024-03-26 10:33:56 +08:00 committed by GitHub
parent f0a9c3e880
commit 76b4e91046
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
46 changed files with 974 additions and 638 deletions

View file

@ -1,3 +1,12 @@
//! # tinymist-query
//!
//! **Note: this crate is under development. it currently doesn't ensure stable
//! APIs, and heavily depending on some unstable crates.**
//!
//! This crate provides a set of APIs to query the information about the source
//! code. Currently it provides:
//! + language queries defined by the [Language Server Protocol](https://microsoft.github.io/language-server-protocol/).
mod adt;
pub mod analysis;
pub mod syntax;
@ -8,7 +17,7 @@ pub(crate) mod diagnostics;
use std::sync::Arc;
pub use analysis::AnalysisContext;
use typst::model::Document as TypstDocument;
use typst::{model::Document as TypstDocument, syntax::Source};
pub use diagnostics::*;
pub(crate) mod code_lens;
@ -48,31 +57,57 @@ pub use references::*;
pub mod lsp_typst_boundary;
pub use lsp_typst_boundary::*;
pub(crate) mod lsp_features;
pub use lsp_features::*;
mod prelude;
/// A compiled document with an self-incremented logical version.
#[derive(Debug, Clone)]
pub struct VersionedDocument {
/// The version of the document.
pub version: usize,
/// The compiled document.
pub document: Arc<TypstDocument>,
}
/// A request handler with given syntax information.
pub trait SyntaxRequest {
/// The response type of the request.
type Response;
fn request(self, ctx: &mut AnalysisContext) -> Option<Self::Response>;
}
pub trait StatefulRequest {
type Response;
/// Request the information from the given source.
fn request(
self,
ctx: &mut AnalysisContext,
v: Option<VersionedDocument>,
source: &Source,
positing_encoding: PositionEncoding,
) -> Option<Self::Response>;
}
/// A request handler with given (semantic) analysis context.
pub trait SemanticRequest {
/// The response type of the request.
type Response;
/// Request the information from the given context.
fn request(self, ctx: &mut AnalysisContext) -> Option<Self::Response>;
}
/// A request handler with given (semantic) analysis context and a versioned
/// document.
pub trait StatefulRequest {
/// The response type of the request.
type Response;
/// Request the information from the given context.
fn request(
self,
ctx: &mut AnalysisContext,
doc: Option<VersionedDocument>,
) -> Option<Self::Response>;
}
#[allow(missing_docs)]
mod polymorphic {
use super::prelude::*;
use super::*;