mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-01 12:17:25 -05:00
refactor(cc): configure clang-format in :editor format
These should be upstreamed.
This commit is contained in:
@ -79,6 +79,12 @@ This is controlled by `+format-on-save-disabled-modes'."
|
||||
;; `+format-with-lsp-mode' in the appropriate modes.
|
||||
(add-to-list 'apheleia-formatters '(lsp . +format-lsp-buffer))
|
||||
|
||||
;; Use clang-format for cuda and protobuf files.
|
||||
(add-to-list 'apheleia-mode-alist '(cuda-mode . clang-format))
|
||||
(add-to-list 'apheleia-mode-alist '(protobuf-mode . clang-format))
|
||||
(add-to-list 'apheleia-formatters-mode-extension-assoc '(cuda-mode . ".cu"))
|
||||
(add-to-list 'apheleia-formatters-mode-extension-assoc '(protobuf-mode . ".proto"))
|
||||
|
||||
;; Apheleia's default clang-format config doesn't respect `c-basic-offset', so
|
||||
;; force it to in the absence of a .clang-format file.
|
||||
(setf (alist-get 'clang-format apheleia-formatters)
|
||||
|
@ -32,17 +32,6 @@ This is ignored by ccls.")
|
||||
(set-docsets! 'c-mode "C")
|
||||
(set-docsets! 'c++-mode "C++" "Boost")
|
||||
(set-electric! '(c-mode c++-mode objc-mode java-mode) :chars '(?\n ?\} ?\{))
|
||||
(set-formatter!
|
||||
'clang-format
|
||||
'("clang-format"
|
||||
"-assume-filename"
|
||||
(or (buffer-file-name)
|
||||
(cdr (assoc major-mode
|
||||
'((c-mode . ".c")
|
||||
(c++-mode . ".cpp")
|
||||
(cuda-mode . ".cu")
|
||||
(protobuf-mode . ".proto"))))))
|
||||
:modes '(c-mode c++-mode protobuf-mode cuda-mode))
|
||||
(set-rotate-patterns! 'c++-mode
|
||||
:symbols '(("public" "protected" "private")
|
||||
("class" "struct")))
|
||||
|
Reference in New Issue
Block a user