Skip to content
This repository has been archived by the owner. It is now read-only.
[DEPRECATED] Support for clangd in lsp-mode.
Branch: master
Clone or download
Latest commit 27b5951 Jan 11, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Prepare for archiving this repository. Jan 10, 2019 Prepare for archiving this repository. Jan 10, 2019
LICENSE Initial commit. Apr 28, 2017 Update Jan 10, 2019
lsp-clangd.el Fixed a typo Aug 28, 2018


Support for 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 using clangd as the language server.

Note that clangd is still a work-in-progress. See the recent commits. It is highly recommended that you run the latest version of clangd to get the best behavior.


Installing clangd

Since 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 lsp-clangd-executable to /usr/local/opt/llvm/bin/clangd.

brew install llvm --HEAD

Enabling lsp-clangd

lsp-clangd is available from MELPA.

By default, lsp-clangd searches for clangd on the executable search path. The location of clangd can be changed by customizing the variable lsp-clang-executable.

Using standard Emacs Lisp

Install lsp-mode via some suitable method and clone this repository to a suitable path, e.g. <path-to-lsp-clangd>.

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))

See lsp-clangd-executable to customize the path to clangd.

Using use-package

(use-package lsp-clangd
  ((c-mode . lsp-clangd-c-enable)
   (c++-mode . lsp-clangd-c++-enable)
   (objc-mode . lsp-clangd-objc-enable)))

Advanced Configuration

The following configuration customizes the location of the clangd executable for macOS.

(use-package lsp-clangd
  (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))
You can’t perform that action at this time.