|
1261 | 1261 | ;;; Treesitter:
|
1262 | 1262 |
|
1263 | 1263 | (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)) |
1270 | 1354 |
|
1271 | 1355 | ;;; vertico:
|
1272 | 1356 |
|
|
0 commit comments