-
Notifications
You must be signed in to change notification settings - Fork 13
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
Organize repo directory structure with queries folder (?) #10
Comments
I think being able to work with more than one query is a good idea, whether it's extending or overriding. I experimented with something similar in elisp-tree-sitter with some success and felt the benefit first-hand. I also know some folks who do this sort of thing with nvim-treesitter. However, is there a move on the Emacs 29 side to do this kind of thing with their bundled I think as it's still "early stage" for On the subject of externalizing a mode's query... ATM, I think most / all of the queries in (defun ruby-ts--font-lock-settings (language)
"Tree-sitter font-lock settings for Ruby."
(treesit-font-lock-rules
:language language
:feature 'comment
'((comment) @ruby-ts--comment-font-lock)
:language language
:feature 'builtin-variable
`(((global_variable) @var (:match ,ruby-ts--predefined-variables @var)) @font-lock-builtin-face)
;; a lot of stuff elided Note the I think to "externalize", some other arrangement would be neccessary -- e.g. the file could be a I think the reference to Emacs Lisp constructs in a clojure-ts-mode/clojure-ts-mode.el Line 248 in 359521e
Note the |
I'd prefer to keep everything in the same clojure-ts-mode.el file right now, as that is the convention in the Emacs community for these tree-sitter major modes. However, I think the underlying question about how users can extend the mode is a good thing to begin thinking about. As Sogaiu points out, there are some regular expressions that are pulled into the call to For example, instead of (defconst clojure-ts--builtin-symbol-regexp
(eval-and-compile
(concat "^"
(regexp-opt
'("do"
"if"
"let*"
"var"
; ...
)))))
;;;...
(defvar clojure-ts--font-lock-settings
(treesit-font-lock-rules
;; ...
:feature 'builtin
:language 'clojure
`(((list_lit :anchor (sym_lit (sym_name) @font-lock-keyword-face))
(:match ,clojure-ts--builtin-symbol-regexp @font-lock-keyword-face))
;; ...
)) We could instead have something like this (defvar clojure-ts--builtin-symbols
'("do"
"if"
"let*"
"var"
; ...
)
;;;...
(defvar clojure-ts--font-lock-settings
(treesit-font-lock-rules
;; ...
:feature 'builtin
:language 'clojure
`(((list_lit :anchor (sym_lit (sym_name) @font-lock-keyword-face))
(:match ,(concat "^" (regex-opt clojure-ts--builtin-symbols) "$") @font-lock-keyword-face))
;; ...
)) Which would allow users to extend the list of builtin symbols with a call to That change would allow for some extension of raw matching. There are other ways things could be extended as well. New syntax highlighting rules could also be added if we were to define Another customization can be done through customizing the Finally, customization methods should be documented. This is a good thread so I would like to leave it open. The more easily extensible this package is the better. I will work on some of this in the near future. |
I noticed a lot of the tree sitter repos have a dedicated queries folder,
e.g. https://github.com/helix-editor/helix/tree/master/runtime/queries/julia
Just a thought... makes it a bit more modular, and also is a possible avenue for extensions maybe, if you load them from a variety of locations found on the path.
The text was updated successfully, but these errors were encountered: