diff --git a/modules/config/default/+emacs-bindings.el b/modules/config/default/+emacs-bindings.el index e33efbed1..df381f259 100644 --- a/modules/config/default/+emacs-bindings.el +++ b/modules/config/default/+emacs-bindings.el @@ -40,9 +40,7 @@ :desc "Find type definition" "t" #'+lookup/type-definition :desc "Delete trailing whitespace" "w" #'delete-trailing-whitespace :desc "Delete trailing newlines" "W" #'doom/delete-trailing-newlines - :desc "List errors" "x" #'flymake-show-diagnostics-buffer - (:when (featurep! :checkers syntax) - :desc "List errors" "x" #'flycheck-list-errors) + :desc "List errors" "x" #'+default/diagnostics (:when (and (featurep! :tools lsp) (not (featurep! :tools lsp +eglot))) :desc "LSP Code actions" "a" #'lsp-execute-code-action :desc "LSP Organize imports" "o" #'lsp-organize-imports diff --git a/modules/config/default/+evil-bindings.el b/modules/config/default/+evil-bindings.el index 3598dfe7b..b0d8146d7 100644 --- a/modules/config/default/+evil-bindings.el +++ b/modules/config/default/+evil-bindings.el @@ -412,9 +412,7 @@ :desc "Find type definition" "t" #'+lookup/type-definition :desc "Delete trailing whitespace" "w" #'delete-trailing-whitespace :desc "Delete trailing newlines" "W" #'doom/delete-trailing-newlines - :desc "List errors" "x" #'flymake-show-diagnostics-buffer - (:when (featurep! :checkers syntax) - :desc "List errors" "x" #'flycheck-list-errors)) + :desc "List errors" "x" #'+default/diagnostics) ;;; f --- file (:prefix-map ("f" . "file") diff --git a/modules/config/default/autoload/default.el b/modules/config/default/autoload/default.el index 59cee2edf..6a56f8c74 100644 --- a/modules/config/default/autoload/default.el +++ b/modules/config/default/autoload/default.el @@ -44,3 +44,22 @@ If ARG (universal argument), runs `compile' from the current directory." (while (server-running-p) (sleep-for 1)) (server-start)) + +;;;###autoload +(defun +default/diagnostics (&rest arg) + "List diagnostics for the current buffer/project. +If the the vertico and lsp modules are active, list lsp diagnostics for the +current project. Otherwise list them for the current buffer" + (interactive) + (cond ((and (featurep! :completion vertico) + (featurep! :tools lsp) + (bound-and-true-p lsp-mode)) + (consult-lsp-diagnostics arg)) + ((and (featurep! :checkers syntax) + (bound-and-true-p flycheck-mode)) + (flycheck-list-errors)) + ((bound-and-true-p flymake-mode) + (flymake-show-diagnostics-buffer)) + (t + (user-error "No diagnostics backend detected. Enable flycheck or \ +flymake, or set up lsp-mode if applicable (see :lang lsp)")))) diff --git a/modules/editor/evil/+commands.el b/modules/editor/evil/+commands.el index 7ebc8378c..8fd590fa6 100644 --- a/modules/editor/evil/+commands.el +++ b/modules/editor/evil/+commands.el @@ -78,7 +78,7 @@ (evil-ex-define-cmd "make" #'+evil:make) (evil-ex-define-cmd "mk" #'+evil:make) ; convenience alias (evil-ex-define-cmd "debug" #'+debugger/start) -(evil-ex-define-cmd "er[rors]" #'flycheck-list-errors) +(evil-ex-define-cmd "er[rors]" #'+default/diagnostics) ;;; File operations (evil-ex-define-cmd "cp" #'+evil:copy-this-file)