acowley / wgsl-ts-mode

WGSL tree-sitter support for emacs
GNU General Public License v3.0
4 stars 0 forks source link

Font lock not working #1

Open kalin-p opened 6 months ago

kalin-p commented 6 months ago

The mode seems to be working, but I cannot see any syntax highlighting from font-lock-mode (which also seems to be on).

acowley commented 6 months ago

It should! When I enable this mode on a sample file, I am in major mode WGSL[ts] and minor modes Auto-Save Corfu Flyspell Font-Lock God-Local Yas. Do your active modes (I'm just using C-h m to check) look similar?

Screenshot 2024-02-29 at 8 34 56 AM
kalin-p commented 6 months ago

Thank you for the quick reply! When I open a .wgsl I get WGSL[ts] as a major mode, with minor modes Auto-Save Company Display-Line-Numbers Font-Lock Undo-Tree Visual-Line.

acowley commented 6 months ago

The trickiest part of tree-sitter grammars in emacs is getting them installed, can you double check that emacs has picked up your WGSL grammar? Running (treesit-language-available-p 'wgsl) should return t.

kalin-p commented 6 months ago

Yeah, it returns t.

kalin-p commented 6 months ago

Hey, I noticed that if I try to use wgsl-ts as a language for an org source code block I get some bizarre error at the line where the #+end_src is. If is use rust-ts as a language fontification works correctly. Additionally when the mode is compiled (when I start emacs) I get these errors:

⛔ Warning (comp): wgsl-ts-mode.el:97:7: Warning: assignment to free variable ‘wgsl-ts-mode--builtins-hash-table’
⛔ Warning (comp): wgsl-ts-mode.el:103:34: Warning: reference to free variable ‘wgsl-ts-mode--builtins-hash-table’
⛔ Warning (comp): wgsl-ts-mode.el:97:7: Warning: assignment to free variable ‘wgsl-ts-mode--builtins-hash-table’
⛔ Warning (comp): wgsl-ts-mode.el:103:34: Warning: reference to free variable ‘wgsl-ts-mode--builtins-hash-table’

It is probably worth mentioning I use straight for package management, although I doubt it is the culprit.

acowley commented 6 months ago

Probably worth changing the setq to defvar to address that warning. I think I inherited it from rust-ts-mode that I adapted. I don't get any error in an org src block with wgsl-ts as the language. Can you share the error you see?

I use nix to build emacs with all my packages rather than straight, but I also don't know exactly how that could be causing trouble.