racket / drracket

DrRacket, IDE for Racket
http://www.racket-lang.org/
Other
444 stars 93 forks source link

Syntax highlighting is bad. #664

Closed Filipp-Druan closed 4 months ago

Filipp-Druan commented 5 months ago

Hello, dear developers! Sorry, but the syntax highlighting in DrRacket is poorly implemented. To run it at full power you need to press a button, besides, there is almost no difference between different syntax constructions by color. I like the way it works in Emacs much better. But DrRacket has its advantages as well. Could you please explain how to fix this? I'm willing to write the code myself, but I need to be coordinated. Thanks in advance!

spdegabrielle commented 5 months ago

Hi @Filipp-Druan Thank you for creating this issue.

To run it at full power you need to press a button,

By full power I believe you are referring to the check syntax button

image

And the differences between syntax highlighting before and after pressing 'check syntax'?

image image

https://docs.racket-lang.org/drracket/buttons.html

It would be helpful to provide example images like I have.

Please include example from Emacs if that helps.

PS: Have you tried https://www.racket-mode.com - you may find that works for you if you prefer Emacs.

soegaard commented 5 months ago
  1. Different languages have different rules for syntax highlighting.

  2. DrRacket provides a framework for #lang languages to use for syntax highlighting.

  3. Syntax highlighting based on lexeme categories (i.e. syntactic categories) is cheap and fast. The default mode uses this method.

  4. In languages with macros, an lexeme like foo could be a datum, an identifier, a keyword or something else. This means that the cheap and fast method from 3. falls short in many cases.

  5. An expansion of the module in question can determine what foo is. Whether a module expansion is fast depends both on the language and the program in question. Therefore, syntax highlighting based on the expanded module can be requested by clicking the "Syntax Check" button.

  6. Some users prefer the method from 5. over the method in 3. They enable "syntax expansion in the background". See the DrRacket preferences.

In short, the situation is more complex than meets the eye. The problem you see might not be due to DrRacket, but due to the implementation of the #lang language. That's why Stephen asks for a concrete example.

/Jens Axel

Den lør. 3. feb. 2024 kl. 20.35 skrev Stephen De Gabrielle < @.***>:

Hi @Filipp-Druan https://github.com/Filipp-Druan Thank you for creating this issue.

To run it at full power you need to press a button,

By full power I believe you are referring to the check syntax button image.png (view on web) https://github.com/racket/drracket/assets/108047/0a7a3401-bfdf-4a77-b23b-93f08e219091

And the differences between syntax highlighting before and after pressing 'check syntax'? image.png (view on web) https://github.com/racket/drracket/assets/108047/9233f9a4-aca7-461f-b683-2501779f04d2 image.png (view on web) https://github.com/racket/drracket/assets/108047/f9edbf55-e4f3-4c20-9747-e3583fc7f7b9

https://docs.racket-lang.org/drracket/buttons.html

It would be helpful to provide example images like I have.

Please include example from Emacs if that helps.

PS: Have you tried https://www.racket-mode.com - you may find that works for you if you prefer Emacs.

— Reply to this email directly, view it on GitHub https://github.com/racket/drracket/issues/664#issuecomment-1925437210, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADQXRKVWGLOOE6FPU5YGNLYR2GORAVCNFSM6AAAAABCVUPE2SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMRVGQZTOMRRGA . You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- -- Jens Axel Søgaard

soegaard commented 4 months ago

Let's close this one. If you have an example we can reopen.

Filipp-Druan commented 4 months ago

https://postimg.cc/xcspM8gg Here's an example. Agree that syntax highlighting in Emacs is much more diverse. And the design theme doesn't influence it much. It is even more diverse without it, though not as beautiful.

spdegabrielle commented 4 months ago

Hi @Filipp-Druan You can adjust your colour scheme in settings

Screenshot 2024-02-09 at 18 05 07

For more information please see https://docs.racket-lang.org/drracket/color-scheme.html

There is also a DrRacket script to save your chosen colorscheme as a package https://github.com/Quickscript-Competiton/July2020entries/blob/master/scripts/colorscheme2package.rkt

I think this answers your question but please re-open if you have more questions/

best regards

Stephen

shhyou commented 4 months ago

@Filipp-Druan To differentiate colors between e.g. language constructs and ordinary variables, you can use different colors for keywords and symbols. Here is what I did https://github.com/shhyou/drracket-scheme-dark-green.

Here are more color schemes https://pkgd.racket-lang.org/pkgn/search?q=&tags=colorscheme. Many of them do use different colors for keywords and symbols, e.g. https://github.com/takikawa/drracket-solarized and https://github.com/JoaoBrlt/drracket-one-dark?tab=readme-ov-file#preview.