From 411d6caf060d0bc96097dc39410e8dae8504070b Mon Sep 17 00:00:00 2001 From: Andrew Scott Date: Tue, 9 Jul 2024 08:56:24 -0400 Subject: [PATCH] Various updates, fix cpp treesit for emacs v29.4 --- dot_config/emacs/init.el | 60 ++++++++++++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 14 deletions(-) diff --git a/dot_config/emacs/init.el b/dot_config/emacs/init.el index 01231e8..b9e1ab9 100644 --- a/dot_config/emacs/init.el +++ b/dot_config/emacs/init.el @@ -78,7 +78,7 @@ (add-hook 'after-init-hook #'elpaca-process-queues) (elpaca `(,@elpaca-order)) -;; Unload seq before elpaca build - also see `use-package' declaration for seq below +;; Unload `seq' before build ;; https://github.com/progfolio/elpaca/issues/216#issuecomment-1868444883 (defun +elpaca-unload-seq (e) (and (featurep 'seq) (unload-feature 'seq t)) @@ -198,7 +198,7 @@ )) :hook ((astro-mode c-ts-mode - c++-mode + c++-ts-mode zig-mode) . eglot-ensure)) (use-package elec-pair @@ -278,14 +278,28 @@ (save-place-mode)) (use-package seq - ;; Unload `seq' before elpaca starts building + ;; Unload `seq' before `elpaca' starts building :ensure `(seq :build ,(+elpaca-seq-build-steps))) (use-package simple + :ensure nil + :config (setq-default indent-tabs-mode nil) + :hook ((conf-mode prog-mode) . column-number-mode)) + +(use-package text-mode + :ensure nil + :config (setq-local fill-column 120 + whitespace-style '(face + whitespace-missing-newline-at-eof + space-after-tab + space-before-tab + trailing))) + +(use-package treesit :ensure nil :config - (setq-default indent-tabs-mode nil) - (column-number-mode)) + (push '(c++-mode . c++-ts-mode) major-mode-remap-alist) + (setq treesit-font-lock-level 4)) (use-package whitespace :ensure nil @@ -311,11 +325,18 @@ :custom (esup-depth 0)) ;; Theme +(use-package catppuccin-theme + :config + (setq custom-safe-themes t + catppuccin-flavor 'macchiato) + (catppuccin-reload) + (load-theme 'catppuccin t)) + (use-package everforest :ensure (everforest :host sourcehut :repo "theorytoe/everforest-theme") :config - (setq custom-safe-themes t) - (load-theme 'everforest-hard-dark t) + ;; (setq custom-safe-themes t) + ;; (load-theme 'everforest-hard-dark t) (let ((moody_line (face-attribute 'mode-line :foreground)) (moody_inactive (face-attribute 'mode-line-inactive :background))) (set-face-attribute 'mode-line nil :overline moody_line) @@ -378,6 +399,9 @@ ;; Better undo/redo (use-package undo-tree :defer 3 + :bind (:map undo-tree-map + ("C-z" . undo-tree-undo) + ("C-M-z" . undo-tree-redo)) :config (global-undo-tree-mode) :custom (undo-tree-auto-save-history t) @@ -604,7 +628,7 @@ ("C-c y s" . yas-insert-snippet) ("C-c y v" . yas-visit-snippet-file) :config (yas-reload-all) - :hook (lsp-mode . yas-minor-mode)) + :hook (prog-mode . yas-minor-mode)) (use-package yasnippet-snippets :after (yasnippet)) @@ -614,12 +638,23 @@ ;; Visualize color names (use-package rainbow-mode - :hook ((conf-mode lsp-mode) . rainbow-mode)) + :hook ((conf-mode + prog-mode + toml-ts-mode) . rainbow-mode)) ;; Syntax parsing/highlighting (use-package treesit-auto :defer 1 :config + (setq my-cpp-tsauto-config + (make-treesit-auto-recipe + :lang 'cpp + :ts-mode 'c++-ts-mode + :remap 'c++-mode + :url "https://github.com/tree-sitter/tree-sitter-cpp" + :revision "v0.21.0" + :ext "\\.cpp\\'")) + (add-to-list 'treesit-auto-recipe-list my-cpp-tsauto-config) (treesit-auto-add-to-auto-mode-alist 'all) (global-treesit-auto-mode) :custom @@ -645,12 +680,9 @@ (use-package lsp-mode :hook - ((;; c-ts-mode - ;; c++-ts-mode - csharp-ts-mode + ((csharp-ts-mode go-ts-mode python-ts-mode) . lsp) - ;; zig-mode) . lsp) (lsp-mode . lsp-enable-which-key-integration) :custom (lsp-use-plists t) @@ -739,7 +771,7 @@ ;; C++ (use-package modern-cpp-font-lock - :hook (c++-mode . modern-c++-font-lock-mode)) + :hook (c++-ts-mode . modern-c++-font-lock-mode)) ;; Go (use-package go-mode