llemaitre19 / jtsx

Extends Emacs JSX/TSX built-in support.
GNU General Public License v3.0
69 stars 2 forks source link

Support default syntax highlight #4

Closed dackon closed 8 months ago

dackon commented 8 months ago

Hey, this is a great package, but I prefer default syntax highlight, can you add an option to support it? Thanks.

llemaitre19 commented 8 months ago

Thanks. The jtsx-enable-all-syntax-highlighting-features existing option is not what you are looking for ? If you turn it to nil, default syntax highlighting should be applied (default level instead of level 4 in treesit-font-lock-level).

dackon commented 8 months ago

The option doesn't work for my emacs (29.2)

(use-package jtsx
  ...
  :config
  ...
  (setq jtsx-enable-all-syntax-highlighting-features nil)
)
Screenshot 2024-02-28 at 23 36 51
llemaitre19 commented 8 months ago

As far as I know, the jtsx-enable-all-syntax-highlighting-features option is working as expected. If it was enabled, push in blockList.push( would be blue.

The default Javascript mode of your screenshot (ie js-mode) is not the one onto jtsx-jsx-mode is implemented (ie js-ts-mode). So what you notice is just a difference of opinion in terms of syntax highlighting between js-mode and js-ts-mode, not a jtsx bug.

If you try js-ts-mode, depending on the version of the tree-sitter Javascript language, instead of getting the same syntax highlighting as in jtsx-ts-mode, you could be surprised to see that many highlighting rules do not work at all. There is a bug in Emacs 29.2, now fixed in Emacs upstream and backported in jtsx.

If you really want to get the same syntax highlighting as in js-mode, you can customize js--treesit-font-lock-settings with some elisp code but it is not recommanded though as it will hard code all rules and could prevent some new features or fixes from working in incoming Emacs releases.

dackon commented 8 months ago

OK, thanks for reply.