Myriad-Dreamin / tinymist

Tinymist [ˈtaɪni mɪst] is an integrated language service for Typst [taɪpst].
https://myriad-dreamin.github.io/tinymist
Apache License 2.0
735 stars 30 forks source link

Rename labels #549

Open quachpas opened 2 months ago

quachpas commented 2 months ago

Motivation

Being able to rename labels would make it easier to work on long documents without resorting to search and replace to change figures/equations labels.

Description

Implement LSP rename capability for labels.


Hello! Not sure if this is intentional or a bug, on my side at least, the rename command does not work for labels.

Myriad-Dreamin commented 2 months ago

This is already implemented on main branch. Please either wait for a new release or follow Installing Regular/Nightly Prebuilds from GitHub.

quachpas commented 2 months ago

Hello! I just tested on the main branch as well as the new extension from b67cec2. On my side I cannot rename a label either in Code or Helix rename a label.

#figure([Test]) <fig:test>
@fig:test
❯ tinymist --version
tinymist 
Build Timestamp:     2024-08-20T10:23:47.000000000Z
Build Git Describe:  v0.11.19-13-gb67cec2
Commit SHA:          b67cec2918db289bff1bf2c2dfe7d3e3206e819c
Commit Date:         None
Commit Branch:       None
Cargo Target Triple: x86_64-unknown-linux-gnu
Typst Version:       0.11.1
❯ hx --version
helix 24.7 (b90ec5c7)
Version: 1.93.0-insider
Commit: 922413f6d97e16c05b565398f33d95c306b1ceb7
Date: 2024-08-13T05:04:09.073Z
Electron: 30.3.1
ElectronBuildId: 9960165
Chromium: 124.0.6367.243
Node.js: 20.15.1
V8: 12.4.254.20-electron.0
OS: Linux x64 6.10.5-zen1-1-zen

Helix logs

2024-08-20T12:40:44.486 helix_lsp::transport [ERROR] tinymist err <- "[2024-08-20T10:40:44Z INFO  sync_lsp] handling textDocument/prepareRename - (3) at Instant { tv_sec: 139358, tv_nsec: 262798420 }\n"
2024-08-20T12:40:44.486 helix_lsp::transport [ERROR] tinymist err <- "[2024-08-20T10:40:44Z INFO  tinymist_query::prepare_rename] prepare_rename: not a function on function definition site: Some(FigureElem { body: Text(Test1), placement: Some(None), caption: Some(None), kind: Some(Custom(Elem(Element(image)))), supplement: Some(Custom(Some(Content(Text(Figure))))), numbering: Some(Some(Pattern(NumberingPattern { pieces: [(\"\", Arabic, Lower)], suffix: \"\", trimmed: false }))), gap: Some(0.65em), outlined: Some(true), counter: Some(Some(Counter(Selector(Elem(Element(figure), Some([(3, Func(image))])))))) })\n"
2024-08-20T12:40:44.486 helix_lsp::transport [ERROR] tinymist err <- "[2024-08-20T10:40:44Z INFO  sync_lsp] handled  textDocument/prepareRename - (3) in 286.39µs\n"
2024-08-20T12:40:45.853 helix_lsp::transport [ERROR] tinymist err <- "[2024-08-20T10:40:45Z INFO  sync_lsp] handling textDocument/prepareRename - (4) at Instant { tv_sec: 139359, tv_nsec: 629580277 }\n"
2024-08-20T12:40:45.853 helix_lsp::transport [ERROR] tinymist err <- "[2024-08-20T10:40:45Z INFO  tinymist_query::prepare_rename] prepare_rename: not a function on function definition site: Some(FigureElem { body: Text(Test1), placement: Some(None), caption: Some(None), kind: Some(Custom(Elem(Element(image)))), supplement: Some(Custom(Some(Content(Text(Figure))))), numbering: Some(Some(Pattern(NumberingPattern { pieces: [(\"\", Arabic, Lower)], suffix: \"\", trimmed: false }))), gap: Some(0.65em), outlined: Some(true), counter: Some(Some(Counter(Selector(Elem(Element(figure), Some([(3, Func(image))])))))) })\n"
2024-08-20T12:40:45.853 helix_lsp::transport [ERROR] tinymist err <- "[2024-08-20T10:40:45Z INFO  sync_lsp] handled  textDocument/prepareRename - (4) in 279.60µs\n"
2024-08-20T12:40:46.486 helix_lsp::transport [ERROR] tinymist err <- "[2024-08-20T10:40:46Z INFO  sync_lsp] handling textDocument/prepareRename - (5) at Instant { tv_sec: 139360, tv_nsec: 262299484 }\n"
2024-08-20T12:40:46.486 helix_lsp::transport [ERROR] tinymist err <- "[2024-08-20T10:40:46Z INFO  tinymist_query::prepare_rename] prepare_rename: not a function on function definition site: Some(FigureElem { body: Text(Test1), placement: Some(None), caption: Some(None), kind: Some(Custom(Elem(Element(image)))), supplement: Some(Custom(Some(Content(Text(Figure))))), numbering: Some(Some(Pattern(NumberingPattern { pieces: [(\"\", Arabic, Lower)], suffix: \"\", trimmed: false }))), gap: Some(0.65em), outlined: Some(true), counter: Some(Some(Counter(Selector(Elem(Element(figure), Some([(3, Func(image))])))))) })\n"
2024-08-20T12:40:46.486 helix_lsp::transport [ERROR] tinymist err <- "[2024-08-20T10:40:46Z INFO  sync_lsp] handled  textDocument/prepareRename - (5) in 176.06µs\n"

