Home Gen38 @ 2025-08-17-14:42 by jonas@monolith

This commit is contained in:
2025-09-21 16:40:28 +02:00
parent f3550e65b0
commit 1dbb0cfd1d
3 changed files with 71 additions and 71 deletions

View File

@@ -165,71 +165,71 @@
:server-id 'nixd)))
;;Use TS-modes
(after! treesit
(load! "packages/treesit-docgen.el")
(setq treesit-font-lock-level 4))
(defconst mode-ts-mode-mapping
'((python-mode . python-ts-mode)
(css-mode . css-ts-mode)
(typescript-mode . typescript-ts-mode)
(js-mode . typescript-ts-mode)
(js2-mode . typescript-ts-mode)
(c-mode . c-ts-mode)
(c++-mode . c++-ts-mode)
(c-or-c++-mode . c-or-c++-ts-mode)
(bash-mode . bash-ts-mode)
(css-mode . css-ts-mode)
(json-mode . json-ts-mode)
(js-json-mode . json-ts-mode)
(sh-mode . bash-ts-mode)
(c-or-c++-mode . c-or-c++-ts-mode)
(sh-base-mode . bash-ts-mode))
"A map from original mode to the ts-mode")
(use-package! treesit
:defer t
:mode (("\\.tsx\\'" . tsx-ts-mode)
("\\.js\\'" . typescript-ts-mode)
("\\.mjs\\'" . typescript-ts-mode)
("\\.mts\\'" . typescript-ts-mode)
("\\.cjs\\'" . typescript-ts-mode)
("\\.ts\\'" . typescript-ts-mode)
("\\.jsx\\'" . tsx-ts-mode)
("\\.json\\'" . json-ts-mode)
("\\.Dockerfile\\'" . dockerfile-ts-mode)
("\\.c\\'" . c-ts-mode)
("\\.h\\'" . c-or-c++-ts-mode)
("\\.cpp\\'" . c++-ts-mode)
("\\.py\\'" . python-ts-mode)
("\\.sh\\'" . bash-ts-mode)
)
:preface
(dolist (mapping mode-ts-mode-mapping)
(add-to-list 'major-mode-remap-alist mapping)))
;; Integrate with legacy tree-sitter mode
(use-package! tree-sitter
:hook ((c++-ts-mode . tree-sitter-mode)
(c-ts-mode . tree-sitter-mode)
(c-or-c++-ts-mode . tree-sitter-mode)
(python-ts-mode . tree-sitter-mode)
(css-ts-mode . tree-sitter-mode)
(typescript-ts-mode . tree-sitter-mode)
(js-ts-mode . tree-sitter-mode)
(bash-ts-mode . tree-sitter-mode)
(json-ts-mode . tree-sitter-mode)
(tree-sitter-mode . tree-sitter-hl-mode))
:config
(let (result)
(dolist (mapping tree-sitter-major-mode-language-alist)
(let* ((pre-mode (car mapping))
(ts-lang (cdr mapping))
(post-mode (cdr (assoc pre-mode mode-ts-mode-mapping))))
(when post-mode
(push (cons post-mode ts-lang) result))))
(dolist (mapping result)
(add-to-list 'tree-sitter-major-mode-language-alist mapping))))
;;(after! treesit
;; (load! "packages/treesit-docgen.el")
;; (setq treesit-font-lock-level 4))
;;
;;(defconst mode-ts-mode-mapping
;; '((python-mode . python-ts-mode)
;; (css-mode . css-ts-mode)
;; (typescript-mode . typescript-ts-mode)
;; (js-mode . typescript-ts-mode)
;; (js2-mode . typescript-ts-mode)
;; (c-mode . c-ts-mode)
;; (c++-mode . c++-ts-mode)
;; (c-or-c++-mode . c-or-c++-ts-mode)
;; (bash-mode . bash-ts-mode)
;; (css-mode . css-ts-mode)
;; (json-mode . json-ts-mode)
;; (js-json-mode . json-ts-mode)
;; (sh-mode . bash-ts-mode)
;; (c-or-c++-mode . c-or-c++-ts-mode)
;; (sh-base-mode . bash-ts-mode))
;; "A map from original mode to the ts-mode")
;;
;;(use-package! treesit
;; :defer t
;; :mode (("\\.tsx\\'" . tsx-ts-mode)
;; ("\\.js\\'" . typescript-ts-mode)
;; ("\\.mjs\\'" . typescript-ts-mode)
;; ("\\.mts\\'" . typescript-ts-mode)
;; ("\\.cjs\\'" . typescript-ts-mode)
;; ("\\.ts\\'" . typescript-ts-mode)
;; ("\\.jsx\\'" . tsx-ts-mode)
;; ("\\.json\\'" . json-ts-mode)
;; ("\\.Dockerfile\\'" . dockerfile-ts-mode)
;; ("\\.c\\'" . c-ts-mode)
;; ("\\.h\\'" . c-or-c++-ts-mode)
;; ("\\.cpp\\'" . c++-ts-mode)
;; ("\\.py\\'" . python-ts-mode)
;; ("\\.sh\\'" . bash-ts-mode)
;; )
;; :preface
;; (dolist (mapping mode-ts-mode-mapping)
;; (add-to-list 'major-mode-remap-alist mapping)))
;;
;;;; Integrate with legacy tree-sitter mode
;;(use-package! tree-sitter
;; :hook ((c++-ts-mode . tree-sitter-mode)
;; (c-ts-mode . tree-sitter-mode)
;; (c-or-c++-ts-mode . tree-sitter-mode)
;; (python-ts-mode . tree-sitter-mode)
;; (css-ts-mode . tree-sitter-mode)
;; (typescript-ts-mode . tree-sitter-mode)
;; (js-ts-mode . tree-sitter-mode)
;; (bash-ts-mode . tree-sitter-mode)
;; (json-ts-mode . tree-sitter-mode)
;; (tree-sitter-mode . tree-sitter-hl-mode))
;; :config
;; (let (result)
;; (dolist (mapping tree-sitter-major-mode-language-alist)
;; (let* ((pre-mode (car mapping))
;; (ts-lang (cdr mapping))
;; (post-mode (cdr (assoc pre-mode mode-ts-mode-mapping))))
;; (when post-mode
;; (push (cons post-mode ts-lang) result))))
;; (dolist (mapping result)
;; (add-to-list 'tree-sitter-major-mode-language-alist mapping))))
;; Integrate with lsp-mode