feat: adapt to rust analyzer's server crate

This commit is contained in:
Myriad-Dreamin 2024-03-10 17:54:55 +08:00
parent 619a4f9f14
commit 9c9fcd91ba
19 changed files with 1078 additions and 600 deletions

View file

@ -34,7 +34,7 @@ typst-ts-core = { version = "0.4.2-rc6", default-features = false, features = [
] }
typst-ts-compiler.workspace = true
tower-lsp.workspace = true
lsp-types.workspace = true
[dev-dependencies]
once_cell.workspace = true

View file

@ -2,7 +2,7 @@ use std::ops::Range;
use anyhow::anyhow;
use log::info;
use tower_lsp::lsp_types::SymbolKind;
use lsp_types::SymbolKind;
use typst::syntax::{ast, LinkedNode, Source, SyntaxKind};
use typst_ts_core::typst::prelude::{eco_vec, EcoVec};

View file

@ -1,6 +1,6 @@
use comemo::Track;
use log::debug;
use tower_lsp::lsp_types::LocationLink;
use lsp_types::LocationLink;
use crate::{analysis::find_definition, prelude::*};

View file

@ -1,7 +1,7 @@
use std::{borrow::Cow, ops::Range};
use log::debug;
use tower_lsp::lsp_types::{InlayHintKind, InlayHintLabel};
use lsp_types::{InlayHintKind, InlayHintLabel};
use typst::{
foundations::{Args, Closure},
syntax::SyntaxNode,

View file

@ -1,6 +1,6 @@
//! Conversions between Typst and LSP types and representations
use tower_lsp::lsp_types;
use lsp_types;
pub type LspPosition = lsp_types::Position;
/// The interpretation of an `LspCharacterOffset` depends on the
@ -130,11 +130,11 @@ pub mod typst_to_lsp {
use itertools::Itertools;
use lazy_static::lazy_static;
use regex::{Captures, Regex};
use tower_lsp::lsp_types::{
use lsp_types::{
CompletionTextEdit, Documentation, InsertTextFormat, LanguageString, MarkedString,
MarkupContent, MarkupKind, TextEdit,
};
use regex::{Captures, Regex};
use typst::diag::EcoString;
use typst::foundations::{CastInfo, Repr};
use typst::syntax::Source;

View file

@ -8,7 +8,7 @@ pub use std::{
pub use comemo::{Track, Tracked};
pub use itertools::{Format, Itertools};
pub use log::{error, trace};
pub use tower_lsp::lsp_types::{
pub use lsp_types::{
CompletionResponse, DiagnosticRelatedInformation, DocumentSymbol, DocumentSymbolResponse,
Documentation, FoldingRange, GotoDefinitionResponse, Hover, InlayHint, Location as LspLocation,
MarkupContent, MarkupKind, Position as LspPosition, PrepareRenameResponse, SelectionRange,

View file

@ -1,7 +1,7 @@
use std::{collections::HashSet, os::windows::fs::FileTypeExt};
use log::{debug, warn};
use tower_lsp::lsp_types::TextEdit;
use lsp_types::TextEdit;
use crate::{
analysis::{find_definition, find_imports, find_lexical_references_after, Definition},

View file

@ -1,4 +1,4 @@
use tower_lsp::lsp_types::{SemanticToken, SemanticTokensEdit};
use lsp_types::{SemanticToken, SemanticTokensEdit};
#[derive(Debug)]
struct CachedTokens {

View file

@ -1,10 +1,10 @@
use itertools::Itertools;
use parking_lot::RwLock;
use strum::IntoEnumIterator;
use tower_lsp::lsp_types::{
use lsp_types::{
Registration, SemanticToken, SemanticTokensEdit, SemanticTokensFullOptions,
SemanticTokensLegend, SemanticTokensOptions, Unregistration,
};
use parking_lot::RwLock;
use strum::IntoEnumIterator;
use typst::diag::EcoString;
use typst::syntax::{ast, LinkedNode, Source, SyntaxKind};

View file

@ -1,4 +1,4 @@
use tower_lsp::lsp_types::{Position, SemanticToken};
use lsp_types::{Position, SemanticToken};
use typst::diag::EcoString;
use typst::syntax::Source;

View file

@ -1,7 +1,7 @@
//! Types for tokens used for Typst syntax
use lsp_types::{SemanticTokenModifier, SemanticTokenType};
use strum::EnumIter;
use tower_lsp::lsp_types::{SemanticTokenModifier, SemanticTokenType};
const BOOL: SemanticTokenType = SemanticTokenType::new("bool");
const PUNCTUATION: SemanticTokenType = SemanticTokenType::new("punct");