Add set-lsp-priority! autodef & +lsp/switch-client command
Relevant to #2689
This commit is contained in:
parent
7e40c1ebe3
commit
74f64c63f0
1 changed files with 39 additions and 0 deletions
|
@ -1,5 +1,14 @@
|
|||
;;; feature/lsp/autoload.el -*- lexical-binding: t; -*-
|
||||
|
||||
;;;###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 (gethash server lsp-clients))
|
||||
priority)
|
||||
(error "No LSP client named %S" client)))
|
||||
|
||||
;;;###autodef
|
||||
(defalias 'lsp! #'lsp-deferred)
|
||||
|
||||
|
@ -12,3 +21,33 @@
|
|||
(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