Repository navigation
Fix math function tooltips/completions, and add MathFieldAccess and LinkedNode::mode - #8116
Conversation
laurmaedje
left a comment
There was a problem hiding this comment.
Nice work! Just a few comments.
On the mode suggestions for a couple of the "boundary" syntax nodes, I'm not entirely certain, but I feel like it's not quite consistent as is.
f003f80 to
ba26acc
Compare
|
I think I've resolved all the non-mode related comments. I also pushed a refactor that didn't change any behavior, but adds For the various mode comments, I think what we really want out of the method is a way to determine the This would also resolve what to return when something is embedded with a hash, like To clarify this, how would you feel about renaming Finally, for |
|
I think what you say makes sense. I was only thinking about the modes in the abstract, not with their concrete use for completions in mind. I'm on board with the changes. One thing I don't fully get yet is how |
|
|
f2a860e to
ea58a33
Compare
|
Updated with those changes. I also realized that there were issues with a few other kinds like Also, I expanded the |
| Self::Strong => Known(Markup), | ||
| Self::Emph => Known(Markup), | ||
| Self::Raw => Embeddable, // code/markup: expr | ||
| Self::RawLang => Parent, // code/markup: Raw |
There was a problem hiding this comment.
After the RawLang, are we really in code or markup? We're still in the raw block after all. So perhaps we could handle this like we handle comments, by returning None from LinkedNode::mode_after.
The other raw parts are also a bit tricky.
There was a problem hiding this comment.
I think returning None makes sense for the internal kinds. For now, I'll switch to doing so except for the overall Raw kind and the closing raw delimiter.
However, you should also know that tinymist has a very similar construct as an InterpretMode enum with variants for Code/Math/Markup and Raw/String/Comment (defined in tinymist-analysis/src/syntax/matcher.rs:316). If you want, we could try to unify with them by outputting a similar enum, but their code would probably benefit from mode_after regardless.
Also note that Raw does trigger some special completions for tinymist, but I can't find an instance of them using String/Comment to produce any particular kind of completion.
|
|
||
| Self::Shebang => Comment, | ||
| Self::LineComment => Comment, | ||
| Self::BlockComment => Comment, |
There was a problem hiding this comment.
Aren't we, in principle, back in the parent mode right after a block comment? Though changing this would also have an effect on the autocomplete changes.
There was a problem hiding this comment.
I guess we kind of are, but I don't think we can do any better without adding a representation for the delimiter of a comment or changing the whole mode_after interface to use cursors instead of whole nodes. So I think it's probably best to just not do anything for this :/
There was a problem hiding this comment.
I don't quite follow. What would be wrong about setting BlockComment to Parent?
There was a problem hiding this comment.
Nothing wrong with it, it would just affect autocompletion if we did.
| let _ = complete_comments(&mut ctx) | ||
| || complete_field_accesses(&mut ctx) | ||
| // Getting the syntax mode also ensures we are not in a comment. | ||
| let mode = ctx.leaf.mode_after()?; |
There was a problem hiding this comment.
I wonder if the "mode after" framing will cause any issues when attempting to trigger completions at a position that is not on a node boundary.
There was a problem hiding this comment.
I think there are really only a few edge cases like raw/strings/comments which would be problematic and could be handled by special completions before accessing mode_after.
There was a problem hiding this comment.
But since we don't have any of those completions ourselves, I think it's fine for now?
211e557 to
beb6160
Compare
Co-authored-by: Laurenz <[email protected]>
Co-authored-by: Runge <[email protected]>
|
Rebased off main and updated to return |
|
Thank you! |
commit 65301b2 Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Date: Fri Jun 5 00:57:12 2026 +0000 build: update tinymist to 0.14.23 commit 3ac7c69 Author: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Date: Thu Jun 4 23:30:34 2026 +0000 build: update tinymist to 0.14.23-rc1 commit 4f5efbf Author: paran3xus <[email protected]> Date: Thu Jun 4 12:41:19 2026 +0000 feat: add compatibility for typst/typst#7865 and typst/typst#8116 commit cb25b2e Author: paran3xus <[email protected]> Date: Sat May 16 10:06:29 2026 +0000 fix: adapt typstyle-consistency to typst/typst#7964 commit ae25cb3 Author: paran3xus <[email protected]> Date: Sat May 16 10:06:22 2026 +0000 fix: adapt today to typst/typst#7691 commit c5702de Author: paran3xus <[email protected]> Date: Sat May 16 05:14:33 2026 +0000 build: patch typst-bundle commit aeffa37 Author: paran3xus <[email protected]> Date: Fri May 15 05:09:16 2026 +0000 build: bump tinymist-world to nightly (remote branch) commit 8ea80b1 Author: paran3xus <[email protected]> Date: Thu May 14 05:08:26 2026 +0000 build: bump typst to nightly (local patch) a
This PR is part of the Typst 0.15 nightly cleanup stack. It sits on top of the path-model group and keeps this slice focused on analyzer, query, debug, lint, eval, and typlite API adaptation. ## Upstream Typst Changes - [`typst/typst#7542`](typst/typst#7542) changes function internals. Tinymist updates signature, definition, hover, and rename paths that inspect function internals. - [`typst/typst#7543`](typst/typst#7543) moves call sites toward `to_element`-style element handling. Tinymist updates field access, completion kind inference, and syntax type checking accordingly. - [`typst/typst#7808`](typst/typst#7808) changes parameter metadata. Tinymist updates signature help, built-in type metadata, scope completion, and type completion to the new parameter representation. - [`typst/typst#8215`](typst/typst#8215) requests the standard library from `World` once upfront. Tinymist updates tracked values, upstream helpers, global analysis, DAP request evaluation, and eval engine construction to use the preloaded library path. - [`typst/typst#7865`](typst/typst#7865), [`typst/typst#8116`](typst/typst#8116), and `typst/typst@5326cd297` adjust math call, math field, and prime syntax. Tinymist updates syntax matchers, coverage instrumentation, debugger instrumentation, lint behavior, expression parsing, and query fixtures. - [`typst/typst#7490`](typst/typst#7490) and `typst/typst@cfdd4238b` change font metadata APIs. Tinymist updates document metrics and symbol glyph handling. - `typst/typst@0f04fd176` changes diagnostic hints into spanned values. Tinymist updates diagnostic hint rendering. - [`typst/typst#7897`](typst/typst#7897) introduces import item placeholders and related attach/text API changes. Tinymist updates import completions and math text/attach matching. - Typst 0.15 makes `typst::ROUTINES` private, adds the library argument to `typst_eval::eval`, and protects engine introspection. Tinymist updates `typst-shim` eval for both nightly and default feature builds. ## Tinymist Changes - Ports analysis and query code to the updated function, element, parameter, font, and math syntax APIs. - Updates debug coverage and debugger instrumentation for the new math call/field syntax shapes. - Updates lint behavior so function-call and math-call handling stay aligned. - Updates DAP and `crityp` to the preloaded engine library path. - Updates `typst-shim` eval and syntax compatibility modules so both `nightly` and default feature builds compile against the current Typst 0.15 dependency set. - Refreshes targeted query and typlite fixtures affected by these API and syntax behavior changes. --------- Co-authored-by: paran3xus <[email protected]>
This PR is part of the Typst 0.15 nightly cleanup stack. It sits on top of the path-model group and keeps this slice focused on analyzer, query, debug, lint, eval, and typlite API adaptation. - [`typst/typst#7542`](typst/typst#7542) changes function internals. Tinymist updates signature, definition, hover, and rename paths that inspect function internals. - [`typst/typst#7543`](typst/typst#7543) moves call sites toward `to_element`-style element handling. Tinymist updates field access, completion kind inference, and syntax type checking accordingly. - [`typst/typst#7808`](typst/typst#7808) changes parameter metadata. Tinymist updates signature help, built-in type metadata, scope completion, and type completion to the new parameter representation. - [`typst/typst#8215`](typst/typst#8215) requests the standard library from `World` once upfront. Tinymist updates tracked values, upstream helpers, global analysis, DAP request evaluation, and eval engine construction to use the preloaded library path. - [`typst/typst#7865`](typst/typst#7865), [`typst/typst#8116`](typst/typst#8116), and `typst/typst@5326cd297` adjust math call, math field, and prime syntax. Tinymist updates syntax matchers, coverage instrumentation, debugger instrumentation, lint behavior, expression parsing, and query fixtures. - [`typst/typst#7490`](typst/typst#7490) and `typst/typst@cfdd4238b` change font metadata APIs. Tinymist updates document metrics and symbol glyph handling. - `typst/typst@0f04fd176` changes diagnostic hints into spanned values. Tinymist updates diagnostic hint rendering. - [`typst/typst#7897`](typst/typst#7897) introduces import item placeholders and related attach/text API changes. Tinymist updates import completions and math text/attach matching. - Typst 0.15 makes `typst::ROUTINES` private, adds the library argument to `typst_eval::eval`, and protects engine introspection. Tinymist updates `typst-shim` eval for both nightly and default feature builds. - Ports analysis and query code to the updated function, element, parameter, font, and math syntax APIs. - Updates debug coverage and debugger instrumentation for the new math call/field syntax shapes. - Updates lint behavior so function-call and math-call handling stay aligned. - Updates DAP and `crityp` to the preloaded engine library path. - Updates `typst-shim` eval and syntax compatibility modules so both `nightly` and default feature builds compile against the current Typst 0.15 dependency set. - Refreshes targeted query and typlite fixtures affected by these API and syntax behavior changes. --------- Co-authored-by: paran3xus <[email protected]>
This PR is part of the Typst 0.15 nightly cleanup stack. It sits on top of the path-model group and keeps this slice focused on analyzer, query, debug, lint, eval, and typlite API adaptation. - [`typst/typst#7542`](typst/typst#7542) changes function internals. Tinymist updates signature, definition, hover, and rename paths that inspect function internals. - [`typst/typst#7543`](typst/typst#7543) moves call sites toward `to_element`-style element handling. Tinymist updates field access, completion kind inference, and syntax type checking accordingly. - [`typst/typst#7808`](typst/typst#7808) changes parameter metadata. Tinymist updates signature help, built-in type metadata, scope completion, and type completion to the new parameter representation. - [`typst/typst#8215`](typst/typst#8215) requests the standard library from `World` once upfront. Tinymist updates tracked values, upstream helpers, global analysis, DAP request evaluation, and eval engine construction to use the preloaded library path. - [`typst/typst#7865`](typst/typst#7865), [`typst/typst#8116`](typst/typst#8116), and `typst/typst@5326cd297` adjust math call, math field, and prime syntax. Tinymist updates syntax matchers, coverage instrumentation, debugger instrumentation, lint behavior, expression parsing, and query fixtures. - [`typst/typst#7490`](typst/typst#7490) and `typst/typst@cfdd4238b` change font metadata APIs. Tinymist updates document metrics and symbol glyph handling. - `typst/typst@0f04fd176` changes diagnostic hints into spanned values. Tinymist updates diagnostic hint rendering. - [`typst/typst#7897`](typst/typst#7897) introduces import item placeholders and related attach/text API changes. Tinymist updates import completions and math text/attach matching. - Typst 0.15 makes `typst::ROUTINES` private, adds the library argument to `typst_eval::eval`, and protects engine introspection. Tinymist updates `typst-shim` eval for both nightly and default feature builds. - Ports analysis and query code to the updated function, element, parameter, font, and math syntax APIs. - Updates debug coverage and debugger instrumentation for the new math call/field syntax shapes. - Updates lint behavior so function-call and math-call handling stay aligned. - Updates DAP and `crityp` to the preloaded engine library path. - Updates `typst-shim` eval and syntax compatibility modules so both `nightly` and default feature builds compile against the current Typst 0.15 dependency set. - Refreshes targeted query and typlite fixtures affected by these API and syntax behavior changes. --------- Co-authored-by: paran3xus <[email protected]>
This PR fixes a number of issues with IDE functionality in Typst and adds two major refactorings to simplify future maintenance of these features.
The major refactorings are the addition of the
MathFieldAccesssyntax kind and theLinkedNode::modemethod.MathFieldAccessis meant to further distinguish math from code in the syntax tree (in the same vein asIdentvs.MathIdent), which both simplifies the implementation ofLinkedNode::modeand will be useful for future math syntax refactorings. The implementation ofLinkedNode::modesupersedes PR #7407, but I've changed the implementation to use a data-oriented approach by having theLinkedNodemethod match on an enum,ModeSearch,which is only dependent on theSyntaxKind.However, I only implemented the refactorings after having resolved most of the issues via the prior commits. I did this so that I could better understand where those errors were actually coming from and so we could more clearly see the benefits of the refactorings to code clarity without them also affecting behavior. Although the addition of
LinkedNode::modedid allow for fixing completions for named and spread arguments in math which I couldn't find a way to resolve beforehand.traceon identifiersSyntaxKind::MathFieldAccessLinkedNode::mode(&self) -> Option<SyntaxMode>typst-ide