purcell / emacs.d

An Emacs configuration bundle with batteries included
BSD 2-Clause "Simplified" License
6.82k stars 2.04k forks source link

About flymake-flycheck #831

Closed xiliuya closed 1 year ago

xiliuya commented 1 year ago

This plugin uses eglot and clangd to report the following errors and cannot be checked properly:

(fn REPORT-FN &rest _)] in ‘flymake--state’
error in process sentinel: Can’t find state for #[385 \300\242\203\0\302\303\301"\210\304\300\242!\210\300\305\240\210\302\306\301"\210\300\307\310p\311\301\312\305\313\314\301!&\240\210\315\300\242\316\317\301#"\207 [(#s(flycheck-syntax-check dwl.c c/c++-clang flycheck-c/c++-clang /home/xiliuya/git/)) c/c++-clang flymake-flycheck--debug interrupting defunct syntax check for %s flycheck-syntax-check-interrupt nil start syntax check for %s flycheck-syntax-check-new :buffer :checker :context :working-directory flycheck-compute-working-directory flycheck-syntax-check-start make-closure #[513 \302\303\301#\210\304\267\2021\0\300\305\306\307\310\301##\207\300\311\312\313\301""\314edB#\207\302\315\301#\207\302\316\301#\207\302\317\301#\207 [V0 V1 flymake-flycheck--debug received status %S from %s #s(hash-table size 4 test eq rehash-size 1.5 rehash-threshold 0.8125 purecopy t data (errored 12 finished 23 interrupted 37 suspicious 43)) :panic :explanation format Flycheck checker %s reported error %S mapcar apply-partially flymake-flycheck--translate-error :region checker %s reported being interrupted %S checker %s reported suspicious result %S unexpected status from checker %s: %S] 9 

Comment out these lines: init-flymake.el : 7-22 (when (maybe-require-package 'flymake-flycheck)

purcell commented 1 year ago

Sorry, I didn't quite understand what's wrong here. How would I reproduce this?

xiliuya commented 1 year ago

Sorry, I didn't quite understand what's wrong here. How would I reproduce this?

I added the configuration in init-local.el. (add-hook 'c-mode-common-hook 'eglot-ensure) Then close all the c files, restart emacs, open C file will pop up this error.

xiliuya commented 1 year ago

Sorry, I didn't quite understand what's wrong here. How would I reproduce this?

Is my configuration incorrect? But even if I don't use eglot. If I don't comment out the above lines (flymake-flycheck). Opening the c project *Flymake diagnostic gives an error similar to the following: The test project is xv6-riscv

1 9 error ( 'kernel/types.h' file not found [c/c++-clang]

xiliuya commented 1 year ago

Sorry, I didn't quite understand what's wrong here. How would I reproduce this?

I found that the value of flymake-diagnostic-functions is different flymake-check does not open:

Its value is (eglot-flymake-backend)

When flymake-check is on:

Its value is
(eglot-flymake-backend #f(compiled-function
                          (report-fn &rest _)
                          #<bytecode 0x5319205130afeb4>))
purcell commented 1 year ago

Yeah, I guess it's possible that if some flycheck backends are enabled, then they will be used via flymake-flycheck alongside eglot. I'll have a think about how to tackle this. In the meantime you can probably add unwanted flycheck backends to flycheck-disabled-checkers.

xiliuya commented 1 year ago

Yeah, I guess it's possible that if some flycheck backends are enabled, then they will be used via flymake-flycheck alongside eglot. I'll have a think about how to tackle this. In the meantime you can probably add unwanted flycheck backends to flycheck-disabled-checkers.

It's very effective. Thank you for your help.

 (setq-default flycheck-disabled-checkers
                  (append (default-value 'flycheck-disabled-checkers)
                          '(c/c++-clang c/c++-gcc c/c++-cppcheck)))
purcell commented 1 year ago

Thanks for confirming that this helped you!

yszhang95 commented 8 months ago

I also want to disable c/c++-clang and enable eglot-flymake-backend. I tried to put in init-local.el

(with-eval-after-load 'flycheck (add-to-list 'flycheck-disabled-checkers 'c/c++-clang))

as suggested in the link.

However, it does not work unless I delete (add-hook 'flymake-mode-hook 'flymake-flycheck-auto) in init-flymake.el and add it after (add-to-list 'flycheck-disabled-checkers 'c/c++-clang) in init-local.el.

I wonder if there is any way to reconcile without modifying anything in init-flymake.el. I want to keep things synchronized with you and avoid corruption from my changes.

Another things is that after I disable c/c++-clang in a dirty way, the backend eglot-flymake-backend cannot be enabled automatically. Executing M-x flymake-running-backends gives me nothing. I have to execute M-X eglot in the buffer manually and eglot checker got invoked. Is there suggestions to overcome this step and make things consistent with flymake-flycheck?

Many thanks!

Edited: It is not necessary to invoke

(add-hook 'flymake-diagnostics-functions 'eglot-flymake-backend nil t)

instead, I have to do

(add-hook 'c++-ts-mode-hook 'eglot-ensure)
(add-hook 'c++-mode-hook 'eglot-ensure)
purcell commented 8 months ago

@yszhang95 Thanks for the info. What do you mean by "the backend eglot-flymake-backend cannot be enabled automatically"? Do you mean when eglot is active in a project, and you open a new buffer, for example? I'm interested in how to reproduce this issue step-by-step specifically, because I'd like to fix it.

yszhang95 commented 8 months ago

Thank you for the quick reply @purcell !

When I tried to prepare for a minimal example to reproduce, I found I have to include

(add-hook 'c++-ts-mode-hook 'eglot-ensure)
(add-hook 'c++-mode-hook 'eglot-ensure)

Sorry for the misleading question. I will update my last comment to avoid misleading others.

The remaining question is the first one, how to avoid corrupting your setup.

Best regards!