llemaitre19 / jtsx

Extends Emacs JSX/TSX built-in support.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support default syntax highlight

dackon opened this issue · comments

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

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).

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

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.

OK, thanks for reply.