forked from doomemacs/doomemacs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
lsp-mode.el
51 lines (48 loc) · 1.93 KB
/
lsp-mode.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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)))))