1

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
  :config
  (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)
  :hook
  (go-mode . lsp-deferred)
  (python-mode . (lambda ()
                   (require 'lsp-python-ms)
                   (lsp-deferred)))
  :config (setq
           lsp-diagnostic-package :auto
           ;; stuff deleted
           lsp-print-performance nil
           )
  (add-hook 'lsp-mode-hook (lambda ()
                            ((lsp-headerline-breadcrumb-mode t))
                            )
            )
  )
1

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
  :custom
  (lsp-headerline-breadcrumb-enable t))
1

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)
(package-initialize)

(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))
(eval-when-compile
  (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, privacy policy and cookie policy

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