Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Warnings "Invalid face reference: lsp-flycheck-info-unnecessary" when using lsp-ui-sideline #761

Open
jonmoore opened this issue Jan 9, 2024 · 1 comment

Comments

@jonmoore
Copy link

jonmoore commented Jan 9, 2024

While editing Python files when using lsp-mode together with pyright, lsp-ui, lsp-ui-sideline and flycheck, warning messages like "Invalid face reference: lsp-flycheck-info-unnecessary" occur repeatedly in the "*Messages*" buffer.

This can be seen by e.g. creating a buffer with an unused import, saving it, and moving the cursor on and off the import line when the sideline is in use.

It occurs because lsp-flycheck-info-unnecessary is not a face (the corresponding face is lsp-flycheck-info-unnecessary-face) but is treated as such by lsp-ui-sideline--diagnostics.

Both are generated by lsp--diagnostics-flycheck-level, which generates a "level" from an original flycheck level (e.g. 'error, 'warning) and a list of tags.

Some of the levels returned from lsp-diagnostics--flycheck-calculate-level are themselves faces but those constructed with tags are not.

However lsp-ui-sideline--diagnostics may set a face variable directly from such a level and pass it to add-face-text-property.

lsp-ui/lsp-ui-sideline.el

Lines 469 to 474 in 0dd3990

(level (flycheck-error-level e))
(face (if (eq level 'info) 'success level))
(margin (lsp-ui-sideline--margin-width))
(msg (progn (add-face-text-property 0 len 'lsp-ui-sideline-global nil msg)
(add-face-text-property 0 len face nil msg)
msg))

When that occurs this triggers an "Invalid face" warnings. This can be fixed by replacing

(face (if (eq level 'info) 'success level))

by

(face (let ((local-face
             (flycheck-error-level-error-list-face
              (if (eq level 'info) 'success level))))
        (if (facep local-face)
            local-face
          (error "Could not determine face for %s" level))))

Related from lsp-mode

jonmoore added a commit to jonmoore/JMEmacs that referenced this issue Jan 9, 2024
@rdiaz02
Copy link

rdiaz02 commented Mar 12, 2024

I am seeing the same error in a LaTeX file. I am using a clean environment using the following command: M-x lsp-start-plain.

Steps to reproduce:

  1. create this LaTeX file
\documentclass{article}

\begin{document}
\section{One section}
\label{sec:one-section}


\end{document}
  1. emacs -Q
  2. evaluate (package-initialize)
  3. M-x lsp-start-plain
  4. find-file the above LaTeX file
  5. lsp. I am using the latest (5.13.0) texlab:
LSP :: Connected to [texlab2:1806426/starting /home/ramon/tmp].
LSP :: texlab2:1806426 initialized successfully in folders: (/home/ramon/tmp
  1. Move point to '\label{sec:one-section}`. Lots of warnings appear in the Messages buffer:
Invalid face reference: lsp-flycheck-info-unnecessary [131 times]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants