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
544 stars 27 forks source link

Ability to extend outline #496

Closed memeplex closed 1 month ago

memeplex commented 2 months ago

Motivation

I use to create my slideshows in LaTeX Workshop with Beamer and it shows the title for each frame environment in the outline, which makes sense since they are logical units of the document.

With polylux what are slides depends on the current theme. For example, with the Bipartite theme:

#west-slide(title: "A longer slide title")[
  #lorem(40)
]

#east-slide(title: "On the right!")[
  #lorem(40)
]

Description

It would be nice if the user could provide a list of regular expressions with capture patterns to show in the outline.

Or if it's more efficient to match the ast or some other structure you already have at hand, perhaps some kind of selector.

Myriad-Dreamin commented 2 months ago

There are two outlines available.

You may seek the second one.

Trick Hint: using a hidden heading to create an outline item in place:

#let my-slide(..args, body) = {
  let title = {
    let title = args.named().at("title")
    // create an outline item separated from its displayed content.
    place({
      set text(fill: rgb("00000000"))
      heading(title, depth: 1)
    })
    display-title(title, ..args)
  }

  slide(..args, title: title, body)
}
memeplex commented 2 months ago
  • exported document outline in "ActivityBar > Tinymist > Outline"

I just have a Symbol View here, should I enable something else perhaps?

Myriad-Dreamin commented 2 months ago
  • exported document outline in "ActivityBar > Tinymist > Outline"

I just have a Symbol View here, should I enable something else perhaps?

it's behind on a feature flag tinymist.preview.showInActivityBar.

memeplex commented 1 month ago

Ah I see, it's related to the sidebar preview. Ok, it does show the headings, thanks! Having the preview there may be overkilling just for the outline, but I hope that by hiding it, it won't consume any resources.

On a side note, I wanted to check that the outline was showing headings, so I Cmd-clicked on, say, west-slide, it took me to bipartite.typ, so far so good, but after that Cmd-click navigation failed to work not only for things outside of bipartite.typ but also between bipartite.typ definitions. Is this expected? Is it because they are outside the project? If not I can open another issue.

Myriad-Dreamin commented 1 month ago

Having the preview there may be overkilling just for the outline, but I hope that by hiding it, it won't consume any resources.

It costs much less resources since it just maintains low-resolution images.

On a side note, I wanted to check that the outline was showing headings, so I Cmd-clicked on, say, west-slide, it took me to bipartite.typ, so far so good, but after that Cmd-click navigation failed to work not only for things outside of bipartite.typ but also between bipartite.typ definitions. Is this expected? Is it because they are outside the project? If not I can open another issue.

I don't quite get.

memeplex commented 1 month ago

I mean, I cmd-clicked on a package function from my own file and it went to the definition site in the package as expected. But once inside the package file cmd-click navigation does nothing, I can't navigate to other definitions in the same file neither to definitions in another files of the package. Perhaps cmd-click only works insides files that are part of the VSCode project and that's expected, I don't know.

Myriad-Dreamin commented 1 month ago

I mean, I cmd-clicked on a package function from my own file and it went to the definition site in the package as expected. But once inside the package file cmd-click navigation does nothing, I can't navigate to other definitions in the same file neither to definitions in another files of the package. Perhaps cmd-click only works insides files that are part of the VSCode project and that's expected, I don't know.

This can be improved. This is probably because LSP server fails to analyze the library code when it changes the peeking file as the "main file". As a workaround, perhaps you can try to pin a document and see if analyzers work without changing the "main file".

Hint: preview command will always pin a document if there is no pinned document.