Code logs

[2024-08-20T10:42:55Z INFO  tinymist_query::prepare_rename] prepare_rename: not a function on function definition site: Some(FigureElem { body: Sequence [SpaceElem, Text(Let), SpaceElem, EquationElem { block: Some(false), numbering: None, number_align: None, supplement: None, body: LrElem { size: None, body: Sequence [Text((), Text(X), Text(,), SpaceElem, AttachElem { base: #Set(equation.variant: Cal)
    Text(B), t: None, b: Some(Some(Text(X))), tl: None, bl: None, tr: None, br: None }, Text(,), SpaceElem, AttachElem { base: Text(μ), t: None, b: Some(Some(Text(X))), tl: None, bl: None, tr: None, br: None }, Text())] } }, SpaceElem, Text(and), SpaceElem, EquationElem { block: Some(false), numbering: None, number_align: None, supplement: None, body: LrElem { size: None, body: Sequence [Text((), Text(Y), Text(,), SpaceElem, AttachElem { base: #Set(equation.variant: Cal)
    Text(B), t: None, b: Some(Some(Text(Y))), tl: None, bl: None, tr: None, br: None }, Text(,), SpaceElem, AttachElem { base: Text(μ), t: None, b: Some(Some(Text(Y))), tl: None, bl: None, tr: None, br: None }, Text())] } }, SpaceElem, Text(be two), SpaceElem, EquationElem { block: Some(false), numbering: None, number_align: None, supplement: None, body: Text(σ) }, Text(-finite measure spaces, and let), SpaceElem, EquationElem { block: Some(false), numbering: None, number_align: None, supplement: None, body: Sequence [Text(f), Text(:), SpaceElem, Text(X), SpaceElem, Text(×), SpaceElem, Text(Y), SpaceElem, Text(→), SpaceElem, LrElem { size: None, body: Sequence [Text([), Text(0), Text(,), SpaceElem, Text(+), Text(∞), Text(])] }] }, SpaceElem, Text(be measurable with respect to), SpaceElem, EquationElem { block: Some(false), numbering: None, number_align: None, supplement: None, body: Sequence [AttachElem { base: #Set(equation.variant: Cal)
    Text(B), t: None, b: Some(Some(Text(X))), tl: None, bl: None, tr: None, br: None }, SpaceElem, Text(×), SpaceElem, AttachElem { base: #Set(equation.variant: Cal)
    Text(B), t: None, b: Some(Some(Text(Y))), tl: None, bl: None, tr: None, br: None }] }, Text(. Then), Text(:), SpaceElem, ListItem { body: Sequence [Text(The functions), SpaceElem, EquationElem { block: Some(false), numbering: None, number_align: None, supplement: None, body: Sequence [Text(x), SpaceElem, Text(↦), SpaceElem, AttachElem { base: Text(∫), t: None, b: Some(Some(Text(Y))), tl: None, bl: None, tr: None, br: None }, SpaceElem, Sequence [Text(f), LrElem { size: None, body: Sequence [Text((), Text(x), Text(,), SpaceElem, Text(y), Text())] }], SpaceElem, AttachElem { base: Text(μ), t: None, b: Some(Some(Text(Y))), tl: None, bl: None, tr: None, br: None }, LrElem { size: None, body: Sequence [Text((), Text(y), Text())] }] }, SpaceElem, Text(and), SpaceElem, EquationElem { block: Some(false), numbering: None, number_align: None, supplement: None, body: Sequence [Text(y), SpaceElem, Text(↦), SpaceElem, AttachElem { base: Text(∫), t: None, b: Some(Some(Text(X))), tl: None, bl: None, tr: None, br: None }, SpaceElem, Sequence [Text(f), LrElem { size: None, body: Sequence [Text((), Text(x), Text(,), SpaceElem, Text(y), Text())] }], SpaceElem, AttachElem { base: Text(μ), t: None, b: Some(Some(Text(X))), tl: None, bl: None, tr: None, br: None }, LrElem { size: None, body: Sequence [Text((), Text(x), Text())] }] }, SpaceElem, Text(are well-defined and measurable with respect to), SpaceElem, EquationElem { block: Some(false), numbering: None, number_align: None, supplement: None, body: AttachElem { base: #Set(equation.variant: Cal)
    Text(B), t: None, b: Some(Some(Text(X))), tl: None, bl: None, tr: None, br: None } }, SpaceElem, Text(and), SpaceElem, EquationElem { block: Some(false), numbering: None, number_align: None, supplement: None, body: AttachElem { base: #Set(equation.variant: Cal)
    Text(B), t: None, b: Some(Some(Text(Y))), tl: None, bl: None, tr: None, br: None } }, Text(, respectively.)] }, SpaceElem, ListItem { body: Sequence [Text(We have), SpaceElem, EquationElem { block: Some(true), numbering: None, number_align: None, supplement: None, body: Sequence [AlignPointElem, SpaceElem, AttachElem { base: Text(∫), t: None, b: Some(Some(Sequence [Text(X), SpaceElem, Text(×), SpaceElem, Text(Y)])), tl: None, bl: None, tr: None, br: None }, SpaceElem, Sequence [Text(f), LrElem { size: None, body: Sequence [Text((), Text(x), Text(,), SpaceElem, Text(y), Text())] }], SpaceElem, LrElem { size: None, body: Sequence [Text((), Sequence [HElem { amount: Rel(0.16666666666666666em), weak: Some(true) }, #Set(equation.italic: Custom(false))
    Text(d)], SpaceElem, AttachElem { base: Text(μ), t: None, b: Some(Some(Text(X))), tl: None, bl: None, tr: None, br: None }, SpaceElem, Text(×), SpaceElem, AttachElem { base: Text(μ), t: None, b: Some(Some(Text(Y))), tl: None, bl: None, tr: None, br: None }, Text())] }, LrElem { size: None, body: Sequence [Text((), Text(x), Text(,), SpaceElem, Text(y), Text())] }, LinebreakElem { justify: None }, SpaceElem, Text(=), SpaceElem, AlignPointElem, SpaceElem, AttachElem { base: Text(∫), t: None, b: Some(Some(Text(X))), tl: None, bl: None, tr: None, br: None }, SpaceElem, LrElem { size: None, body: Sequence [Text((), AttachElem { base: Text(∫), t: None, b: Some(Some(Text(Y))), tl: None, bl: None, tr: None, br: None }, SpaceElem, Sequence [Text(f), LrElem { size: None, body: Sequence [Text((), Text(x), Text(,), SpaceElem, Text(y), Text())] }], SpaceElem, Sequence [HElem { amount: Rel(0.16666666666666666em), weak: Some(true) }, #Set(equation.italic: Custom(false))
    Text(d)], SpaceElem, AttachElem { base: Text(μ), t: None, b: Some(Some(Text(Y))), tl: None, bl: None, tr: None, br: None }, LrElem { size: None, body: Sequence [Text((), Text(y), Text())] }, Text())] }, SpaceElem, Sequence [HElem { amount: Rel(0.16666666666666666em), weak: Some(true) }, #Set(equation.italic: Custom(false))
    Text(d)], SpaceElem, AttachElem { base: Text(μ), t: None, b: Some(Some(Text(X))), tl: None, bl: None, tr: None, br: None }, LrElem { size: None, body: Sequence [Text((), Text(x), Text())] }, SpaceElem, LinebreakElem { justify: None }, SpaceElem, Text(=), SpaceElem, AlignPointElem, SpaceElem, AttachElem { base: Text(∫), t: None, b: Some(Some(Text(Y))), tl: None, bl: None, tr: None, br: None }, SpaceElem, LrElem { size: None, body: Sequence [Text((), AttachElem { base: Text(∫), t: None, b: Some(Some(Text(X))), tl: None, bl: None, tr: None, br: None }, SpaceElem, Sequence [Text(f), LrElem { size: None, body: Sequence [Text((), Text(x), Text(,), SpaceElem, Text(y), Text())] }], SpaceElem, Sequence [HElem { amount: Rel(0.16666666666666666em), weak: Some(true) }, #Set(equation.italic: Custom(false))
    Text(d)], SpaceElem, AttachElem { base: Text(μ), t: None, b: Some(Some(Text(X))), tl: None, bl: None, tr: None, br: None }, LrElem { size: None, body: Sequence [Text((), Text(x), Text())] }, Text())] }, SpaceElem, Sequence [HElem { amount: Rel(0.16666666666666666em), weak: Some(true) }, #Set(equation.italic: Custom(false))
    Text(d)], SpaceElem, AttachElem { base: Text(μ), t: None, b: Some(Some(Text(Y))), tl: None, bl: None, tr: None, br: None }, LrElem { size: None, body: Sequence [Text((), Text(y), Text())] }] }, SpaceElem] }, SpaceElem], placement: Some(None), caption: Some(Some(FigureCaption { position: None, separator: None, body: Sequence [Text(Tonelli), SmartQuoteElem { double: Some(false), enabled: None, alternative: None, quotes: None }, Text(s Theorem), SpaceElem, Text((Theorem 1.7.15,), SpaceElem, RefElem { target: Label("tao_2011_IntroductionMeasureTheory"), supplement: None, citation: None, element: None }, Text())], kind: Some(Name("maths")), supplement: Some(Some(Text(Theorem))), numbering: Some(Some(Func(Func(thm-numbering)))), counter: Some(Some(Counter(Selector(Elem(Element(figure), Some([(3, "maths")])))))), figure_location: Some(Some(Location { hash: 167896810197078677029069933691306150431, disambiguator: 0, variant: 0 })) })), kind: Some(Custom(Name("maths"))), supplement: Some(Custom(Some(Content(Text(Theorem))))), numbering: Some(Some(Func(Func(thm-numbering)))), gap: Some(0.65em), outlined: Some(true), counter: Some(Some(Counter(Selector(Elem(Element(figure), Some([(3, "maths")])))))) })
[2024-08-20T10:42:55Z INFO  sync_lsp] handled  textDocument/prepareRename - (147) in 611.22µs