Comments (15)
Okay, I was able to fix the lazy loading issue by minor refactoring, I can confirm the below code works:
(use-package tree-sitter
:if (executable-find "tree-sitter")
:straight (tree-sitter :type git
:host github
:repo "ubolonton/emacs-tree-sitter"
:files ("lisp/*.el" "src" "Cargo.toml" "Cargo.lock"))
:hook (((rustic-mode
python-mode
css-mode) . tree-sitter-mode)
((rustic-mode
python-mode
css-mode) . tree-sitter-hl-mode))
:config
(add-to-list 'tree-sitter-major-mode-language-alist
'(rustic-mode . rust)))
(use-package tree-sitter-langs
:if (executable-find "tree-sitter")
:straight (tree-sitter-langs :type git
:host github
:repo "ubolonton/emacs-tree-sitter"
:files ("langs/*.el" "langs/queries"))
:after tree-sitter)
from elisp-tree-sitter.
Turns out I'm having this issue too:
File mode specification error: (error Cannot find shared library for language: go)
to fix this run tree-sitter-langs-install-grammars
or hook (lambda () (tree-sitter-langs-install-grammars t))
to your after-init-hook
from elisp-tree-sitter.
Normally you'd use (require 'tree-sitter-langs)
explicitly, as described in the doc.
use-package
uses deferred loading, so you will need to add :after tree-sitter
instead:
(use-package tree-sitter-langs
:straight (tree-sitter-langs :type git
:host github
:repo "ubolonton/emacs-tree-sitter"
:files ("langs/*.el" "langs/queries"))
:after tree-sitter)
from elisp-tree-sitter.
I'll add it in the next release.
You can also customize tree-sitter-major-mode-language-alist
to make it work:
(add-to-list 'tree-sitter-major-mode-language-alist '(rustic-mode . rust))
from elisp-tree-sitter.
Okay, I added that to my emacs config, but now when I open a rust file, I am getting the below error:
tree-sitter-load: Cannot find shared library for language: rust
what does this error mean?
from elisp-tree-sitter.
Okay, I added that to my emacs config, but now when I open a rust file, I am getting the below error:
tree-sitter-load: Cannot find shared library for language: rust
what does this error mean?
it means you need to install the rust grammar I think, but that is installed when you install this package, but I could be wrong
from elisp-tree-sitter.
Turns out I'm having this issue too:
File mode specification error: (error Cannot find shared library for language: go)
to fix this run
tree-sitter-langs-install-grammars
or hook(lambda () (tree-sitter-langs-install-grammars t))
to yourafter-init-hook
We dont need to do this. I suppose we have to run this only once to install all the grammars.
I managed to get it work with use-package
and straight.el
You can find my config here: https://github.com/CSRaghunandan/.emacs.d/blob/master/setup-files/setup-tree-sitter.el
from elisp-tree-sitter.
@ubolonton Maybe it will be helpful if you could run tree-sitter-langs-install-grammars
as a part of the build process for installing emacs-tree-sitter
package? I'm really not sure how emacs package management works and whether or not this is possible.
You can document this in README section so that the users don't get confused.
from elisp-tree-sitter.
Maybe it will be helpful if you could run
tree-sitter-langs-install-grammars
as a part of the build process for installingemacs-tree-sitter
package?
tree-sitter-langs-install-grammars
should already be run when tree-sitter-langs
is installed, as part of the byte-compilation process. If that's not the case, please provide a reproduction.
to fix this run
tree-sitter-langs-install-grammars
or hook(lambda () (tree-sitter-langs-install-grammars t))
to yourafter-init-hook
Please don't do this. If it was not run automatically, that's a bug to be fixed.
from elisp-tree-sitter.
Maybe it will be helpful if you could run
tree-sitter-langs-install-grammars
as a part of the build process for installingemacs-tree-sitter
package?
tree-sitter-langs-install-grammars
should already be run whentree-sitter-langs
is installed, as part of the byte-compilation process. If that's not the case, please provide a reproduction.to fix this run
tree-sitter-langs-install-grammars
or hook(lambda () (tree-sitter-langs-install-grammars t))
to yourafter-init-hook
Please don't do this. If it was not run automatically, that's a bug to be fixed.
Pleaes find below the steps to reproduce:
-
Copy my emacs config here: https://github.com/CSRaghunandan/.emacs.d/blob/master/setup-files/setup-tree-sitter.el
It uses straight + use-package to configure tree-sitter for emacs
-
Evaluate the buffer. This should download and build
tree-sitter
usingstraight
-
Open any rust file
-
Run
tree-sitter-hl-mode
And you should run into the error: tree-sitter-load: Cannot find shared library for language: rust
. Maybe tree-sitter-langs-install-grammars
is not being run when building the package using straight
instead of MELPA.
from elisp-tree-sitter.
We dont need to do this. I suppose we have to run this only once to install all the grammars.
that's just a workaround
Please don't do this. If it was not run automatically, that's a bug to be fixed.
ibid.
from elisp-tree-sitter.
This is my conf. for emacs-tree-sitter:
(use-package tree-sitter
:straight (tree-sitter :host github
:repo "ubolonton/emacs-tree-sitter"
:files ("lisp/*.el" "src" "Cargo.toml" "Cargo.lock"))
:hook ((after-init . global-tree-sitter-mode)
((go-mode python-mode js-mode typescript-mode) . tree-sitter-hl-mode)))
(use-package tree-sitter-langs
:straight (tree-sitter-langs :host github
:repo "ubolonton/emacs-tree-sitter"
:files ("langs/*.el" "langs/queries"))
:hook (after-init . (lambda () (tree-sitter-langs-install-grammars t))))
I, too, use straight.el. Without the workaround this bug will show up.
from elisp-tree-sitter.
Normally you'd use
(require 'tree-sitter-langs)
explicitly, as described in the doc.
use-package
uses deferred loading, so you will need to add:after tree-sitter
instead:(use-package tree-sitter-langs :straight (tree-sitter-langs :type git :host github :repo "ubolonton/emacs-tree-sitter" :files ("langs/*.el" "langs/queries")) :after tree-sitter)
I tried this, but ran into the same error. tree-sitter-load: Cannot find shared library for language: rust
I had to run (require 'tree-sitter-langs)
in :init
section of use-package for it work. Is there a better way to do this? I'd like to lazy tree-sitter until I actually open a file for which tree-sitter-mode
is enabled.
from elisp-tree-sitter.
I had to run
(require 'tree-sitter-langs)
in:init
section of use-package for it work. Is there a better way to do this? I'd like to lazy tree-sitter until I actually open a file for whichtree-sitter-mode
is enabled.
:init (require 'tree-sitter-langs)
is not the right way to do it. It effectively means calling (require 'tree-sitter-langs)
twice. :after tree-sitter
should be the correct way. Please consult use-package
's documentation.
- Evaluate the buffer. This should download and build
tree-sitter
usingstraight
Please provide better reproduction steps, which are not dependent on a specific config (the result of evaluating that depends on the specific straight.el setup; and in my case, it worked). For example, this is a minimal init.el
that works: https://gist.github.com/ubolonton/9e135c0ae12600e6ab0b5d0868a4def7#file-init-el
from elisp-tree-sitter.
I had to run
(require 'tree-sitter-langs)
in:init
section of use-package for it work. Is there a better way to do this? I'd like to lazy tree-sitter until I actually open a file for whichtree-sitter-mode
is enabled.
:init (require 'tree-sitter-langs)
is not the right way to do it. It effectively means calling(require 'tree-sitter-langs)
twice.:after tree-sitter
should be the correct way. Please consultuse-package
's documentation.
- Evaluate the buffer. This should download and build
tree-sitter
usingstraight
Please provide better reproduction steps, which are not dependent on a specific config (the result of evaluating that depends on the specific straight.el setup; and in my case, it worked). For example, this is a minimal
init.el
that works: https://gist.github.com/ubolonton/9e135c0ae12600e6ab0b5d0868a4def7#file-init-el
I realized why tree-sitter-langs was not being loaded. Since I used :hook
declaration in my config, it tree-sitter is being lazy loaded.
I put :demand t
for tree-sitter-langs
use-package config and now it is working. But hmm. I'm still not sure if this is the right way of doing things.
I will give you steps to reproduce a littler today after my day job completes.
Thank you for your prompt replies
from elisp-tree-sitter.
Related Issues (20)
- `Unsupported Operating System: OpenBSD` HOT 7
- bin/build not work on linux because builtin cd will output the folder name. HOT 1
- tree-sitter languages download of windows binaries failed with error
- tsc-lang-abi-too-new when installing new language HOT 11
- Crash when large file contains an ERROR node
- Invalid version syntax: ‘[email protected] HOT 1
- Colors look wrong in haskell mode. HOT 3
- `tree-sitter-debug-mode` is broken
- Crash when loading one particular Markdown file HOT 7
- Reporting Vulnerability
- (ts-fold-indicators-mode) not working when running emacs from terminal
- How do I add a new grammer to this mode? HOT 2
- why the submodule langs pointed to an old commit?
- tree-sitter-hl-mode doesn't honor the :extend font face in single line comments HOT 1
- request to rebuild tsc-dyn.so with older Linux OS
- Provide `aarch64` build of `tsc-dyn.so` for AArch64 Linux
- Repetitions and Predicate Problems
- Tree sitter not loading in Raspberry Pi 5 with Emacs GNU Emacs 28.2 HOT 2
- `tsc-current-field` doesn't work against starting node HOT 7
- Returned parent node doesn't contain given node as child HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elisp-tree-sitter.