manateelazycat / lsp-bridge

A blazingly fast LSP client for Emacs
GNU General Public License v3.0
1.36k stars 197 forks source link

Idea: Support lsp progress? #922

Closed eval-exec closed 2 months ago

eval-exec commented 2 months ago

I believe it would be nice if the lsp-bridge could display lsp progress in the modeline, similar to the example shown in https://github.com/linrongbin16/lsp-progress.nvim.

Reference:

manateelazycat commented 2 months ago

I'll make it happen in a while. I've been a little too busy lately.

manateelazycat commented 2 months ago

Can you give me some code to test workDoneProgress? Thanks.

eval-exec commented 2 months ago

Can you give me some code to test workDoneProgress? Thanks.

You can try this rust repo: git clone --depth=1 https://github.com/BurntSushi/ripgrep.git

manateelazycat commented 2 months ago

@eval-exec

I have push https://github.com/manateelazycat/lsp-bridge/commit/c767902cc6b9e60ad4c8dca15ddbecef44cb496b to support workDoneProgress protocol.

Control by option acm-backend-lsp-show-progress , when acm-backend-lsp-show-progress is t, show progress in minibuffer.

I use my awesome-tray, not use modeline, any PR about modeline are welcome! ;)

eval-exec commented 2 months ago

Great job on implementing support for the workDoneProgress protocol! Thank you! :blue_heart:

I use my awesome-tray, not use modeline, any PR about modeline are welcome! ;)

Now I can use the following spinner characters to display the status of WorkDoneProgress in modeline: ;; spinner = {"⣾", "⣽", "⣻", "⢿", "⡿", "⣟", "⣯", "⣷"},


(defvar lsp-bridge--mode-line-spin-id 0)
(defvar lsp-bridge--spiners
  ;; '("⣾" "⣽" "⣻" "⢿" "⡿" "⣟" "⣯" "⣷")
  '("▁" "▃" "▄" "▅" "▆" "▇" "█" "▇" "▆" "▅" "▄" "▃")
  )
(defun lsp-bridge--mode-line-format ()
  "Compose the LSP-bridge's mode-line."
  (setq-local mode-face
              (if (lsp-bridge-process-live-p)
                  'lsp-bridge-alive-mode-line
                'lsp-bridge-kill-mode-line))

  (when lsp-bridge-server
    (propertize (format "lsp-bridge %s "
                        (nth lsp-bridge--mode-line-spin-id lsp-bridge--spiners)) 'face mode-face)))

(defun lsp-bridge--update-spin-id ()
  (setq lsp-bridge--mode-line-spin-id
        (mod (1+ lsp-bridge--mode-line-spin-id) (length lsp-bridge--spiners)))
  (force-mode-line-update))

(run-with-timer 0 0.1 'lsp-bridge--update-spin-id)

The effect:

https://github.com/manateelazycat/lsp-bridge/assets/46400566/f8eaf32c-4a3b-42dc-a62a-7a8997e1d1c5

manateelazycat commented 2 months ago

Enjoy it.