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,9 +1,32 @@
use crate::{prelude::*, StatefulRequest};
/// The [`textDocument/completion`] request is sent from the client to the
/// server to compute completion items at a given cursor position.
///
/// If computing full completion items is expensive, servers can additionally
/// provide a handler for the completion item resolve request
/// (`completionItem/resolve`). This request is sent when a completion item is
/// selected in the user interface.
///
/// [`textDocument/completion`]: https://microsoft.github.io/language-server-protocol/specification#textDocument_completion
///
/// # Compatibility
///
/// Since 3.16.0, the client can signal that it can resolve more properties
/// lazily. This is done using the `completion_item.resolve_support` client
/// capability which lists all properties that can be filled in during a
/// `completionItem/resolve` request.
///
/// All other properties (usually `sort_text`, `filter_text`, `insert_text`, and
/// `text_edit`) must be provided in the `textDocument/completion` response and
/// must not be changed during resolve.
#[derive(Debug, Clone)]
pub struct CompletionRequest {
/// The path of the document to compute completions.
pub path: PathBuf,
/// The position in the document at which to compute completions.
pub position: LspPosition,
/// Whether the completion is triggered explicitly.
pub explicit: bool,
}
@ -35,7 +58,7 @@ impl StatefulRequest for CompletionRequest {
let explicit = false;
let (offset, completions) =
typst_ide::autocomplete(ctx.world, doc, &source, cursor, explicit)?;
typst_ide::autocomplete(ctx.world(), doc, &source, cursor, explicit)?;
let lsp_start_position = ctx.to_lsp_pos(offset, &source);
let replace_range = LspRange::new(lsp_start_position, self.position);