I would like to enable lsp-headerline-breadcrumb-mode in every buffer where lsp-mode is active.

I'd know how to do it for every mode, for example

(use-package go-mode
  :ensure t
  (add-hook 'go-mode-hook (lambda ()
                            ;; other stuff
                            (lsp-headerline-breadcrumb-mode t)

But I fail to do it for every buffer with lsp-mode ... With this, lsp-mode doesn't work at all:

(use-package lsp-mode
  :ensure t
  :commands (lsp lsp-deferred)
  (go-mode . lsp-deferred)
  (python-mode . (lambda ()
                   (require 'lsp-python-ms)
  :config (setq
           lsp-diagnostic-package :auto
           ;; stuff deleted
           lsp-print-performance nil
  (add-hook 'lsp-mode-hook (lambda ()
                            ((lsp-headerline-breadcrumb-mode t))

2 Answers 2


There is a variable you can customize that automatically enables the headerline breadcrumb mode whenever lsp-mode is active. Try something like:

(use-package lsp-mode
  (lsp-headerline-breadcrumb-enable t))

The following snippet works for me, it enables breadcrumbs in all modes where lsp is active.

(require 'package)
(setq package-user-dir (expand-file-name "~/.emacs.d/elpa/")
      package-enable-at-startup nil)
(add-to-list 'package-archives
             '("melpa" . "https://melpa.org/packages/") t)

(unless (package-installed-p 'use-package)
  (package-install 'use-package))
  (require 'use-package))

(add-hook 'c++-mode-hook #'lsp)
(add-hook 'python-mode-hook #'lsp)

(use-package lsp-mode
  :ensure t
  :commands (lsp lsp-deferred)
  :hook ((lsp-mode . lsp-enable-which-key-integration)
         (lsp-managed-mode . lsp-modeline-diagnostics-mode)
         (lsp-mode . lsp-headerline-breadcrumb-mode)
         (lsp-mode . lsp-modeline-code-actions-mode)))

Here I have only included c++-mode and python-mode. I usually prefer to enable lsp from the corresponding major mode use-package declarations.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.