Skip to content

Commit 2147fbe

Browse files
authored
Customizable spinner type (emacs-lsp#3546)
* Add variable to customize spinner type * fix typos in doc
1 parent 8123c5c commit 2147fbe

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Diff for: lsp-mode.el

+14-2
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,14 @@ As defined by the Language Server Protocol 3.16."
192192
:group 'lsp-mode
193193
:type 'boolean)
194194

195+
(defcustom lsp-progress-spinner-type 'progress-bar
196+
"Holds the type of spinner to be used in the mode-line.
197+
Takes a value accepted by `spinner-start'."
198+
:group 'lsp-mode
199+
:type `(choice :tag "Choose a spinner by name"
200+
,@(mapcar (lambda (c) (list 'const (car c)))
201+
spinner-types)))
202+
195203
(defvar-local lsp--cur-workspace nil)
196204

197205
(defvar-local lsp--cur-version 0)
@@ -1328,7 +1336,7 @@ the lists according to METHOD."
13281336

13291337
(defun lsp--spinner-start ()
13301338
"Start spinner indication."
1331-
(condition-case _err (spinner-start 'progress-bar-filled) (error)))
1339+
(condition-case _err (spinner-start (lsp-progress-spinner-type)) (error)))
13321340

13331341
(defun lsp--propertize (str type)
13341342
"Propertize STR as per TYPE."
@@ -2056,7 +2064,7 @@ WORKSPACE is the workspace that contains the progress token."
20562064
(-let* (((&WorkDoneProgressBegin :title :percentage?) value)
20572065
(reporter
20582066
(if lsp-progress-via-spinner
2059-
(let* ((spinner-strings (alist-get 'progress-bar spinner-types))
2067+
(let* ((spinner-strings (alist-get (lsp-progress-spinner-type) spinner-types))
20602068
;; Set message as a tooltip for the spinner strings
20612069
(propertized-strings
20622070
(seq-map (lambda (string) (propertize string 'help-echo title))
@@ -8826,6 +8834,10 @@ This avoids overloading the server with many files when starting Emacs."
88268834
(unless (flycheck-checker-supports-major-mode-p 'lsp mode)
88278835
(flycheck-add-mode 'lsp mode)))
88288836

8837+
(defun lsp-progress-spinner-type ()
8838+
"Retrive the spinner type value, if value is not a symbol of `spinner-types defaults to 'progress-bar."
8839+
(or (car (assoc lsp-progress-spinner-type spinner-types)) 'progress-bar))
8840+
88298841
(defun lsp-org ()
88308842
(interactive)
88318843
(-if-let ((virtual-buffer &as &plist :workspaces) (-first (-lambda ((&plist :in-range))

0 commit comments

Comments
 (0)