[eglot] Add support for eglot lsp client in emacs
- Update README - Add eglot-specifics to cc, rs, py, hs removing unused lsp-mode packages when eglot is active - Add eglot-specific bindings - Add doctor warnings for debugger +lsp and +peek - Add eglot-backed lookup-handlers - Add flycheck checker using eglot for :checkers syntax users (using flycheck/flycheck#1676 and flycheck/flycheck#1592 discussion). This implementation is based on @marsam code, and uses recent Flycheck development in order to make the code smaller and easier to maintain.
This commit is contained in:
parent
f2a3dee7ff
commit
3e5b7cce3f
18 changed files with 248 additions and 47 deletions
9
modules/tools/lsp/autoload/common.el
Normal file
9
modules/tools/lsp/autoload/common.el
Normal file
|
@ -0,0 +1,9 @@
|
|||
;;; tools/lsp/autoload/common.el -*- lexical-binding: t; -*-
|
||||
|
||||
;;;###autodef
|
||||
(defun lsp! ()
|
||||
"Dispatch to call the currently used lsp client entrypoint"
|
||||
(interactive)
|
||||
(if (featurep! +eglot)
|
||||
(eglot-ensure)
|
||||
(lsp-deferred)))
|
19
modules/tools/lsp/autoload/eglot.el
Normal file
19
modules/tools/lsp/autoload/eglot.el
Normal file
|
@ -0,0 +1,19 @@
|
|||
;;; tools/lsp/autoload/eglot.el -*- lexical-binding: t; -*-
|
||||
;;;###if (featurep! +eglot)
|
||||
|
||||
;;;###autodef
|
||||
(defun set-eglot-client! (mode server-call)
|
||||
"Add SERVER-CALL list as a possible lsp server for given major MODE.
|
||||
|
||||
Example : (set-eglot-client! 'python-mode `(,(concat doom-etc-dir \"lsp/mspyls/Microsoft.Python.LanguageServer\")))"
|
||||
(when (featurep! +eglot)
|
||||
(add-to-list 'eglot-server-programs `(,mode . ,server-call))))
|
||||
|
||||
;;;###autoload
|
||||
(defun +eglot/documentation-lookup-handler ()
|
||||
"Documentation lookup handler using eglot :document/hover handler.
|
||||
|
||||
Mostly a rewrite of `eglot-help-at-point', which should be used interactively."
|
||||
(interactive)
|
||||
(eglot-help-at-point)
|
||||
(display-buffer eglot--help-buffer))
|
51
modules/tools/lsp/autoload/lsp-mode.el
Normal file
51
modules/tools/lsp/autoload/lsp-mode.el
Normal file
|
@ -0,0 +1,51 @@
|
|||
;;; tools/lsp/autoload/lsp-mode.el -*- lexical-binding: t; -*-
|
||||
;;;###if (not (featurep! +eglot))
|
||||
|
||||
;;;###autodef
|
||||
(defun set-lsp-priority! (client priority)
|
||||
"Change the PRIORITY of lsp CLIENT."
|
||||
(require 'lsp-mode)
|
||||
(if-let (client (gethash client lsp-clients))
|
||||
(setf (lsp--client-priority client)
|
||||
priority)
|
||||
(error "No LSP client named %S" client)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +lsp/uninstall-server (dir)
|
||||
"Delete a LSP server from `lsp-server-install-dir'."
|
||||
(interactive
|
||||
(list (read-directory-name "Uninstall LSP server: " lsp-server-install-dir nil t)))
|
||||
(unless (file-directory-p dir)
|
||||
(user-error "Couldn't find %S directory" dir))
|
||||
(delete-directory dir 'recursive)
|
||||
(message "Uninstalled %S" (file-name-nondirectory dir)))
|
||||
|
||||
;;;###autoload
|
||||
(defun +lsp/switch-client (client)
|
||||
"Switch to another LSP server."
|
||||
(interactive
|
||||
(progn
|
||||
(require 'lsp-mode)
|
||||
(list (completing-read
|
||||
"Select server: "
|
||||
(or (mapcar #'lsp--client-server-id (lsp--find-clients))
|
||||
(user-error "No available LSP clients for %S" major-mode))))))
|
||||
(require 'lsp-mode)
|
||||
(let* ((client (if (symbolp client) client (intern client)))
|
||||
(match (car (lsp--filter-clients (lambda (c) (eq (lsp--client-server-id c) client)))))
|
||||
(workspaces (lsp-workspaces)))
|
||||
(unless match
|
||||
(user-error "Couldn't find an LSP client named %S" client))
|
||||
(let ((old-priority (lsp--client-priority match)))
|
||||
(setf (lsp--client-priority match) 9999)
|
||||
(unwind-protect
|
||||
(if workspaces
|
||||
(lsp-workspace-restart
|
||||
(if (cdr workspaces)
|
||||
(lsp--completing-read "Select server: "
|
||||
workspaces
|
||||
'lsp--workspace-print
|
||||
nil t)
|
||||
(car workspaces)))
|
||||
(lsp-mode +1))
|
||||
(setf (lsp--client-priority match) old-priority)))))
|
Loading…
Add table
Add a link
Reference in a new issue