Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sticky lines for chapter + section #3545

Open
jojo2357 opened this issue May 6, 2024 · 8 comments
Open

Sticky lines for chapter + section #3545

jojo2357 opened this issue May 6, 2024 · 8 comments
Labels
enhancement New feature or (non bug related) change to the program.

Comments

@jojo2357
Copy link
Contributor

jojo2357 commented May 6, 2024

In IDES circa 2024, they added sticky lines. While it works for a lot of tokens, it does not work for \chapter or \section tokens, which I would think are important to know where you are in the tex.

I think this should be obvious to replicate? just add a \chapter and a lot of lines and scroll down and see that it doesnt end up at the sticky lines

@jojo2357 jojo2357 added enhancement New feature or (non bug related) change to the program. untriaged Issue type still needs to be triaged or verified. labels May 6, 2024
@PHPirates
Copy link
Collaborator

Not sure if this is possible, do you have any idea how they determine scopes? Don't see anything in the intellij sdk docs yet about sticky lines

@jojo2357
Copy link
Contributor Author

jojo2357 commented May 9, 2024

Absolutely no idea, only hunch is that it uses environs that close and open? Cuz \begin{figure} sticks, so I presume we somehow need to make chapters and sections a thing? how? based off spacing? Yikes.

@PHPirates PHPirates added wontfix Issue will be discarded by the development team. and removed untriaged Issue type still needs to be triaged or verified. wontfix Issue will be discarded by the development team. labels May 13, 2024
@PHPirates
Copy link
Collaborator

I asked at jetbrains slack channel and Scott Wells replied:

It's all based on the breadcrumbsInfoProvider EP. Implement that properly for your language, and the elements included in the breadcrumb trail are the same ones used for sticky line scopes.

To be specific, for my plugin's custom language, I had to implement the following methods in BreadcrumbsProvider properly:
getLanguages()
acceptElement()
getElementInfo()
getElementTooltip()
I believe the latter two are more specific to the way things look in the breadcrumb than to sticky lines.
With those properly implemented, though, it works wonderfully:
image

@jojo2357
Copy link
Contributor Author

Okay, I checked and every command is being accepted (so if there was such thing as a multiline command, then it would be sticking.

I am 99% sure that the reason that it isnt sticking is the fact that the element being accepted is ONLY the \chapter command. If the chapter was similar to an environment and had an implicit ending, then the token would be large and would be stickable.

@PHPirates
Copy link
Collaborator

Yeah I guess that's the only way it can determine the scope. I don't see an easy way to add sectioning commands to the parser without breaking a lot of things though.

@jojo2357
Copy link
Contributor Author

I want to give it a shot, and I'm not sure where to start. Starting in the bnf or flex is very static, and not future-proof. It would be really nice if there was some way to define a weak environment that gets added to the PSI/AST after lexing. That way we could go so far as to make chapter/sections configurable in settings so the user can define their own sectioning commands.

Thoughts @PHPirates ?

@PHPirates
Copy link
Collaborator

Querying user settings from the lexer is probably not a good idea because it will make the lexer slow. There are also token type remappers (LatexParserUtil) for parser level, but they are not easy to use.

@jojo2357
Copy link
Contributor Author

I saw those, and I concured that they are hard to use.

For such a new feature I think it would be fine to wait a little to see what happens. We have folding for the chapter so secretly im hoping we will be able to recycle that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or (non bug related) change to the program.
Projects
None yet
Development

No branches or pull requests

2 participants