refactor(lsp): migrate PHP dagnostics from flycheck to flymake-phpcs
This commit is contained in:
@@ -78,29 +78,34 @@
|
||||
;; (flymake-mode))))
|
||||
:init
|
||||
(remove-hook 'flymake-diagnostic-functions 'flymake-proc-legacy-flymake)
|
||||
)
|
||||
|
||||
(use-package flycheck
|
||||
:init (global-flycheck-mode)
|
||||
:config
|
||||
(setq-default flycheck-global-modes '(not org-mode))
|
||||
(setq flycheck-indication-mode nil
|
||||
flycheck-phpcs-standard "PSR12"))
|
||||
;; Workaround de bug#81786 (flymake): la rama no-ratón del `interactive'
|
||||
;; de `flymake-show-buffer-diagnostics' devolvía la LISTA de diagnósticos
|
||||
;; 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
|
||||
:after flycheck
|
||||
:custom
|
||||
(flycheck-eglot-exclusive nil)
|
||||
(use-package flymake-phpcs
|
||||
:ensure (:host github :repo "KJ2ME/flymake-phpcs")
|
||||
:config
|
||||
;; Activar solo en buffers PHP gestionados por eglot: en el resto (p.ej. Go)
|
||||
;; dejar que Eglot use flymake nativo y evitar la recursión de flycheck-eglot.
|
||||
(add-hook 'eglot-managed-mode-hook
|
||||
(lambda ()
|
||||
;; Al conectar, Eglot hace `setq-local' de `flymake-diagnostic-functions'
|
||||
;; (= (eglot-flymake-backend)), borrando nuestro backend; el siguiente
|
||||
;; rechequeo de flymake limpia entonces los overlays de phpcs (aparecen y
|
||||
;; luego desaparecen). Lo re-añadimos cuando Eglot termine de gestionar el
|
||||
;; buffer (el hook corre DESPUES del `setq') y forzamos un rechequeo.
|
||||
(defun flymake-phpcs-readd-after-eglot ()
|
||||
"Re-register the phpcs backend and re-check once Eglot manages the buffer."
|
||||
(when (derived-mode-p 'php-mode 'php-ts-mode)
|
||||
(flycheck-eglot-mode 1)))))
|
||||
|
||||
(use-package flycheck-popup-tip
|
||||
: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)
|
||||
;;; init-lsp.el ends here
|
||||
|
||||
Reference in New Issue
Block a user