feat(cc): redo c++ configuration with clangd and modularity
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
(load! "security")
|
(load! "security")
|
||||||
(load! "core")
|
(load! "core")
|
||||||
(load! "development/lsp")
|
(load! "development/lsp")
|
||||||
|
(load! "development/cpp")
|
||||||
(load! "development/nix")
|
(load! "development/nix")
|
||||||
(load! "development/misc")
|
(load! "development/misc")
|
||||||
(load! "org")
|
(load! "org")
|
||||||
|
|||||||
@@ -0,0 +1,43 @@
|
|||||||
|
;;; development/cpp.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
|
;; 4. Optional: Fine-tuning Clangd
|
||||||
|
;; These arguments are passed directly to the clangd binary.
|
||||||
|
(setq lsp-clients-clangd-args
|
||||||
|
'("-j=4"
|
||||||
|
"--background-index"
|
||||||
|
"--clang-tidy"
|
||||||
|
"--completion-style=detailed"
|
||||||
|
"--header-insertion=never"
|
||||||
|
"--header-insertion-decorators=0"))
|
||||||
|
|
||||||
|
(after! lsp-clangd
|
||||||
|
(set-lsp-priority! 'clangd 2)) ; Ensure clangd is preferred over ccls
|
||||||
|
|
||||||
|
;; Formatting for c++
|
||||||
|
;; This tells Doom to use the LSP server (clangd) for formatting instead of
|
||||||
|
;; a separate clang-format call via apheleia.
|
||||||
|
(setq-hook! '(c-mode-hook c++-mode-hook) +format-with-lsp t)
|
||||||
|
|
||||||
|
;; Formatting as I type
|
||||||
|
;; This enables real-time formatting as you type trigger characters like ; or }
|
||||||
|
(after! lsp-mode
|
||||||
|
(setq lsp-enable-on-type-formatting t))
|
||||||
|
|
||||||
|
;; Ensure cc-mode settings align with clangd/clang-format
|
||||||
|
;; While clangd handles most things, basic Emacs indentation settings are
|
||||||
|
;; still useful as a fallback or for initial indentation.
|
||||||
|
(after! cc-mode
|
||||||
|
(setq-default c-basic-offset 2)
|
||||||
|
(c-add-style "doom-cpp"
|
||||||
|
'("llvm"
|
||||||
|
(c-basic-offset . 2)
|
||||||
|
(c-offsets-alist . ((innamespace . 0)
|
||||||
|
(access-label . -)
|
||||||
|
(arglist-intro . +)
|
||||||
|
(arglist-cont-nonempty . +)))))
|
||||||
|
(add-hook! '(c-mode-hook c++-mode-hook)
|
||||||
|
(c-set-style "doom-cpp")))
|
||||||
|
|
||||||
|
;; Add C++ documentation support
|
||||||
|
(set-docsets! 'c++-mode "C++")
|
||||||
|
(set-docsets! 'c-mode "C")
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
;;; development/cpp.el -*- lexical-binding: t; -*-
|
||||||
|
|
||||||
|
;; 4. Optional: Fine-tuning Clangd
|
||||||
|
;; These arguments are passed directly to the clangd binary.
|
||||||
|
(setq lsp-clients-clangd-args
|
||||||
|
'("-j=4"
|
||||||
|
"--background-index"
|
||||||
|
"--clang-tidy"
|
||||||
|
"--completion-style=detailed"
|
||||||
|
"--header-insertion=never"
|
||||||
|
"--header-insertion-decorators=0"))
|
||||||
|
|
||||||
|
(after! lsp-clangd
|
||||||
|
(set-lsp-priority! 'clangd 2)) ; Ensure clangd is preferred over ccls
|
||||||
|
|
||||||
|
;; Formatting for c++
|
||||||
|
;; This tells Doom to use the LSP server (clangd) for formatting instead of
|
||||||
|
;; a separate clang-format call via apheleia.
|
||||||
|
(setq-hook! '(c-mode-hook c++-mode-hook) +format-with-lsp t)
|
||||||
|
|
||||||
|
;; Formatting as I type
|
||||||
|
;; This enables real-time formatting as you type trigger characters like ; or }
|
||||||
|
(after! lsp-mode
|
||||||
|
(setq lsp-enable-on-type-formatting t))
|
||||||
|
|
||||||
|
;; Ensure cc-mode settings align with clangd/clang-format
|
||||||
|
;; While clangd handles most things, basic Emacs indentation settings are
|
||||||
|
;; still useful as a fallback or for initial indentation.
|
||||||
|
(after! cc-mode
|
||||||
|
(setq-default c-basic-offset 2)
|
||||||
|
(c-add-style "doom-cpp"
|
||||||
|
'("llvm"
|
||||||
|
(c-basic-offset . 2)
|
||||||
|
(c-offsets-alist . ((innamespace . 0)
|
||||||
|
(access-label . -)
|
||||||
|
(arglist-intro . +)
|
||||||
|
(arglist-cont-nonempty . +)))))
|
||||||
|
(add-hook! '(c-mode-hook c++-mode-hook)
|
||||||
|
(c-set-style "doom-cpp")))
|
||||||
|
|
||||||
|
;; Add C++ documentation support
|
||||||
|
(set-docsets! 'c++-mode "C++")
|
||||||
|
(set-docsets! 'c-mode "C")
|
||||||
@@ -37,14 +37,8 @@
|
|||||||
corfu-annotate-max-width 50)
|
corfu-annotate-max-width 50)
|
||||||
)
|
)
|
||||||
|
|
||||||
;; If using LSP, configure to show more details
|
|
||||||
(after! lsp-mode
|
(after! lsp-mode
|
||||||
(setq lsp-completion-show-detail t ; Show method signatures
|
(setq lsp-completion-show-detail t ; Show method signatures
|
||||||
lsp-completion-show-kind t ; Show completion item kind
|
lsp-completion-show-kind t ; Show completion item kind
|
||||||
lsp-completion-show-label-description t ; Show more details in label
|
lsp-completion-show-label-description t ; Show more details in label
|
||||||
))
|
))
|
||||||
|
|
||||||
(after! lsp-clangd
|
|
||||||
(setq lsp-clients-clangd-executable "clangd")
|
|
||||||
(setq lsp-clients--clangd-default-executable "clangd")
|
|
||||||
(setq lsp-clangd-binary-path "clangd"))
|
|
||||||
|
|||||||
@@ -115,7 +115,7 @@
|
|||||||
:lang
|
:lang
|
||||||
;;agda ; types of types of types of types...
|
;;agda ; types of types of types of types...
|
||||||
;;beancount ; mind the GAAP
|
;;beancount ; mind the GAAP
|
||||||
(cc +lsp) ; C > C++ == 1
|
(cc +lsp +tree-sitter) ; C > C++ == 1
|
||||||
;;clojure ; java with a lisp
|
;;clojure ; java with a lisp
|
||||||
;;common-lisp ; if you've seen one lisp, you've seen them all
|
;;common-lisp ; if you've seen one lisp, you've seen them all
|
||||||
;;coq ; proofs-as-programs
|
;;coq ; proofs-as-programs
|
||||||
|
|||||||
Reference in New Issue
Block a user