`flymake-eslint-enable` works when enabled from minibuffer but fails when started from major mode hook
Closed this issue · 1 comments
ovistoica commented
Here's my config
(use-package flymake
:ensure flymake
:demand
:hook (prog-mode . flymake-mode)
:defines
flymake-mode
:bind
("M-n" . flymake-goto-next-error)
("M-p" . flymake-goto-prev-error)
("<f12>" . flymake-goto-next-error)
("C-<f12>" . flymake-goto-next-error)
("C-c !" . flymake-show-buffer-diagnostics))
(use-package flymake-eslint
:ensure flymake-eslint
:after (flymake)
:hook
(js2-mode . flymake-eslint-enable)
(web-mode . flymake-eslint-enable)
(typescript-ts-mode . (lambda () (flymake-eslint-enable)))
(tsx-ts-mode . (lambda () (flymake-eslint-enable))))
If I open a ts or tsx file and then I do M-x flymake-eslint-enable
it works
But as a hook trigger from the above config it fails
Note: It's now written with lambda as I hoped that would solve it but I get the same error if have hooks configured like
(mode . flymake-eslint-enable)
I'm using treesitter & eglot
Messages Log
error in process sentinel: flymake--handle-report: Can’t find state for flymake-proc-legacy-flymake in ‘flymake--state’
error in process sentinel: Can’t find state for flymake-proc-legacy-flymake in ‘flymake--state’
error in process sentinel: flymake--handle-report: Can’t find state for flymake-eslint--checker in ‘flymake--state’
error in process sentinel: Can’t find state for flymake-eslint--checker in ‘flymake--state’
ovistoica commented
Update: Figured it out. The issue was that eglot
was taking over flymake, removing any other backends that were set. In the eglot
documentation, it's suggested to add flymake
to eglot-stay-out-of
but that stops eglot from showing errors through flymake which is not what you'd want
Ended on with this as a working solution:
(defun os/enable-eslint-if-typescript ()
"Enable eslint if typescript mode"
(when (or (eq major-mode 'tsx-ts-mode)
(eq major-mode 'typescript-ts-mode))
(flymake-eslint-enable)))
(add-hook 'eglot-managed-mode-hook #'os/enable-eslint-if-typescript)