doom

My literate doom emacs config
git clone https://github.com/michaelneuper/doom.git
Files | Log | Refs

commit 50e0f8541e18143109aafde0cadae0a7ee7647eb
parent 20fead4dd63c974098afc1cf2ff66f2e56f6f1d1
Author: Michael Neuper <michael@michaelneuper.com>
Date:   Sat, 16 May 2026 11:37:35 +0200

add snippets for .clang-format

Diffstat:
Mconfig.org | 31++++++++++++-------------------
Minit.el | 2+-
Asnippets/yaml-mode/clang-format | 15+++++++++++++++
Asnippets/yaml-ts-mode/clang-format | 15+++++++++++++++
4 files changed, 43 insertions(+), 20 deletions(-)

diff --git a/config.org b/config.org @@ -1148,40 +1148,24 @@ Create some keybindings for commonly used commands. *** cc Configure =cc-mode=. #+begin_src emacs-lisp -(after! cc-mode - (setf (alist-get 'c-mode c-default-style) "k&r") +(after! (cc-mode c-ts-mode) (setq c-basic-offset 4 c-doc-comment-style '((c-mode . doxygen) (c-ts-mode . doxygen)) - whitespace-style '(face trailing lines-tail empty)) - indent-tabs-mode t) + whitespace-style '(face trailing lines-tail empty))) + (after! eglot (if (featurep :system 'macos) (add-to-list 'eglot-server-programs '((c-mode c++-mode cc-mode c-ts-mode) . ("/opt/homebrew/opt/llvm/bin/clangd" "-j=3" "--clang-tidy"))))) -(add-hook! '(c-mode-common-hook c-ts-mode-hook) - (c-setup-doc-comment-style)) - (add-hook! '(c-mode-hook c-ts-mode-hook) (unless (or (file-exists-p "makefile") (file-exists-p "Makefile")) (setq-local compile-command "cc -Wall -o main main.c"))) #+end_src -Make =#ifdef 0= blocks appear as comments. -#+begin_src emacs-lisp -(add-hook! '(c-mode-hook c-ts-mode-hook) - (defun +c-hideifdef-init () - "Enable hide-ifdef-mode with shadowing, auto-hiding, and hidden directive lines." - (hide-ifdef-mode 1) - (setq-local hide-ifdef-shadow t - hide-ifdef-initially t - hide-ifdef-lines t) - (hide-ifdefs))) -#+end_src - Fix issue where two new lines are inserted after ={=. #+begin_src emacs-lisp (after! eglot @@ -1190,6 +1174,15 @@ Fix issue where two new lines are inserted after ={=. ;; remove eglot’s post-self-insert-hook in current buffer (remove-hook 'post-self-insert-hook #'eglot--post-self-insert-hook t)))) #+end_src + +Enable =yaml-ts-mode= in =.clang-format= files. +#+begin_src emacs-lisp +(add-to-list 'auto-mode-alist + (cons "\\.clang-format\\'" + (if (modulep! :lang yaml +tree-sitter) + 'yaml-ts-mode + 'yaml-mode))) +#+end_src *** java Set indentation level for =java-mode= to 2. #+begin_src emacs-lisp diff --git a/init.el b/init.el @@ -162,7 +162,7 @@ swift ; who asked for emoji variables? ;;terra ; Earth and Moon in alignment for performance. (web +tree-sitter) ; the tubes - yaml ; JSON, but readable + (yaml +tree-sitter) ; JSON, but readable (zig +lsp +tree-sitter) ; C, but simpler :email diff --git a/snippets/yaml-mode/clang-format b/snippets/yaml-mode/clang-format @@ -0,0 +1,15 @@ +# -*- mode: snippet -*- +# name: .clang-format +# key: clang-format +# condition: (string-match-p "\\.clang-format" (buffer-file-name)) +# -- +BasedOnStyle: LLVM +IndentWidth: 4 +TabWidth: 4 +UseTab: Never +IndentCaseLabels: true +AlignConsecutiveDeclarations: true +AlignTrailingComments: true +AllowShortIfStatementsOnASingleLine: Always +InsertNewlineAtEOF: true +$0 diff --git a/snippets/yaml-ts-mode/clang-format b/snippets/yaml-ts-mode/clang-format @@ -0,0 +1,15 @@ +# -*- mode: snippet -*- +# name: .clang-format +# key: clang-format +# condition: (string-match-p "\\.clang-format" (buffer-file-name)) +# -- +BasedOnStyle: LLVM +IndentWidth: 4 +TabWidth: 4 +UseTab: Never +IndentCaseLabels: true +AlignConsecutiveDeclarations: true +AlignTrailingComments: true +AllowShortIfStatementsOnASingleLine: Always +InsertNewlineAtEOF: true +$0