Skip to content

Main features#

Completion at point#

If LSP server supports completion, lsp-mode use symbols returned by the server to present the user when completion is triggered via completion-at-point.

For the traditional completion popup, install company-mode.

You can check above the recommended settings for company-mode:

(setq company-minimum-prefix-length 1
      company-idle-delay 0.0) ;; default is 0.2

Code navigation#

lsp-find-definition

lsp-find-references

Code lens#

In case the LSP server supports code lens:

Project errors on modeline#

To see all error statistics in the modeline you can enable lsp-modeline-diagnostics-mode or (setq lsp-modeline-diagnostics-enable t). This is especially useful for languages that compilation might be broken due to errors in other files(e.g. Java/Haskell).

(with-eval-after-load 'lsp-mode
  ;; :global/:workspace/:file
  (setq lsp-modeline-diagnostics-scope :workspace))

Tip: To find out the global errors you might use lsp-treemacs-errors-list.

Code actions on modeline#

For a UI feedback of the available code actions, you can enable lsp-modeline-code-actions-mode which shows available code actions on modeline:

With lsp-modeline-code-actions-segments you can customize what to show on the modeline as you want:

lsp-modeline-code-actions-segments result
'(count icon) (Default)
'(name icon)
'(icon)
'(count icon name)

For a UI feedback on headerline of the document symbols at point, current file or project name, you can enable lsp-headerline-breadcrumb-mode which shows a breadcrumb on top of window.

You can customize the breadcrumb segments via lsp-headerline-breadcrumb-segments variable, some examples:

lsp-headerline-breadcrumb-segments result
'(path-up-to-project file symbols) (Default)
'(project file symbols)
'(symbols)

If lsp-headerline-breadcrumb-segments contains 'symbols, you can optionally label the corresponding entries in the headerline display by setting lsp-headerline-breadcrumb-enable-symbol-numbers to t.

Symbol highlights#

In case LSP server supports hover feature:

Formatting#

In general the formatter settings are language server specific(e. g. JDT LS uses eclipse formatter file and lsp-java-format-settings-url to configure it while clangd uses clangd-format and lsp-dart uses the built-in dartfmt from Dart SDK). The only settings that are controlled on lsp-mode level are indent size and whether the server should use tabs or spaces. Refer to lsp--formatting-indent-alist to find out what is the variable that is used for the current major mode.

Some language servers, e.g. for C++, Java, etc, can format code as you type and the formatting is triggered when the corresponding character is pressed(typically, }, RET). This behaviour is controlled via lsp-enable-on-type-formatting and it is enabled by default.

Debugger#

lsp-mode integrates with dap-mode with implements the DAP(Debugger Adapter Protocol), for more information check the dap-mode documentation.

Integrations#

lsp-mode supports many integrations for improve the user experience like treemacs, Helm, Ivy and others.

For all available integrations, check the Extensions section on the left navigation.


Last update: April 27, 2024