clojure-emacs / clojure-emacs/clojure-ts-mode
set `clojure-ts-align-forms-automatically` not working when hit TAB in `clojure-ts-clojurescript-mode`
- Dominant language
- Emacs Lisp
- Stars
- 188
- Forks
- 21
- Avg merge
- 12m
- Merged PRs (30d)
- 1
Description
## Expected behavior
- set `clojure-ts-align-forms-automatically` to `t`.
- select the region of a map, hit TAB. The map is indented
```clojure
;;before
(def my-map
{:a-key 1
:other-key 2})
;; after hitting TAB
(def my-map
{:a-key 1
:other-key 2})
```
## Actual behavior
the map is not indented
## Steps to reproduce the problem
- set `clojure-ts-align-forms-automatically` to `t`.
- create a `core.cljs` file, add the following content
```clojure
(def my-map
{:a-key 1
:other-key 2})
```
- select the region of a map, hit TAB.
## Environment & Version information
### clojure-ts-mode version
clojure-ts-mode (version 0.6.0)
### tree-sitter-clojure grammar version
unstable-20250526
### Emacs version
GNU Emacs 30.2 (build 1, aarch64-apple-darwin24.6.0, NS appkit-2575.70 Version 15.7.5 (Build 24G624))
### Operating system
MacOS 15.7.5 (24G624)
---
The issue I've found is that `clojure-ts-clojurescript-mode` calls `(treesit-major-mode-setup)` a second time
(when `clojure-ts-clojurescript-use-js-parser` is non-nil and the javascript
tree-sitter grammar is available), which resets `indent-region-function` back to
`#'treesit-indent-region`, overwriting the `#'clojure-ts-indent-region` that the
parent mode (`clojure-ts-mode`) set for automatic alignment.
- `clojure-ts-mode` set the indent-region-function
https://github.com/clojure-emacs/clojure-ts-mode/blob/main/clojure-ts-mode.el#L3238-L3243
- recall (treesit-major-mode-setup) in `clojure-ts-clojurescript-mode`
https://github.com/clojure-emacs/clojure-ts-mode/blob/main/clojure-ts-mode.el#L3277-L3289
I think `jank-mode` also has this issue. The simplest solution I think is to set indent-region-function after every `(treesit-major-mode-setup)`, but would like to here what you think.
Contributor guide
Assessment
This issue has not been assessed yet.