Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Update to Typst v0.10.0 #378

Merged
merged 1 commit into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
957 changes: 436 additions & 521 deletions Cargo.lock

Large diffs are not rendered by default.

12 changes: 8 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ native-tls = ["reqwest?/native-tls"]
fontconfig = ["fontdb/fontconfig"]

[dependencies]
typst = { git = "https://github.com/typst/typst.git", tag = "v0.9.0" }
typst-library = { git = "https://github.com/typst/typst.git", tag = "v0.9.0" }
typst-ide = { git = "https://github.com/typst/typst.git", tag = "v0.9.0" }
typst = { git = "https://github.com/typst/typst.git", tag = "v0.10.0" }
typst-ide = { git = "https://github.com/typst/typst.git", tag = "v0.10.0" }
typst-pdf = { git = "https://github.com/typst/typst.git", tag = "v0.10.0" }

anyhow = "1.0.71"
async-compression = { version = "0.4.1", features = ["tokio", "gzip"] }
Expand All @@ -42,7 +42,11 @@ chrono = { version = "0.4.24", default-features = false, features = [
comemo = "0.3"
dirs = "5.0"
elsa = "1.9.0"
fontdb = { version = "0.16.0", default-features = false, features = ["std", "fs", "memmap"] }
fontdb = { version = "0.16.0", default-features = false, features = [
"std",
"fs",
"memmap",
] }
futures = "0.3"
if_chain = "1.0"
indexmap = "2.1.0"
Expand Down
9 changes: 4 additions & 5 deletions src/lsp_typst_boundary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub type TypstRange = std::ops::Range<usize>;
pub type TypstTooltip = typst_ide::Tooltip;
pub type LspHoverContents = lsp_types::HoverContents;

pub type TypstDatetime = typst::eval::Datetime;
pub type TypstDatetime = typst::foundations::Datetime;

pub type LspDiagnostic = lsp_types::Diagnostic;
pub type TypstDiagnostic = typst::diag::SourceDiagnostic;
Expand All @@ -30,7 +30,7 @@ pub type LspSeverity = lsp_types::DiagnosticSeverity;
pub type TypstSeverity = typst::diag::Severity;

pub type LspParamInfo = lsp_types::ParameterInformation;
pub type TypstParamInfo = typst::eval::ParamInfo;
pub type TypstParamInfo = typst::foundations::ParamInfo;

/// An LSP range with its associated encoding.
pub struct LspRange {
Expand Down Expand Up @@ -130,10 +130,9 @@ pub mod typst_to_lsp {
LanguageString, Location, MarkedString, MarkupContent, MarkupKind, TextEdit,
};
use tracing::error;
use typst::diag::Tracepoint;
use typst::eval::{CastInfo, Repr};
use typst::diag::{EcoString, Tracepoint};
use typst::foundations::{CastInfo, Repr};
use typst::syntax::{FileId, Source, Spanned};
use typst_library::prelude::EcoString;

use crate::config::ConstConfig;
use crate::server::diagnostics::DiagnosticsMap;
Expand Down
4 changes: 2 additions & 2 deletions src/server/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::sync::Arc;
use anyhow::Context;
use tower_lsp::lsp_types::Url;
use tracing::info;
use typst::doc::Document;
use typst::model::Document;

use crate::ext::UrlExt;

Expand All @@ -22,7 +22,7 @@ impl TypstServer {
self.thread_with_world(source_uri)
.await?
.run(move |world| {
let data = typst::export::pdf(&document, Some(pdf_uri.as_str()), world.now());
let data = typst_pdf::pdf(&document, Some(pdf_uri.as_str()), world.now());

world
.write_raw(&pdf_uri, &data)
Expand Down
4 changes: 3 additions & 1 deletion src/server/hover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ impl TypstServer {
) -> anyhow::Result<Option<Hover>> {
let position_encoding = self.const_config().position_encoding;

let doc = self.document.lock().await.clone();

let result = self
.thread_with_world(uri)
.await?
Expand All @@ -24,7 +26,7 @@ impl TypstServer {
let typst_offset =
lsp_to_typst::position_to_offset(position, position_encoding, &source);

let typst_tooltip = typst_ide::tooltip(&world, &[], &source, typst_offset)?;
let typst_tooltip = typst_ide::tooltip(&world, Some(&doc), &source, typst_offset)?;

Some((typst_offset, typst_tooltip))
})
Expand Down
2 changes: 1 addition & 1 deletion src/server/lsp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ impl LanguageServer for TypstServer {
let typst_offset =
lsp_to_typst::position_to_offset(position, position_encoding, &source);
let (typst_start_offset, completions) =
typst_ide::autocomplete(&world, &doc.pages, &source, typst_offset, explicit)?;
typst_ide::autocomplete(&world, Some(&doc), &source, typst_offset, explicit)?;
let lsp_start_position =
offset_to_position(typst_start_offset, position_encoding, &source);

Expand Down
6 changes: 3 additions & 3 deletions src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use tokio::sync::{Mutex, OwnedRwLockReadGuard, RwLock, RwLockReadGuard};
use tower_lsp::lsp_types::Url;
use tower_lsp::Client;
use tracing_subscriber::{reload, Registry};
use typst::doc::Document;
use typst::model::Document;
use typst::syntax::Source;

use crate::config::{Config, ConstConfig};
Expand Down Expand Up @@ -78,8 +78,8 @@ impl TypstServer {
.expect("workspace should be initialized")
}

pub fn typst_global_scopes(&self) -> typst::eval::Scopes {
typst::eval::Scopes::new(Some(&TYPST_STDLIB))
pub fn typst_global_scopes(&self) -> typst::foundations::Scopes {
typst::foundations::Scopes::new(Some(&TYPST_STDLIB))
}

#[tracing::instrument(skip(self))]
Expand Down
2 changes: 1 addition & 1 deletion src/server/semantic_tokens/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use tower_lsp::lsp_types::{
Registration, SemanticToken, SemanticTokensEdit, SemanticTokensFullOptions,
SemanticTokensLegend, SemanticTokensOptions, Unregistration,
};
use typst::diag::EcoString;
use typst::syntax::{ast, LinkedNode, Source, SyntaxKind};
use typst_library::prelude::EcoString;

use self::delta::token_delta;
use self::modifier_set::ModifierSet;
Expand Down
2 changes: 1 addition & 1 deletion src/server/semantic_tokens/token_encode.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use tower_lsp::lsp_types::{Position, SemanticToken};
use typst::diag::EcoString;
use typst::syntax::Source;
use typst_library::prelude::EcoString;

use crate::config::PositionEncoding;
use crate::ext::{PositionExt, StrExt};
Expand Down
2 changes: 1 addition & 1 deletion src/server/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use tower_lsp::lsp_types::{
SignatureInformation, Url,
};
use tracing::trace;
use typst::eval::{Func, ParamInfo, Scopes, Value};
use typst::foundations::{Func, ParamInfo, Scopes, Value};
use typst::syntax::{ast, LinkedNode, Source, SyntaxKind};

use crate::lsp_typst_boundary::{lsp_to_typst, typst_to_lsp, LspPosition, TypstOffset};
Expand Down
6 changes: 4 additions & 2 deletions src/server/typst_compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ use std::sync::Arc;

use comemo::Track;
use tower_lsp::lsp_types::Url;
use typst::doc::Document;
use typst::eval::{Module, Route, Tracer};
use typst::engine::Route;
use typst::eval::Tracer;
use typst::foundations::Module;
use typst::model::Document;
use typst::World;

use crate::lsp_typst_boundary::typst_to_lsp;
Expand Down
4 changes: 2 additions & 2 deletions src/workspace/font_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use comemo::Prehashed;
use fontdb::{Database, Source};
use once_cell::sync::OnceCell;
use tracing::error;
use typst::eval::Bytes;
use typst::font::{Font, FontBook, FontInfo};
use typst::foundations::Bytes;
use typst::text::{Font, FontBook, FontInfo};

use super::fs::local::LocalFs;
use super::fs::FsError;
Expand Down
2 changes: 1 addition & 1 deletion src/workspace/fs/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use elsa::sync::FrozenMap;
use once_cell::sync::OnceCell;
use tower_lsp::lsp_types::Url;
use tracing::trace;
use typst::eval::Bytes;
use typst::foundations::Bytes;
use typst::syntax::Source;

use crate::ext::PathExt;
Expand Down
2 changes: 1 addition & 1 deletion src/workspace/fs/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::fs;
use std::path::{Path, PathBuf};

use tower_lsp::lsp_types::Url;
use typst::eval::Bytes;
use typst::foundations::Bytes;
use typst::syntax::Source;
use walkdir::WalkDir;

Expand Down
2 changes: 1 addition & 1 deletion src/workspace/fs/lsp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::collections::{HashMap, HashSet};

use anyhow::anyhow;
use tower_lsp::lsp_types::{TextDocumentContentChangeEvent, Url};
use typst::eval::Bytes;
use typst::foundations::Bytes;
use typst::syntax::Source;

use crate::config::PositionEncoding;
Expand Down
2 changes: 1 addition & 1 deletion src/workspace/fs/manager.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::HashSet;

use tower_lsp::lsp_types::{TextDocumentContentChangeEvent, Url};
use typst::eval::Bytes;
use typst::foundations::Bytes;
use typst::syntax::Source;

use crate::config::PositionEncoding;
Expand Down
2 changes: 1 addition & 1 deletion src/workspace/fs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::path::{Path, PathBuf};
use tower_lsp::lsp_types::Url;
use tracing::error;
use typst::diag::FileError;
use typst::eval::Bytes;
use typst::foundations::Bytes;
use typst::syntax::{FileId, Source};

use crate::ext::UriError;
Expand Down
5 changes: 3 additions & 2 deletions src/workspace/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ use tower_lsp::lsp_types::{
InitializeParams, TextDocumentContentChangeEvent, Url, WorkspaceFoldersChangeEvent,
};
use tracing::trace;
use typst::eval::{Bytes, Library};
use typst::foundations::Bytes;
use typst::syntax::Source;
use typst::Library;

use crate::config::PositionEncoding;
use crate::ext::InitializeParamsExt;
Expand All @@ -60,7 +61,7 @@ pub mod project;
pub mod world;

lazy_static! {
pub static ref TYPST_STDLIB: Prehashed<Library> = Prehashed::new(typst_library::build());
pub static ref TYPST_STDLIB: Prehashed<Library> = Prehashed::new(Library::default());
}

#[derive(Debug)]
Expand Down
5 changes: 3 additions & 2 deletions src/workspace/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ use std::sync::Arc;
use comemo::Prehashed;
use tokio::sync::OwnedRwLockReadGuard;
use tower_lsp::lsp_types::Url;
use typst::eval::{Bytes, Library};
use typst::font::{Font, FontBook};
use typst::foundations::Bytes;
use typst::syntax::{FileId, Source};
use typst::text::{Font, FontBook};
use typst::Library;

use crate::ext::FileIdExt;

Expand Down
6 changes: 3 additions & 3 deletions src/workspace/world/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ use futures::Future;
use tokio::runtime;
use tower_lsp::lsp_types::Url;
use typst::diag::{EcoString, FileResult};
use typst::eval::{Bytes, Datetime, Library};
use typst::font::{Font, FontBook};
use typst::foundations::{Bytes, Datetime};
use typst::syntax::{FileId, PackageSpec, Source};
use typst::World;
use typst::text::{Font, FontBook};
use typst::{Library, World};

use crate::workspace::fs::{FsError, FsResult};
use crate::workspace::project::Project;
Expand Down