feat(format): add :lang cc formatter

This commit is contained in:
Ellis Kenyő 2022-08-16 08:17:51 +01:00 committed by Ellis Kenyo
parent cd79edf134
commit bfb963f2f3
No known key found for this signature in database
GPG key ID: 298BE5D997EBAA02
2 changed files with 16 additions and 0 deletions

View file

@ -48,6 +48,18 @@ 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 ?\} ?\{))
(when (executable-find "clang-format")
(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")))

View file

@ -26,3 +26,7 @@
;; glslangValidator
(unless (executable-find "glslangValidator")
(warn! "Couldn't find glslangValidator. GLSL code completion is disabled")))
(when (modulep! :editor format)
(unless (executable-find "clang-format")
(warn! "Couldn't find clang-format. Formatting will be disabled.")))