This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-10-31
Channels
- # ai (5)
- # announcements (11)
- # beginners (19)
- # biff (1)
- # calva (8)
- # cider (3)
- # clj-kondo (12)
- # clojure (97)
- # clojure-europe (39)
- # clojure-nl (1)
- # clojure-norway (74)
- # clojure-uk (35)
- # clojurescript (8)
- # component (8)
- # conjure (4)
- # cursive (13)
- # data-science (1)
- # datahike (55)
- # datomic (2)
- # emacs (3)
- # etaoin (6)
- # gratitude (1)
- # hoplon (12)
- # hyperfiddle (54)
- # introduce-yourself (1)
- # lsp (70)
- # missionary (40)
- # music (1)
- # off-topic (79)
- # re-frame (78)
- # releases (4)
- # sql (5)
- # squint (9)
- # tree-sitter (4)
- # xtdb (20)
in emacs, I have the following config:
(use-package tree-sitter
:config
;; activate tree-sitter on any buffer containing code for which it has a parser available
(global-tree-sitter-mode)
;; you can easily see the difference tree-sitter-hl-mode makes for python, ts or tsx
;; by switching on and off
(add-hook 'tree-sitter-after-on-hook #'tree-sitter-hl-mode))
this ends up overriding clojure-mode buffers to look almost unhighlighted. Turning off tree-sitter-hl-mode
in the buffer uses the default font-lock settings, which look great.
So three questions:
1. Is there a way I can get the tree-sitter-hl-mode
highlighting to look good?
2. How should I disable that mode in Clojure buffers, if I can't make it look good?
3. I'm guessing that clojure-ts-mode
handles more things like indentation, code navigation? anything else?for (2) I found https://shivjm.blog/tree-sitter-hl-mode-lsp-modes-semantic-highlighting-and-rust-analyzer/ which had this snippet:
(setf tree-sitter-major-mode-language-alist
(cl-remove 'rustic-mode tree-sitter-major-mode-language-alist :key #'car))
which I adapted for clojure-mode:
(use-package tree-sitter
:config
;; activate tree-sitter on any buffer containing code for which it has a parser available
(global-tree-sitter-mode)
(setf tree-sitter-major-mode-language-alist
(cl-remove 'clojure-mode
tree-sitter-major-mode-language-alist :key #'car))
;; you can easily see the difference tree-sitter-hl-mode makes for python, ts or tsx
;; by switching on and off
(add-hook 'tree-sitter-after-on-hook #'tree-sitter-hl-mode))
> I'm guessing that clojure-ts-mode
handles more things like indentation, code navigation? anything else?
fwiw, clojure-ts-mode
is not related to tree-sitter
mode in any way. tree-sitter
is a package that was written before the emacs builtin treesit
package. clojure-ts-mode
uses the builtin. If you want to try it then you don't need to setup tree-sitter
at all. Just clojure-ts-mode
And clojure-ts-mode handles syntax highlighting and indentation. It does not handle code navigation. That is better left to eglot/lsp-mode/cider