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

Look for major modes and extensions for grammar loading #241

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion langs
Submodule langs updated 1 files
+38 −36 tree-sitter-langs.el
4 changes: 3 additions & 1 deletion lisp/tree-sitter.el
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,9 @@ OLD-LEN is the char length of the old text."
"Enable `tree-sitter' in the current buffer."
(unless tree-sitter-language
;; Determine the language symbol based on `major-mode' .
(let ((lang-symbol (alist-get major-mode tree-sitter-major-mode-language-alist)))
(let*
((file-extension (if (eq major-mode 'tuareg-mode) (file-name-extension buffer-file-name) nil))
(lang-symbol (alist-get (list major-mode file-extension) tree-sitter-major-mode-language-alist nil nil 'equal)))
(unless lang-symbol
(error "No language registered for major mode `%s'" major-mode))
(setq tree-sitter-language (tree-sitter-require lang-symbol))))
Expand Down