mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-07-23 04:35:00 +00:00
feat: forward const config
This commit is contained in:
parent
d49085338f
commit
0c7e67ed9a
12 changed files with 125 additions and 211 deletions
|
@ -4,7 +4,6 @@ use crate::prelude::*;
|
|||
pub struct CompletionRequest {
|
||||
pub path: PathBuf,
|
||||
pub position: LspPosition,
|
||||
pub position_encoding: PositionEncoding,
|
||||
pub explicit: bool,
|
||||
}
|
||||
|
||||
|
@ -12,16 +11,16 @@ pub fn completion(
|
|||
world: &TypstSystemWorld,
|
||||
doc: Option<Arc<TypstDocument>>,
|
||||
req: CompletionRequest,
|
||||
position_encoding: PositionEncoding,
|
||||
) -> Option<CompletionResponse> {
|
||||
let source = get_suitable_source_in_workspace(world, &req.path).ok()?;
|
||||
let typst_offset =
|
||||
lsp_to_typst::position_to_offset(req.position, req.position_encoding, &source);
|
||||
let typst_offset = lsp_to_typst::position_to_offset(req.position, position_encoding, &source);
|
||||
|
||||
let (typst_start_offset, completions) =
|
||||
typst_ide::autocomplete(world, doc.as_deref(), &source, typst_offset, req.explicit)?;
|
||||
|
||||
let lsp_start_position =
|
||||
typst_to_lsp::offset_to_position(typst_start_offset, req.position_encoding, &source);
|
||||
typst_to_lsp::offset_to_position(typst_start_offset, position_encoding, &source);
|
||||
let replace_range = LspRawRange::new(lsp_start_position, req.position);
|
||||
Some(typst_to_lsp::completions(&completions, replace_range).into())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue