From ee4619d3670830180ffd87b1598d74312b5b9808 Mon Sep 17 00:00:00 2001 From: Vincent Zhang Date: Sat, 29 Jun 2019 01:21:32 +0800 Subject: [PATCH] Optimize lsp segment. --- doom-modeline-segments.el | 44 ++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/doom-modeline-segments.el b/doom-modeline-segments.el index e9fa425..ed5c065 100644 --- a/doom-modeline-segments.el +++ b/doom-modeline-segments.el @@ -1622,8 +1622,10 @@ mouse-3: Describe current input method") 'help-echo (if workspaces (concat "LSP Connected " - (string-join (--map (format "[%s]\n" (lsp--workspace-print it)) - workspaces)) + (string-join + (mapcar (lambda (w) + (format "[%s]\n" (lsp--workspace-print w))) + workspaces)) "C-mouse-1: Switch to another workspace folder mouse-1: Describe current session mouse-2: Quit server @@ -1631,28 +1633,28 @@ mouse-3: Reconnect to server") "LSP Disconnected mouse-1: Reload to start server") 'mouse-face '(:box 0) - 'local-map - (let ((map (make-sparse-keymap))) - (if workspaces - (progn - (define-key map [mode-line C-mouse-1] - #'lsp-workspace-folders-open) - (define-key map [mode-line mouse-1] - #'lsp-describe-session) - (define-key map [mode-line mouse-2] - #'lsp-workspace-shutdown) - (define-key map [mode-line mouse-3] - #'lsp-workspace-restart)) - (progn - (define-key map [mode-line mouse-1] - (lambda () - (interactive) - (ignore-errors (revert-buffer t t)))))) - map))))) + 'local-map (let ((map (make-sparse-keymap))) + (if workspaces + (progn + (define-key map [mode-line C-mouse-1] + #'lsp-workspace-folders-open) + (define-key map [mode-line mouse-1] + #'lsp-describe-session) + (define-key map [mode-line mouse-2] + #'lsp-workspace-shutdown) + (define-key map [mode-line mouse-3] + #'lsp-workspace-restart)) + (progn + (define-key map [mode-line mouse-1] + (lambda () + (interactive) + (ignore-errors (revert-buffer t t)))))) + map))))) +(add-hook 'lsp-before-initialize-hook #'doom-modeline-update-lsp) (add-hook 'lsp-after-initialize-hook #'doom-modeline-update-lsp) (add-hook 'lsp-after-uninitialized-hook #'doom-modeline-update-lsp) +(add-hook 'lsp-before-open-hook #'doom-modeline-update-lsp) (add-hook 'lsp-after-open-hook #'doom-modeline-update-lsp) -(add-hook 'lsp-workspace-folders-changed-hook #'doom-modeline-update-lsp) (defvar-local doom-modeline--eglot nil) (defun doom-modeline-update-eglot ()