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

[FR] Codemirror Language Package for printer.cfg #1355

Open
forgodtosave opened this issue Apr 25, 2023 · 8 comments
Open

[FR] Codemirror Language Package for printer.cfg #1355

forgodtosave opened this issue Apr 25, 2023 · 8 comments
Labels
💡 Type: FR Requests a new feature

Comments

@forgodtosave
Copy link
Contributor

forgodtosave commented Apr 25, 2023

Requested feature:

A Codemirror Language Package for printer.cfg. It would enable a lot of useful features, like 

  • error highlighting without "Restart&Save"  
  • better code highlighting  
  • auto indentation ... 

It would also create a syntax tree, which would be useful to find blocks of config to resolve #1320

Solves the following problem:

  • No static error checking in the config file
  • no auto indentation
  • flat syntax tree

Additional information:

I would like to try it and would start based on this example, but I’m not sure if there will be any license problems or what a good directory structure would look like.

@meteyou
Copy link
Member

meteyou commented Apr 25, 2023

pls check the open PRs. most of these things are already did...

@forgodtosave
Copy link
Contributor Author

forgodtosave commented Apr 26, 2023

Sorry, but I can't find anything regarding this in the open PRs. There is only text highlighting for jinja2 but nothing regarding the complete printer.cfg. 
And I would like to have a complete language package which is, as far as I know, state of the art for Codemirror 6. This includes a parser for the language generated with a lezer grammar. With this parser a syntax tree can be created which makes a lot of cool stuff possible. Like easy highlighting, auto indentation, and even autocompletion/syntax-aware-selection. 
I know it will be a quite lot of work, but I would like to try to write a grammar for the printer.cfg.

@meteyou
Copy link
Member

meteyou commented Apr 30, 2023

@forgodtosave ohhh that sounds really nice!

can you use this PR/branch to check the syntax highlighting for your language package -> #1200

@forgodtosave
Copy link
Contributor Author

Sorry, but I don't think so, at least in the current state. Lezer supports grammar nesting and it should even be possible between a lezer parser and a stream parser. The only problem is that in #1200 the streamParserJinja2 has been removed and integrated into streamParserKlipperConfig. Of course it would be possible to nest the new parser of #1200 into the new language, but it would be quite ugly because it would be a klipper/jinja2 paser in a klipper parser. 

Another question: why did you implement a custom jinja2 streamParser? There is a public version available.

@meteyou
Copy link
Member

meteyou commented May 4, 2023

This was meant as a hint that you should follow this syntax highlighting instead of the current one from Mainsail.

I have not implemented this. This was a contribution...

@zellneralex
Copy link
Member

@forgodtosave we tested the public parser but Klipper has e.g. modified start and end variable strings. Testing with my config (https://github.com/zellneralex/klipper_config) showed in many areas that the default parser failed.

BTW our custom parser is also not 100% perfect but the best we have so far.

@forgodtosave
Copy link
Contributor Author

@zellneralex ok then of course it makes sense to use the custom parser.

@meteyou the new streamparser definitely looks better than the current one. However, I think it would be great if there were more than just syntax highlighting. I started with a grammar for the KlipperConfig and that seems to work quite well. Everything related to Jinja2, is currently outsourced to the old parser. Of course, that could also be the new one from #1200, but then everything related to the KlipperConfig in it would be unnecessary.

@meteyou
Copy link
Member

meteyou commented May 9, 2023

@forgodtosave I would also love a complete language package. One feature that I personally always miss is a collapse section function. I think this is also only available in language packages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💡 Type: FR Requests a new feature
Projects
None yet
Development

No branches or pull requests

3 participants