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

Missing output from lsp-ui-flycheck #160

Closed
syvsto opened this issue Jul 27, 2018 · 17 comments
Closed

Missing output from lsp-ui-flycheck #160

syvsto opened this issue Jul 27, 2018 · 17 comments

Comments

@syvsto
Copy link

syvsto commented Jul 27, 2018

I'm trying to use lsp-mode with Rust (RLS), and all features seem to be working fine, except the Flycheck integration. Flycheck doesn't present any errors in a buffer that contains errors. The lsp-ui-sideline displays type errors, and running M-x lsp-ui-flycheck-list displays my errors, but I get no squigglies, the modeline doesn't update, and the default Flycheck error list (C-c ! l) doesn't show any errors. According to flycheck-verify-setup, lsp-ui is the chosen syntax checker, and it seems to be enabled.
Flycheck works with other checkers. Has anyone come across something similar?

I'm running Emacs 26.1 on Windows 10.

@yyoncho
Copy link
Member

yyoncho commented Jul 27, 2018

Can you post your configuration? I suspect that it might be fixed by calling lsp-ui-flycheck-enable .

@syvsto
Copy link
Author

syvsto commented Jul 27, 2018

The relevant part of my config looks like this:

;; Flycheck
(use-package flycheck
  :ensure t)

;; LSP
(use-package lsp-mode
  :ensure t
  :config
  (setq lsp-rust-rls-command '("rustup" "run" "nightly" "rls")))
(use-package lsp-ui
  :ensure t
  :hook ((lsp-mode . lsp-ui-mode)))
(use-package company-lsp
  :ensure t)

;; Rust
(use-package lsp-rust
  :ensure t)

(use-package rust-mode
  :ensure t
  :hook ((rust-mode . (lambda ()
			(eldoc-mode)
			(company-mode)
			(lsp-rust-enable)
			(flycheck-mode)
			(lsp-mode)
			))))

Describe-variable on lsp-ui-flycheck-enable says the variable is set to true. Evaluating (lsp-ui-flycheck-enable t) in a Rust buffer with LSP mode enabled gives this output:

(lsp-ui-sideline--diagnostics-changed lsp-ui-flycheck--report t)

The sideline diagnostics pop up, but nothing happens on the Flycheck front. Is this the correct way of calling it? Does it need to be called before flycheck/lsp-mode is launched?

@mspinelli
Copy link

I also can't get flycheck to work. Like you SPC e v says that is is enabled and is uing lsp-ui. In my case I'm using VueJS. See AdamNiederer/vue-mode#84

@innerout
Copy link

innerout commented Aug 2, 2018

@syvsto For me when i had the hook the way you have it didnt work.

  :hook ((lsp-mode . lsp-ui-mode)))

change it to

:init (add-hook 'lsp-mode-hook 'lsp-ui-mode)

@syvsto
Copy link
Author

syvsto commented Aug 2, 2018

@innerout Thanks, but the issue isn't lsp-ui not launching, but rather the Flycheck checking not working. Anyways, I tried changing the code to what you recommended, and Flycheck still doesn't work with LSP. It's not much of an issue for now, as I've disabled the checker from LSP and am using one of the old checkers available, but it'd be nice to get the LSP generated errors to show up!

@innerout
Copy link

innerout commented Aug 2, 2018

You have forgotten placing this!

 (add-hook 'rust-mode-hook 'flycheck-mode)

You have to hook flycheck mode for every language you need it.

That hook i think has to be placed inside lsp-ui.

@syvsto
Copy link
Author

syvsto commented Aug 4, 2018

I had the hook for flycheck placed inside the rust-mode config. I tried removing it from there and adding it to the lsp-ui config, but alas, no change to flycheck when running with the LSP checker.

@yyoncho
Copy link
Member

yyoncho commented Aug 4, 2018

Can you debug the following method - lsp-ui-flycheck--start? It is used to post the flycheck errors.

@syvsto
Copy link
Author

syvsto commented Aug 4, 2018

@yyoncho lsp-ui-flycheck--start gets called when entering a LSP-enabled buffer, with no error messages. Subsequent calls to flycheck-buffer doesn't trigger the debugger (when running debug-on-entry).

@yyoncho
Copy link
Member

yyoncho commented Aug 4, 2018

It looks like some flycheck misconfiguration - when I am using lsp-java and my flycheck is configured properly when I do flycheck-buffer it calls lsp-ui-flycheck--start. Here it is the callstack, I hope this helps:

  lsp-ui-flycheck--start(lsp-ui (closure ((syntax-check . #s(flycheck-syntax-check :buffer #<buffer App.java> :checker lsp-ui :context nil :working-directory "/home/kyoncho/Sources/demo/com.dap.demo.parent/project-b/src/main/java/com/dap/demo/projectb/")) cl-struct-flycheck-syntax-check-tags cl-struct-flycheck-verification-result-tags ess-language sh-shell t) (&rest args) (apply (function flycheck-report-buffer-checker-status) syntax-check args)))
  funcall(lsp-ui-flycheck--start lsp-ui (closure ((syntax-check . #s(flycheck-syntax-check :buffer #<buffer App.java> :checker lsp-ui :context nil :working-directory "/home/kyoncho/Sources/demo/com.dap.demo.parent/project-b/src/main/java/com/dap/demo/projectb/")) cl-struct-flycheck-syntax-check-tags cl-struct-flycheck-verification-result-tags ess-language sh-shell t) (&rest args) (apply (function flycheck-report-buffer-checker-status) syntax-check args)))
  (aset v 3 (funcall (flycheck-checker-get checker 'start) checker callback))
  (let* ((v syntax-check)) (aset v 3 (funcall (flycheck-checker-get checker 'start) checker callback)))
  (progn (or (and (memq (type-of syntax-check) cl-struct-flycheck-syntax-check-tags) t) (signal 'wrong-type-argument (list 'flycheck-syntax-check syntax-check))) (let* ((v syntax-check)) (aset v 3 (funcall (flycheck-checker-get checker 'start) checker callback))))
  (let ((checker (progn (or (and (memq (type-of syntax-check) cl-struct-flycheck-syntax-check-tags) t) (signal 'wrong-type-argument (list 'flycheck-syntax-check syntax-check))) (aref syntax-check 2))) (default-directory (progn (or (and (memq (type-of syntax-check) cl-struct-flycheck-syntax-check-tags) t) (signal 'wrong-type-argument (list 'flycheck-syntax-check syntax-check))) (aref syntax-check 4)))) (progn (or (and (memq (type-of syntax-check) cl-struct-flycheck-syntax-check-tags) t) (signal 'wrong-type-argument (list 'flycheck-syntax-check syntax-check))) (let* ((v syntax-check)) (aset v 3 (funcall (flycheck-checker-get checker 'start) checker callback)))))
  flycheck-syntax-check-start(#s(flycheck-syntax-check :buffer #<buffer App.java> :checker lsp-ui :context nil :working-directory "/home/kyoncho/Sources/demo/com.dap.demo.parent/project-b/src/main/java/com/dap/demo/projectb/") (closure ((syntax-check . #s(flycheck-syntax-check :buffer #<buffer App.java> :checker lsp-ui :context nil :working-directory "/home/kyoncho/Sources/demo/com.dap.demo.parent/project-b/src/main/java/com/dap/demo/projectb/")) cl-struct-flycheck-syntax-check-tags cl-struct-flycheck-verification-result-tags ess-language sh-shell t) (&rest args) (apply (function flycheck-report-buffer-checker-status) syntax-check args)))
  (let* ((check (flycheck-syntax-check-new :buffer (current-buffer) :checker checker :context nil :working-directory (flycheck-compute-working-directory checker))) (callback (flycheck-buffer-status-callback check))) (setq flycheck-current-syntax-check check) (flycheck-report-status 'running) (flycheck-syntax-check-start check callback))
  flycheck-start-current-syntax-check(lsp-ui)
  (if checker (flycheck-start-current-syntax-check checker) (flycheck-clear) (flycheck-report-status 'no-checker))
  (let* ((checker (flycheck-get-checker-for-buffer))) (if checker (flycheck-start-current-syntax-check checker) (flycheck-clear) (flycheck-report-status 'no-checker)))
  (condition-case err (let* ((checker (flycheck-get-checker-for-buffer))) (if checker (flycheck-start-current-syntax-check checker) (flycheck-clear) (flycheck-report-status 'no-checker))) (error (flycheck-report-failed-syntax-check) (signal (car err) (cdr err))))
  (if (flycheck-running-p) nil (run-hooks 'flycheck-before-syntax-check-hook) (flycheck-clear-errors) (flycheck-mark-all-overlays-for-deletion) (condition-case err (let* ((checker (flycheck-get-checker-for-buffer))) (if checker (flycheck-start-current-syntax-check checker) (flycheck-clear) (flycheck-report-status 'no-checker))) (error (flycheck-report-failed-syntax-check) (signal (car err) (cdr err)))))
  (if flycheck-mode (if (flycheck-running-p) nil (run-hooks 'flycheck-before-syntax-check-hook) (flycheck-clear-errors) (flycheck-mark-all-overlays-for-deletion) (condition-case err (let* ((checker (flycheck-get-checker-for-buffer))) (if checker (flycheck-start-current-syntax-check checker) (flycheck-clear) (flycheck-report-status 'no-checker))) (error (flycheck-report-failed-syntax-check) (signal (car err) (cdr err))))) (user-error "Flycheck mode disabled"))
  flycheck-buffer()
  funcall-interactively(flycheck-buffer)
  call-interactively(flycheck-buffer nil nil)
  command-execute(flycheck-buffer)

@diaevd
Copy link

diaevd commented Nov 9, 2018

Is there any progress for this issue with rust?

@yyoncho
Copy link
Member

yyoncho commented Nov 9, 2018

@diaevd include your lsp-mode/flycheck/lsp-ui related configuration + content of the Messages buffer with lsp-print-io set to t.

@diaevd
Copy link

diaevd commented Nov 9, 2018

Ok, it is working for me only with:

lsp-ui-flycheck-enable nil                                                                        |                                                                                                          
lsp-ui-sideline-show-flycheck t

and

(with-eval-after-load 'rust-mode                                                                          |                                                                                                          
  (add-hook 'flycheck-mode-hook #'flycheck-rust-setup))

i.e. it is clean flycheck rust.
But depending on what error it does not always show, it depends on how the frames are splited, horizontaly or verticaly.

In verticaly error always show, in horizontaly not.

@diaevd
Copy link

diaevd commented Nov 9, 2018

My config:

(use-package lsp-mode                                                                                                                                                                                                
  :config                                                                                                                                                                                                            
  (setq lsp-rust-rls-command '("rustup" "run" "nightly" "rls"))                                                                                                                                                      
  )
                                                                                                                                                                                                                  
(use-package company-lsp                                                                                                                                                                                             
  :config                                                                                                                                                                                                            
  (push 'company-lsp company-backends))                                                                                                                                                                              
                                                                                                                                                                                                                                                                                                                                                                                      
(use-package lsp-ui                                                                                                                                                                                                  
  :config                                                                                                                                                                                                            
  (define-key lsp-ui-mode-map [remap xref-find-definitions] #'lsp-ui-peek-find-definitions)                                                                                                                          
  (define-key lsp-ui-mode-map [remap xref-find-references] #'lsp-ui-peek-find-references)                                                                                                                            
  (setq lsp-ui-sideline-enable nil                                                                                                                                                                                   
        lsp-ui-doc-enable nil                                                                                                                                                                                        
        lsp-ui-flycheck-enable nil                                                                                                                                                                                   
        lsp-ui-sideline-show-flycheck t                                                                                                                                                                              
        lsp-ui-imenu-enable t                                                                                                                                                                                        
        lsp-ui-sideline-ignore-duplicate t)) 

(use-package lsp-rust                                                                                                                                                                                                
  :after lsp-mode                                                                                                                                                                                                    
  )                                                                                                                                                                                                                  
                                                                                                                                                                                                                     
;; rust-mode: major-mode for editing rust files                                                                                                                                                                      
;; https://github.com/rust-lang/rust-mode                                                                                                                                                                            
(use-package rust-mode                                                                                                                                                                                               
  :hook ((rust-mode . (lambda ()                                                                                                                                                                                     
                        (lsp-rust-enable)                                                                                                                                                                            
                        (flycheck-mode)                                                                                                                                                                              
                        (lsp-ui-mode)                                                                                                                                                                                
                        (lsp-ui-sideline-mode)                                                                                                                                                                       
                        (lsp-ui-doc-mode)                                                                                                                                                                            
                        (eldoc-mode)                                                                                                                                                                                 
                        ;; (racer-mode)                                                                                                                                                                              
                        ;; (smart-dash-mode)                                                                                                                                                                         
                        (company-mode))))                                                                                                                                                                            
                                                                                                                                                                                                                     
  :bind (:map rust-mode-map                                                                                                                                                                                          
         ("C-c C-r C-v" . wh/rust-toggle-visibility)                                                                                                                                                                 
         ("C-c C-r C-m" . wh/rust-toggle-mutability)                                                                                                                                                                 
         ("C-c C-r C-s" . wh/rust-vec-as-slice)                                                                                                                                                                      
         ("?\t" . #'company-indent-or-complete-common))
  :ensure-system-package                                                                                                                                                                                             
     ((rustfmt . "rustup component add rustfmt-preview")                                                                                                                                                             
       (racer . "cargo install racer")                                                                                                                                                                               
        (rls . "rustup component add rls-preview rust-analysis rust-src"))                                                                                                                                           
  :config                                                                                                                                                                                                            
  (setq rust-indent-method-chain t)                                                                                                                                                                                  
                                                                                                                                                                                                                     
  (defun my-rust-mode-hook ()                                                                                                                                                                                        
    (set (make-local-variable 'company-backends)                                                                                                                                                                     
         '((company-lsp company-files :with company-yasnippet)                                                                                                                                                       
           (company-dabbrev-code company-dabbrev))))                                                                                                                                                                 
                                                                                                                                                                                                                     
  (add-hook 'rust-mode-hook #'my-rust-mode-hook)                                                                                                                                                                     
                                                                                                                                                                                                                     
  ;; format rust buffers using rustfmt(if it is installed)                                                                                                                                                           
  (add-hook 'rust-mode-hook                                                                                                                                                                                          
            (lambda ()                                                                                                                                                                                               
              (add-hook 'before-save-hook                                                                                                                                                                            
                        (lambda ()                                                                                                                                                                                   
                          (time-stamp)                                                                                                                                                                               
                          (lsp-format-buffer)) nil t))) 

(with-eval-after-load 'rust-mode                                                                                                                                                                                     
  (add-hook 'flycheck-mode-hook #'flycheck-rust-setup))

(use-package cargo                                                                                                                                                                                                   
  :after rust-mode                                                                                                                                                                                                   
  :hook ((rust-mode . cargo-minor-mode)))

if i remove flycheck-rust-setup and/or enable lsp-ui-flycheck-enable nothing to work

@yyoncho
Copy link
Member

yyoncho commented Nov 9, 2018

@diaevd can you set lsp-ui-flycheck-enable to t and set lsp-print-io to t and send the logs from the message buffer? I want to make sure that the backend server is sending any diagnostics. Also, #160 (comment) provides a guidelines how to debug lsp-ui flycheck setup. lsp-ui-flycheck-list list the current errors, can you share what is the content of this buffer too?

@diaevd
Copy link

diaevd commented Nov 9, 2018

I can't reproduce call stack like in #160 (I don't know how, no errors).
About messages buffer after enable lsp-print-io - looks like server return nothing. But in lsp-rust buffer i found crashing of compiler. I think this is not bug for lsp-ui, but for rls + rustc.

Sorry. If i find the cause, i'll let you know

P.S. But if you don't touch rls, but the configuration that i provided.

        lsp-ui-flycheck-enable nil                                                                                                                                                                                   
        lsp-ui-sideline-show-flycheck t 

and

(with-eval-after-load 'rust-mode                                                                          |                                                                                                          
  (add-hook 'flycheck-mode-hook #'flycheck-rust-setup))

Have a bug with showing errors (not for all) and only if my frames (layouts) splited horizintaly:

This layout buggy

+------+------+
|      |      |
|      |      |
+------+------+

That's always ok

+-------------+
|             |
+-------------+
|             |
+-------------+

:)

UPD:
It is a bug in rls nightly (see Issue #1117). If use stable or beta - all working fine.
:(
But bug below is standing :)

@brotzeit
Copy link
Member

brotzeit commented Mar 3, 2020

The reason for this is that the implemented flycheck checker in lsp-ui doesn't create squigglies for some reason. lsp-mode now got a generic checker that will be set the default.

@brotzeit brotzeit closed this as completed Mar 3, 2020
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

6 participants