2

In a C# lsp-mode buffer, when something is highlighted, is there a "jump to next warning or error" function?

I don't see anything like lsp-next* or lsp-jump*.

Any pointers?

2 Answers 2

1

lsp-mode integrates with flycheck or flymake. Please check the variable lsp-diagnostics-provider.

For example, flycheck provides flycheck-next-error and flycheck-previous-error to help navigate across errors/warnings. You can also use flycheck-list-errors to see the errors list. Similarly, flymake provides flymake-goto-next-error and flymake-goto-prev-error.

1

For real-time diagnostics, lsp-mode utilizes either flycheck or a built-in package flymake (in Emacs open manual with C-h R flymake RET).

flycheck documentation on interaction with errors states:

By default Flycheck hooks into Emacs’ standard error navigation on M-g n (next-error) and M-g p (previous-error).

This is what, supposedly, you're looking for, since flycheck is a recommended package for use by lsp-mode and is configured by default.

flymake documentation in its turn also describes how to navigate between errors. To reach this section in Emacs use M-: (info "(flymake) Finding diagnostics") RET. Now the section states the following:

‘flymake-goto-next-error’ and ‘flymake-goto-prev-error’ are let you navigate to the next/previous erroneous regions, respectively. It might be a good idea to map them to ‘M-n’ and ‘M-p’ in ‘flymake-mode’, by adding to your init file:

 (define-key flymake-mode-map (kbd "M-n") 'flymake-goto-next-error)
 (define-key flymake-mode-map (kbd "M-p") 'flymake-goto-prev-error)

And, since we've touched the subject of diagnostics, you may find a list of related lsp-mode custom options useful. Especially note lsp-diagnostics-provider custom option on that list, which can be used for selecting -- as its name broadly hints -- one of the mentioned providers of the diagnostics.

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.