diff --git a/modules/home/doom/static/config.el b/modules/home/doom/static/config.el index 3696100..9e34430 100644 --- a/modules/home/doom/static/config.el +++ b/modules/home/doom/static/config.el @@ -150,6 +150,27 @@ (set-formatter! 'alejandra '("alejandra" "--quiet") :modes '(nix-mode)) ;;Use TS-modes +(after! treesit + (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) @@ -168,24 +189,19 @@ ("\\.sh\\'" . bash-ts-mode) ) :preface - (dolist (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))) + (dolist (mapping 'mode-ts-mode-mapping) (add-to-list 'major-mode-remap-alist mapping))) +(after! tree-sitter + (dolist (mapping 'tree-sitter-major-mode-language-alist) + (let* ((pre-mode (car mapping)) + (post-mode (cdr mapping)) + (ts-lang (cdr (rassoc pre-mode 'mode-ts-mode-mapping)))) + (when ts-pre-mode-lang + (add-to-list 'tree-sitter-major-mode-language-alist (post-mode . ts-lang)))))) + + + (use-package lsp-mode :defer t :hook ((lsp-mode . lsp-diagnostics-mode)