Skip to content

Commit

Permalink
eglot: Allow customizing clangd args
Browse files Browse the repository at this point in the history
  • Loading branch information
mohkale committed Jul 5, 2024
1 parent bfc6874 commit c86caf4
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions init.org
Original file line number Diff line number Diff line change
Expand Up @@ -19574,6 +19574,32 @@ Welcome to my personal Emacs configuration 😎.
:hook (c++-mode . modern-c++-font-lock-mode))
#+END_SRC

*** Clangd :lsp:
#+begin_src emacs-lisp
(defvar c-mode-clangd-args+ '("--clang-tidy")
"Command line options to pass to clangd for lsp.")

(defvaralias 'c-mode-clangd-compile-commands-dir+ '+cmake-build-directory
"Customizable path to directory containing compile_commands.json")

(defun c-mode-clangd-args+ ()
`(,@c-mode-clangd-args+
,@(when-let ((dir c-mode-clangd-compile-commands-dir+))
(list "--compile-commands-dir" dir))))
#+end_src

#+begin_src emacs-lisp :tangle (package-lisp! +lang-cpp c eglot)
(use-package eglot
:preface
(defun eglot-clangd-command+ (&optional _interactive _project)
`("clangd" ,@(c-mode-clangd-args+)))

:config
(push `((c-mode c-ts-mode c++-mode c++-ts-mode objc-mode)
. ,#'eglot-clangd-command+)
eglot-server-programs))
#+end_src

*** Appendix
#+begin_src emacs-lisp
(provide '+lang-cpp)
Expand Down

0 comments on commit c86caf4

Please sign in to comment.