tools/lsp: minor refactor & doc revision
This commit is contained in:
parent
f83e6fe1cc
commit
ffb21b18e5
4 changed files with 21 additions and 17 deletions
|
@ -93,6 +93,7 @@ active, LSP is used to search a symbol indexed by the LSP server :
|
|||
|-----------+-------------------------------------|
|
||||
| =SPC c j= | Jump to symbol in current workspace |
|
||||
| =SPC c J= | Jump to symbol in any workspace |
|
||||
|
||||
** Differences between eglot and lsp-mode
|
||||
Entering the debate about which one to use would be useless. Doom provides an
|
||||
easy way to switch out lsp client implementations so you can test for yourself
|
||||
|
@ -108,6 +109,7 @@ closer integration with "more basic" emacs packages (=eldoc=, =xref=, ...).
|
|||
** My language server is not found
|
||||
Check the entry in the [[../../../docs/faq.org][FAQ]] about "Doom can't find my executables/doesn't inherit
|
||||
the correct ~PATH~"
|
||||
|
||||
** LSP/Eglot is not started automatically in my buffer
|
||||
Make sure that you added the =+lsp= flag to the language you're using too in
|
||||
your init.el :
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
;;; flycheck-eglot --- Hacky eglot support in flycheck -*- lexical-binding: t; -*-
|
||||
|
||||
;;; Code:
|
||||
(defun flycheck-eglot--start (checker callback)
|
||||
(defun +lsp--flycheck-eglot-init (checker callback)
|
||||
"Clean up errors when done.
|
||||
|
||||
CHECKER is the checker (eglot).
|
||||
|
@ -31,26 +31,25 @@ CALLBACK is the function that we need to call when we are done, on all the error
|
|||
;; NOTE: Forcefully trigger a check in the buffer (function name is confusing)
|
||||
(flycheck-buffer)))
|
||||
|
||||
(defun flycheck-eglot--available-p ()
|
||||
(defun +lsp--flycheck-eglot-available-p ()
|
||||
(bound-and-true-p eglot--managed-mode))
|
||||
|
||||
(flycheck-define-generic-checker 'eglot
|
||||
"Report `eglot' diagnostics using `flycheck'."
|
||||
:start #'flycheck-eglot--start
|
||||
:predicate #'flycheck-eglot--available-p
|
||||
:start #'+lsp--flycheck-eglot-init
|
||||
:predicate #'+lsp--flycheck-eglot-available-p
|
||||
:modes '(prog-mode text-mode))
|
||||
|
||||
(push 'eglot flycheck-checkers)
|
||||
|
||||
(defun +doom-eglot-prefer-flycheck-h ()
|
||||
(when eglot--managed-mode
|
||||
(when-let ((current-checker (flycheck-get-checker-for-buffer)))
|
||||
(unless (equal current-checker 'eglot)
|
||||
(flycheck-add-next-checker 'eglot current-checker)))
|
||||
(flycheck-add-mode 'eglot major-mode)
|
||||
(flycheck-mode 1)
|
||||
(flymake-mode -1)))
|
||||
|
||||
(add-hook 'eglot--managed-mode-hook #'+doom-eglot-prefer-flycheck-h)
|
||||
(add-hook! 'eglot--managed-mode-hook
|
||||
(defun +lsp-eglot-prefer-flycheck-h ()
|
||||
(when eglot--managed-mode
|
||||
(when-let ((current-checker (flycheck-get-checker-for-buffer)))
|
||||
(unless (equal current-checker 'eglot)
|
||||
(flycheck-add-next-checker 'eglot current-checker)))
|
||||
(flycheck-add-mode 'eglot major-mode)
|
||||
(flycheck-mode 1)
|
||||
(flymake-mode -1))))
|
||||
|
||||
;;; flycheck-eglot.el ends here
|
||||
|
|
|
@ -5,14 +5,15 @@
|
|||
workspace buffer is closed.
|
||||
|
||||
This delay prevents premature server shutdown when a user still intends on
|
||||
working on that project after closing the last buffer.")
|
||||
|
||||
working on that project after closing the last buffer, or when programmatically
|
||||
killing and opening many LSP/eglot-powered buffers.")
|
||||
|
||||
|
||||
;;
|
||||
;;; Common
|
||||
|
||||
(defun +lsp-init-optimizations-h ()
|
||||
"Deploys universal optimizations for `lsp-mode' and `eglot'."
|
||||
(when (or (bound-and-true-p eglot--managed-mode)
|
||||
(bound-and-true-p lsp-mode))
|
||||
;; `read-process-output-max' is only available on recent development
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
;;; tools/lsp/doctor.el -*- lexical-binding: t; -*-
|
||||
|
||||
(assert! (not (and (featurep! +eglot) (featurep! +peek))) "+eglot and +peek flags are not compatible. Peek uses lsp-mode, while Eglot is another package altogether for LSP.")
|
||||
(assert! (not (and (featurep! +eglot)
|
||||
(featurep! +peek)))
|
||||
"+eglot and +peek flags are not compatible. Peek uses lsp-mode, while Eglot is another package altogether for LSP.")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue