refactor(lsp): migrate PHP dagnostics from flycheck to flymake-phpcs
This commit is contained in:
@@ -78,29 +78,34 @@
|
|||||||
;; (flymake-mode))))
|
;; (flymake-mode))))
|
||||||
:init
|
:init
|
||||||
(remove-hook 'flymake-diagnostic-functions 'flymake-proc-legacy-flymake)
|
(remove-hook 'flymake-diagnostic-functions 'flymake-proc-legacy-flymake)
|
||||||
)
|
|
||||||
|
|
||||||
(use-package flycheck
|
|
||||||
:init (global-flycheck-mode)
|
|
||||||
:config
|
:config
|
||||||
(setq-default flycheck-global-modes '(not org-mode))
|
;; Workaround de bug#81786 (flymake): la rama no-ratón del `interactive'
|
||||||
(setq flycheck-indication-mode nil
|
;; de `flymake-show-buffer-diagnostics' devolvía la LISTA de diagnósticos
|
||||||
flycheck-phpcs-standard "PSR12"))
|
;; solapados en el punto y Emacs la reexpandía como argumentos
|
||||||
|
;; ("Wrong number of arguments: ..., N"). Arreglado en emacs-31/31.2 y
|
||||||
|
;; pendiente de fusionar a master; borrar cuando tu flymake incluya el fix.
|
||||||
|
(defun flymake--one-diag-filter (args)
|
||||||
|
"Keep only the first diagnostic of ARGS (bug#81786 workaround)."
|
||||||
|
(if (cdr args) (list (car args)) args))
|
||||||
|
(advice-add 'flymake-show-buffer-diagnostics
|
||||||
|
:filter-args #'flymake--one-diag-filter))
|
||||||
|
|
||||||
(use-package flycheck-eglot
|
(use-package flymake-phpcs
|
||||||
:after flycheck
|
:ensure (:host github :repo "KJ2ME/flymake-phpcs")
|
||||||
:custom
|
|
||||||
(flycheck-eglot-exclusive nil)
|
|
||||||
:config
|
:config
|
||||||
;; Activar solo en buffers PHP gestionados por eglot: en el resto (p.ej. Go)
|
;; Al conectar, Eglot hace `setq-local' de `flymake-diagnostic-functions'
|
||||||
;; dejar que Eglot use flymake nativo y evitar la recursión de flycheck-eglot.
|
;; (= (eglot-flymake-backend)), borrando nuestro backend; el siguiente
|
||||||
(add-hook 'eglot-managed-mode-hook
|
;; rechequeo de flymake limpia entonces los overlays de phpcs (aparecen y
|
||||||
(lambda ()
|
;; luego desaparecen). Lo re-añadimos cuando Eglot termine de gestionar el
|
||||||
(when (derived-mode-p 'php-mode 'php-ts-mode)
|
;; buffer (el hook corre DESPUES del `setq') y forzamos un rechequeo.
|
||||||
(flycheck-eglot-mode 1)))))
|
(defun flymake-phpcs-readd-after-eglot ()
|
||||||
|
"Re-register the phpcs backend and re-check once Eglot manages the buffer."
|
||||||
(use-package flycheck-popup-tip
|
(when (derived-mode-p 'php-mode 'php-ts-mode)
|
||||||
:hook (flycheck-mode . flycheck-popup-tip-mode))
|
(add-hook 'flymake-diagnostic-functions #'flymake-phpcs nil t)
|
||||||
|
(flymake-mode 1)
|
||||||
|
(flymake-start)))
|
||||||
|
(add-hook 'eglot-managed-mode-hook #'flymake-phpcs-readd-after-eglot)
|
||||||
|
:hook ((php-mode php-ts-mode) . flymake-phpcs-load))
|
||||||
|
|
||||||
(provide 'init-lsp)
|
(provide 'init-lsp)
|
||||||
;;; init-lsp.el ends here
|
;;; init-lsp.el ends here
|
||||||
|
|||||||
Reference in New Issue
Block a user