Following is a screenshot of Vim highlighting the closing bracket ()) red,

enter image description here

How can I know why vim thinks it's an error (or whatever it is)? How can I print the description of the reason for highlighting in red?

  • 1
    If it's not from LSP, you likely won't get a description of the error. You can find the exact error vim is highlighting, though, with command! SynName echo synIDattr(synID(line("."), col("."), 1), "name"). Run this command when cursor is on the error and it should print what the error is.
    – 3N4N
    Sep 18, 2022 at 11:23
  • 1
    @kadekai to be more precise: the command you show defines a command SynName which will show the syntax group under the cursor. (There are better variations because there can be more than one such group.) The syntax group is likely to be what triggered the highlighting, though, which you can confirm with a mix of :highlight and :syntax commands.
    – D. Ben Knoble
    Sep 18, 2022 at 13:07


Your Answer

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

Browse other questions tagged or ask your own question.