Skip to content

Commit a7b1236

Browse files
committed
Replace treesit-auto with manual treesit config
I ran into some problems after upgrading to Emacs 30.1.
1 parent bfcfa40 commit a7b1236

File tree

2 files changed

+90
-7
lines changed

2 files changed

+90
-7
lines changed

.emacs

+90-6
Original file line numberDiff line numberDiff line change
@@ -1261,12 +1261,96 @@
12611261
;;; Treesitter:
12621262

12631263
(use-package
1264-
treesit-auto
1265-
:custom (treesit-auto-install 'prompt)
1266-
:config (treesit-auto-add-to-auto-mode-alist 'all)
1267-
(setq auto-mode-alist
1268-
(remove '("\\.rs\\'" . rust-ts-mode) auto-mode-alist))
1269-
(delete 'rust treesit-auto-langs) (global-treesit-auto-mode))
1264+
treesit
1265+
:straight (treesit :type built-in)
1266+
:mode
1267+
(("\\.tsx\\'" . tsx-ts-mode)
1268+
("\\.go\\'" . go-ts-mode)
1269+
("\\.js\\'" . typescript-ts-mode)
1270+
("\\.mjs\\'" . typescript-ts-mode)
1271+
("\\.mts\\'" . typescript-ts-mode)
1272+
("\\.cjs\\'" . typescript-ts-mode)
1273+
("\\.ts\\'" . typescript-ts-mode)
1274+
("\\.jsx\\'" . tsx-ts-mode)
1275+
("\\.json\\'" . json-ts-mode)
1276+
("\\.yaml\\'" . yaml-ts-mode)
1277+
("\\.css\\'" . css-ts-mode)
1278+
("\\.yml\\'" . yaml-ts-mode))
1279+
:preface
1280+
(defun os/setup-install-grammars ()
1281+
"Install Tree-sitter grammars if they are absent."
1282+
(interactive)
1283+
(dolist
1284+
(grammar
1285+
'((css
1286+
.
1287+
("https://github.com/tree-sitter/tree-sitter-css"
1288+
"v0.23.2"))
1289+
(bash
1290+
"https://github.com/tree-sitter/tree-sitter-bash"
1291+
"v0.23.3")
1292+
(html
1293+
.
1294+
("https://github.com/tree-sitter/tree-sitter-html"
1295+
"v0.23.2"))
1296+
(javascript
1297+
.
1298+
("https://github.com/tree-sitter/tree-sitter-javascript"
1299+
"v0.23.1"
1300+
"src"))
1301+
(json
1302+
.
1303+
("https://github.com/tree-sitter/tree-sitter-json"
1304+
"v0.24.8"))
1305+
(rust
1306+
.
1307+
("https://github.com/tree-sitter/tree-sitter-rust"
1308+
"v0.23.3"))
1309+
(go
1310+
"https://github.com/tree-sitter/tree-sitter-go" "v0.23.4")
1311+
(make "https://github.com/alemuller/tree-sitter-make")
1312+
(elisp "https://github.com/Wilfred/tree-sitter-elisp")
1313+
(toml "https://github.com/tree-sitter/tree-sitter-toml")
1314+
(tsx
1315+
.
1316+
("https://github.com/tree-sitter/tree-sitter-typescript"
1317+
"v0.23.2"
1318+
"tsx/src"))
1319+
(typescript
1320+
.
1321+
("https://github.com/tree-sitter/tree-sitter-typescript"
1322+
"v0.23.2"
1323+
"typescript/src"))
1324+
(yaml
1325+
.
1326+
("https://github.com/ikatyang/tree-sitter-yaml"
1327+
"v0.5.0"))))
1328+
(add-to-list 'treesit-language-source-alist grammar)
1329+
;; Only install `grammar' if we don't already have it
1330+
;; installed. However, if you want to *update* a grammar then
1331+
;; this obviously prevents that from happening.
1332+
(unless (treesit-language-available-p (car grammar))
1333+
(treesit-install-language-grammar (car grammar)))))
1334+
1335+
;; Optional, but recommended. Tree-sitter enabled major modes are
1336+
;; distinct from their ordinary counterparts.
1337+
;;
1338+
;; You can remap major modes with `major-mode-remap-alist'. Note
1339+
;; that this does *not* extend to hooks! Make sure you migrate them
1340+
;; also
1341+
(dolist (mapping
1342+
'((css-mode . css-ts-mode)
1343+
(typescript-mode . typescript-ts-mode)
1344+
(js-mode . typescript-ts-mode)
1345+
(js2-mode . typescript-ts-mode)
1346+
(bash-mode . bash-ts-mode)
1347+
(css-mode . css-ts-mode)
1348+
(json-mode . json-ts-mode)
1349+
(js-json-mode . json-ts-mode)
1350+
(sh-mode . bash-ts-mode)
1351+
(sh-base-mode . bash-ts-mode)))
1352+
(add-to-list 'major-mode-remap-alist mapping))
1353+
:config (os/setup-install-grammars))
12701354

12711355
;;; vertico:
12721356

lockfile.el

-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@
133133
("toml-mode.el" . "f6c61817b00f9c4a3cab1bae9c309e0fc45cdd06")
134134
("transient" . "680f079b5e2b67ef5e904168a27680cbf6831b6a")
135135
("treemacs" . "df26b6ab9a0f467e5ff99f7ed97551ccf756e06c")
136-
("treesit-auto" . "016bd286a1ba4628f833a626f8b9d497882ecdf3")
137136
("use-package" . "a6e856418d2ebd053b34e0ab2fda328abeba731c")
138137
("vertico" . "e0bb699ebf9e41893dbd19e7d19381fa73c08bc1")
139138
("vundo" . "e7cfd047bbc28b1b107688392f7e97f78fd030d5")

0 commit comments

Comments
 (0)