こんな感じ.
(add-hook 'c-mode-hook #'eglot-ensure) (add-hook 'c-mode-common-hook #'(lambda () (c-set-style "GNU") (setq c-basic-offset 4) ;; width of indent (setq fill-column 80) (setq-default auto-fill-mode t))) ;; https://emacs.stackexchange.com/questions/48500/how-to-clang-format-the-current-buffer-on-save (defun clang-format-save-hook-for-this-buffer () "Create a buffer local save hook." (add-hook 'before-save-hook (lambda () (when (locate-dominating-file "." ".clang-format") (clang-format-buffer)) ;; Continue to save. nil) nil ;; Buffer local hook. t)) ;; Run this for each mode you want to use the hook. (add-hook 'c-mode-hook (lambda () (clang-format-save-hook-for-this-buffer)))
clangdを動かす設定はこちらの記事にて.