emacs-tree-sitter / elisp-tree-sitter

Emacs Lisp bindings for tree-sitter
https://emacs-tree-sitter.github.io
MIT License
816 stars 73 forks source link

Can't get Syntax Highlighting to work for Ruby in Emacs #154

Closed leviartan closed 2 years ago

leviartan commented 3 years ago

When I open a ruby file, I can see that Tree-Sitter-Hl mode is active, but none of the syntax highlighting has changed. But if I manually turn off it via M-X and then turn on again it start works. What am I doing wrong? How to force syntax highlighting automatically?

shackra commented 3 years ago

can you share your configuration, please?

leviartan commented 3 years ago

https://github.com/0xk175un3/emacs.d here it is

shackra commented 3 years ago

https://github.com/0xk175un3/emacs.d here it is

Please note that tree-sitter-hl-mode:

Enabling this automatically enables tree-sitter-mode in the buffer.

To enable this automatically whenever tree-sitter-mode is enabled:

 (add-hook 'tree-sitter-after-on-hook #'tree-sitter-hl-mode)

so you should modify the entire code block of your tree-sitter configuration to:

(use-package tree-sitter
  :ensure t
  :config
  (add-hook 'tree-sitter-after-on-hook #'tree-sitter-hl-mode)
  (add-hook 'ruby-mode-hook #'tree-sitter-mode))

I use Doom Emacs as my basis for my configuration and I have emacs-tree-sitter configure like this.

Please make changes and test if things work.

leviartan commented 3 years ago

Tried both variants, but sadly it doesn't work.

shackra commented 3 years ago

Tried both variants, but sadly it doesn't work.

keep the configuration with those corrections, further investigation on the rest of it may be necessary