Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable tree sitter code only when it's enabled #522

Closed
wants to merge 1 commit into from

Conversation

psibi
Copy link
Member

@psibi psibi commented Feb 28, 2024

No description provided.

@alanz
Copy link

alanz commented Feb 28, 2024

This does not work for me. When I apply it locally, flycheck reports that rust-mode-treesitter-derive) is not defined

@alanz
Copy link

alanz commented Feb 28, 2024

Perhaps that should be an or?

@alanz
Copy link

alanz commented Feb 28, 2024

Adding (require 'rust-mode) gets rid of the warning, but the problem remains.

Turning the and into an or just makes rust-mode not load at all.

I am reluctant to turn on native tree-sitter mode, as I develop some tree-sitter grammars and have the non-native tree-sitter support enabled.

@psibi
Copy link
Member Author

psibi commented Feb 28, 2024

@alanz When do you actually see that warning that was reported by you ? Is it during installation or during some other step (Your latest comment indicates it's during flycheck) ? I can try reproducing it locally for my setup.

I don't think doing or is the right thing here.

@alanz
Copy link

alanz commented Feb 28, 2024

I agree or is not the right step, it broke completely.

I see the error on starting up emacs. I guess I need to dig more deeply into the actual origin. And/or go full native tree-sitter.
I will not be able to do any investigation today though

@alanz
Copy link

alanz commented Feb 28, 2024

And it seems the warning is benign, I have the functionality I need regardless.

@psibi
Copy link
Member Author

psibi commented Feb 28, 2024

see the error on starting up emacs.

Looking at my Messages buffer - I can see a similar type of warning:

 ■  Warning (treesit): Cannot activate tree-sitter, because language grammar for rust is unavailable (not-found): (libtree-sitter-rust libtree-sitter-rust.0 libtree-sitter-rust.0.0 libtree-sitter-rust.so libtree-sitter-rust.so.0 libtree-sitter-rust.so.0.0) No such file or directory

I receiving the warning even though I'm using a tree sitter based setup. Probably it's able to find the grammars subsequently, not sure.

And it seems the warning is benign, I have the functionality I need regardless.

Thanks for the confirmation, I assumed something was broken. Given the situation, I will close this PR. I would be happy to accept any PR that fixes the warning. :-)

@psibi psibi closed this Feb 28, 2024
@alanz
Copy link

alanz commented Feb 28, 2024

FYI, I switched to emacsformacosx, which has tree-sitter support build in. Without explicitly asking for the tree-sitter mode, I am getting

⛔ Warning (treesit): Cannot activate tree-sitter, because language grammar for rust is unavailable (not-found): (libtree-sitter-rust.so libtree-sitter-rust.so.0 libtree-sitter-rust.so.0.0 libtree-sitter-rust.dylib libtree-sitter-rust.dylib.0 libtree-sitter-rust.dylib.0.0) No such file or directory

Which I guess means I need to work out how to install the language. Is it documented somewhere? A quick scan of the README does not show anything

@alanz
Copy link

alanz commented Feb 28, 2024

And it looks like the steps are

init.el

  (setq treesit-language-source-alist
      '((rust "https://github.com/tree-sitter/tree-sitter-rust")
        ))

In emacs
M-x treesit-install-language-grammarPickrust`

@alanz
Copy link

alanz commented Feb 28, 2024

My final piece of barrage.

Putting the following into my init.le

(use-package rust-ts-mode
  :custom
  (rust-mode-treesitter-derive t)
...
)
...
(use-package lsp-mode
  :hook (rust-mode rust-ts-mode)
...
)

And basically using rust-ts-mode instead of rust-mode in all config restored

  • semantic highlighting
  • compile buffer regexp matching
  • basic rust-mode operation, such as knowledge of what the normal indent and comment markers are

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants