Skip to content

flycheck doesn't work when editing thru symlink #119

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

Closed
jackkamm opened this issue Apr 12, 2018 · 2 comments
Closed

flycheck doesn't work when editing thru symlink #119

jackkamm opened this issue Apr 12, 2018 · 2 comments

Comments

@jackkamm
Copy link

jackkamm commented Apr 12, 2018

lsp-ui-flycheck has problems when editing a file through a symlink.

In particular, syntax errors within the buffer are not highlighted by flycheck; furthermore functions such as flycheck-list-errors, flycheck-next-error, etc. will not find any errors.

However, calling lsp-ui-flycheck-list works fine, and will correctly find errors/warnings and list them in the sidebar.

I believe the issue is in the function lsp-ui-flycheck--start within lsp-ui-flycheck.el, around line 169:

(defun lsp-ui-flycheck--start (checker callback)
  ;; ...skipping a few lines here...
  (let ((errors))
    (dolist (diag (gethash buffer-file-name lsp--diagnostics)) ;<--ISSUE HERE
      (push (flycheck-error-new
      ;; ...more lines below...

replacing buffer-file-name with (file-truename buffer-filename) fixed the issue in my case.

@jackkamm jackkamm changed the title flycheck doesn't work when editing symlink flycheck doesn't work when editing thru symlink Apr 12, 2018
@sebastiencs
Copy link
Member

sebastiencs commented Apr 13, 2018

Thank you ! I've pushed a fix

@aquarichy
Copy link

This bug may have returned.

If I create a minimal environment in a fresh image, with just emacs, lsp-mode, lsp-ui, lsp-pyright, and flycheck installed, if I access a .py file from its real path, flycheck errors are shown as highlighted in the buffer. If I access it through a symlinked directory, I get the behaviour above. lsp-ui-flycheck-list sees my errors, but they aren't indicated otherwise.

  • Fedora Linux 38 (Container Image)
  • GNU Emacs 28.3
  • flycheck 20230813.620
  • lsp-pyright 20231006.1212
  • lsp-ui 20230811.552
  • lsp-mode 20231101.2023

Minimal .emacs:

;; ---- Package Management (package.el, melpa) ----
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)


;; From: https://emacs-lsp.github.io/lsp-mode/page/installation/
(use-package lsp-mode
  :init
  ;; set prefix for lsp-command-keymap (few alternatives - "C-l", "C-c l")
  (setq lsp-keymap-prefix "C-c l")
  :hook (;; replace XXX-mode with concrete major-mode(e. g. python-mode)
         (python-mode . lsp)
         ;; if you want which-key integration
         (lsp-mode . lsp-enable-which-key-integration))
  :commands lsp)

(use-package lsp-ui :commands lsp-ui-mode)

;; From: https://emacs-lsp.github.io/lsp-pyright/
(use-package lsp-pyright
  :ensure t
  :hook (python-mode . (lambda ()
                          (require 'lsp-pyright)
                          (lsp))))  ; or lsp-deferred

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

No branches or pull requests

3 participants