THIS REPOSITORY IS DEPRECATED AND SHOULD NO LONGER BE USED!
clangd is now configured and enabled in
lsp-mode by default. The normal Emacs customization interface can be used for customizing the location of the
clangd executable and other configurable options.
A configuration for an Emacs LSP client for Clang-based languages
clangd as the
clangd is still a work-in-progress. See the recent
It is highly recommended that you run the latest version of
to get the best behavior.
clangd is part of
clang-tools-extra since Clang 5, it can be
installed by all the same methods for installing Clang 5 or later.
With macOS, the easiest way is to install via Homebrew. Note that
this recipe is keg-only, so you must customize
brew install llvm --HEAD
lsp-clangd is available from MELPA.
lsp-clangd searches for
clangd on the executable
search path. The location of
clangd can be changed by customizing
Using standard Emacs Lisp
lsp-mode via some suitable method and clone this repository
to a suitable path, e.g.
The following Emacs Lisp will enable lsp-clangd after lsp-mode is loaded.
(add-to-list 'load-path "<path-to-lsp-clangd>") (with-eval-after-load 'lsp-mode (require 'lsp-clangd) (add-hook 'c-mode-hook #'lsp-clangd-c-enable) (add-hook 'c++-mode-hook #'lsp-clangd-c++-enable) (add-hook 'objc-mode-hook #'lsp-clangd-objc-enable))
lsp-clangd-executable to customize the path to clangd.
(use-package lsp-clangd :load-path "<path-to-lsp-clangd>" :hook ((c-mode . lsp-clangd-c-enable) (c++-mode . lsp-clangd-c++-enable) (objc-mode . lsp-clangd-objc-enable)))
The following configuration customizes the location of the
executable for macOS.
(use-package lsp-clangd :load-path "<path-to-lsp-clangd>" :init (when (equal system-type 'darwin) (setq lsp-clangd-executable "/usr/local/opt/llvm/bin/clangd")) (add-hook 'c-mode-hook #'lsp-clangd-c-enable) (add-hook 'c++-mode-hook #'lsp-clangd-c++-enable) (add-hook 'objc-mode-hook #'lsp-clangd-objc-enable))