diff --git a/Eask b/Eask index d7960d0e..005a4649 100644 --- a/Eask +++ b/Eask @@ -16,12 +16,12 @@ (depends-on "emacs" "27.1") (depends-on "dash") -(depends-on "flycheck") (depends-on "lsp-mode") (depends-on "markdown-mode") -(depends-on "rustic") (development - (depends-on "ert-runner")) + (depends-on "ert-runner") + (depends-on "rustic") + (depends-on "flycheck")) (setq network-security-level 'low) ; see https://github.com/jcs090218/setup-emacs-windows/issues/156#issuecomment-932956432 diff --git a/lsp-ui-doc.el b/lsp-ui-doc.el index 3e853302..4f113cd1 100644 --- a/lsp-ui-doc.el +++ b/lsp-ui-doc.el @@ -100,7 +100,7 @@ This affects the position of the documentation when (defcustom lsp-ui-doc-alignment 'frame "How to align the doc. -This only takes effect when `lsp-ui-doc-position' is 'top or 'bottom." +This only takes effect when `lsp-ui-doc-position' is `top or `bottom." :type '(choice (const :tag "Frame" frame) (const :tag "Window" window)) :group 'lsp-ui-doc) @@ -182,31 +182,31 @@ Only the `background' is used in this face." :group 'lsp-ui-doc) (defvar lsp-ui-doc-frame-parameters - '((left . -1) - (no-focus-on-map . t) - (min-width . 0) - (width . 0) - (min-height . 0) - (height . 0) - (internal-border-width . 1) - (vertical-scroll-bars . nil) - (horizontal-scroll-bars . nil) - (right-fringe . 0) - (menu-bar-lines . 0) - (tool-bar-lines . 0) - (tab-bar-lines . 0) + '((left . -1) + (no-focus-on-map . t) + (min-width . 0) + (width . 0) + (min-height . 0) + (height . 0) + (internal-border-width . 1) + (vertical-scroll-bars . nil) + (horizontal-scroll-bars . nil) + (right-fringe . 0) + (menu-bar-lines . 0) + (tool-bar-lines . 0) + (tab-bar-lines . 0) (tab-bar-lines-keep-state . 0) - (line-spacing . 0) - (unsplittable . t) - (undecorated . t) - (top . -1) - (visibility . nil) - (mouse-wheel-frame . nil) - (no-other-frame . t) + (line-spacing . 0) + (unsplittable . t) + (undecorated . t) + (top . -1) + (visibility . nil) + (mouse-wheel-frame . nil) + (no-other-frame . t) (inhibit-double-buffering . t) - (drag-internal-border . t) - (no-special-glyphs . t) - (desktop-dont-save . t)) + (drag-internal-border . t) + (no-special-glyphs . t) + (desktop-dont-save . t)) "Frame parameters used to create the frame.") (defvar lsp-ui-doc-render-function nil @@ -248,7 +248,8 @@ Because some variables are buffer local.") "Non-nil when the current document should ask to hide after next command.") -(defconst lsp-ui-doc--buffer-prefix " *lsp-ui-doc-") +(defconst lsp-ui-doc--buffer-prefix " *lsp-ui-doc-" + "LSP UI doc prefix.") (defmacro lsp-ui-doc--with-buffer (&rest body) "Execute BODY in the lsp-ui-doc buffer." @@ -260,7 +261,6 @@ Because some variables are buffer local.") (setq lsp-ui-doc--parent-vars parent-vars) (prog1 (let ((buffer-read-only nil) (inhibit-modification-hooks t) - (inhibit-point-motion-hooks t) (inhibit-redisplay t)) ,@body) (setq buffer-read-only t) @@ -904,15 +904,15 @@ HEIGHT is the documentation number of lines." (run-hook-with-args 'lsp-ui-doc-frame-hook frame window) (when lsp-ui-doc-use-webkit (define-key (current-global-map) [xwidget-event] - (lambda () - (interactive) - (let ((xwidget-event-type (nth 1 last-input-event))) - ;; (when (eq xwidget-event-type 'load-changed) - ;; (lsp-ui-doc--move-frame (lsp-ui-doc--get-frame))) - (when (eq xwidget-event-type 'javascript-callback) - (let ((proc (nth 3 last-input-event)) - (arg (nth 4 last-input-event))) - (funcall proc arg)))))) + (lambda () + (interactive) + (let ((xwidget-event-type (nth 1 last-input-event))) + ;; (when (eq xwidget-event-type 'load-changed) + ;; (lsp-ui-doc--move-frame (lsp-ui-doc--get-frame))) + (when (eq xwidget-event-type 'javascript-callback) + (let ((proc (nth 3 last-input-event)) + (arg (nth 4 last-input-event))) + (funcall proc arg)))))) (lsp-ui-doc--webkit-run-xwidget)) frame)) diff --git a/lsp-ui-imenu.el b/lsp-ui-imenu.el index 3cb1e515..ee8f899a 100644 --- a/lsp-ui-imenu.el +++ b/lsp-ui-imenu.el @@ -53,7 +53,7 @@ (defcustom lsp-ui-imenu-kind-position 'top "Where to show the entries kind." :type '(choice (const :tag "Top" top) - (const :tag "Left" left)) + (const :tag "Left" left)) :group 'lsp-ui-imenu) (defcustom lsp-ui-imenu-buffer-position 'right @@ -81,8 +81,8 @@ ie. it will not be affected by `balance-windows' etc." (defcustom lsp-ui-imenu-auto-refresh nil "Automatically refresh imenu when certain conditions meet." :type '(choice (const :tag "Enable" t) - (const :tag "Active only when after save" after-save) - (const :tag "Disable" nil)) + (const :tag "Active only when after save" after-save) + (const :tag "Disable" nil)) :group 'lsp-ui-imenu) (defcustom lsp-ui-imenu-auto-refresh-delay 1.0 @@ -106,17 +106,17 @@ ie. it will not be affected by `balance-windows' etc." (defun lsp-ui-imenu--pad (s len bars depth color-index for-title is-last) (let ((n (- len (length s)))) - (apply #'concat - (make-string n ?\s) - (propertize s 'face `(:foreground ,(lsp-ui-imenu--get-color color-index))) - (let (bar-strings) - (dotimes (i depth) - (push - (propertize (lsp-ui-imenu--get-bar bars i depth for-title is-last) - 'face `(:foreground - ,(lsp-ui-imenu--get-color (+ color-index i)))) - bar-strings)) - (reverse bar-strings))))) + (apply #'concat + (make-string n ?\s) + (propertize s 'face `(:foreground ,(lsp-ui-imenu--get-color color-index))) + (let (bar-strings) + (dotimes (i depth) + (push + (propertize (lsp-ui-imenu--get-bar bars i depth for-title is-last) + 'face `(:foreground + ,(lsp-ui-imenu--get-color (+ color-index i)))) + bar-strings)) + (reverse bar-strings))))) (defun lsp-ui-imenu--get-bar (bars index depth for-title is-last) (cond @@ -142,14 +142,14 @@ ie. it will not be affected by `balance-windows' etc." (defun lsp-ui-imenu--make-line (title index entry padding bars depth color-index is-last) (let* ((prefix (if (and (= index 0) (eq lsp-ui-imenu-kind-position 'left)) title " ")) - (text (concat (lsp-ui-imenu--pad prefix padding bars depth color-index nil is-last) - (propertize (car entry) 'face 'default) - "\n")) - (len (length text))) - (add-text-properties 0 len `(index ,index title ,title marker ,(cdr entry) - padding ,padding depth, depth) - text) - text)) + (text (concat (lsp-ui-imenu--pad prefix padding bars depth color-index nil is-last) + (propertize (car entry) 'face 'default) + "\n")) + (len (length text))) + (add-text-properties 0 len `(index ,index title ,title marker ,(cdr entry) + padding ,padding depth, depth) + text) + text)) (defvar-local lsp-ui-imenu-ov nil "Variable that holds overlay for imenu.") @@ -157,66 +157,66 @@ ie. it will not be affected by `balance-windows' etc." (defun lsp-ui-imenu--make-ov nil "Make imenu overlay." (or (and (overlayp lsp-ui-imenu-ov) lsp-ui-imenu-ov) - (setq lsp-ui-imenu-ov (make-overlay 1 1)))) + (setq lsp-ui-imenu-ov (make-overlay 1 1)))) (defun lsp-ui-imenu--post-command nil "Post command hook for imenu." (when (eobp) (forward-line -1)) (lsp-ui-imenu--move-to-name-beginning) (when (eq lsp-ui-imenu-kind-position 'left) - (save-excursion - (when (overlayp lsp-ui-imenu-ov) - (overlay-put lsp-ui-imenu-ov 'display nil)) - (redisplay) - (goto-char (window-start)) - (if (= (get-text-property (point) 'index) 0) - (when (overlayp lsp-ui-imenu-ov) (delete-overlay lsp-ui-imenu-ov)) - (let* ((ov (lsp-ui-imenu--make-ov)) - (padding (get-text-property (point) 'padding)) - (title (get-text-property (point) 'title)) - (text (buffer-substring (+ (line-beginning-position) padding) (line-end-position)))) - (move-overlay ov (line-beginning-position) (line-end-position)) - (overlay-put ov 'display `(string ,(concat (let ((n (- padding (length title)))) - (propertize (concat (make-string n ?\s) title))) - text)))))))) + (save-excursion + (when (overlayp lsp-ui-imenu-ov) + (overlay-put lsp-ui-imenu-ov 'display nil)) + (redisplay) + (goto-char (window-start)) + (if (= (get-text-property (point) 'index) 0) + (when (overlayp lsp-ui-imenu-ov) (delete-overlay lsp-ui-imenu-ov)) + (let* ((ov (lsp-ui-imenu--make-ov)) + (padding (get-text-property (point) 'padding)) + (title (get-text-property (point) 'title)) + (text (buffer-substring (+ (line-beginning-position) padding) (line-end-position)))) + (move-overlay ov (line-beginning-position) (line-end-position)) + (overlay-put ov 'display `(string ,(concat (let ((n (- padding (length title)))) + (propertize (concat (make-string n ?\s) title))) + text)))))))) (defun lsp-ui-imenu--move-to-name-beginning () (-when-let* ((padding (get-char-property (point) 'padding)) - (depth (get-char-property (point) 'depth))) - (goto-char (+ (* depth 3) (line-beginning-position) padding)))) + (depth (get-char-property (point) 'depth))) + (goto-char (+ (* depth 3) (line-beginning-position) padding)))) (defvar lsp-ui-imenu--origin nil) (defun lsp-ui-imenu--put-separator nil (let ((ov (make-overlay (point) (point)))) - (overlay-put ov 'after-string (propertize "\n" 'face '(:height 0.6))) - (overlay-put ov 'priority 0))) + (overlay-put ov 'after-string (propertize "\n" 'face '(:height 0.6))) + (overlay-put ov 'priority 0))) (defvar-local overlay-priority 0) (defun lsp-ui-imenu--put-toplevel-title (title color-index) (if (eq lsp-ui-imenu-kind-position 'top) - (let ((ov (make-overlay (point) (point))) - (color (lsp-ui-imenu--get-color color-index))) - (overlay-put - ov 'after-string - (concat (propertize "\n" 'face '(:height 0.6)) - (propertize title 'face `(:foreground ,color)) - "\n" - (propertize "\n" 'face '(:height 0.6)))) + (let ((ov (make-overlay (point) (point))) + (color (lsp-ui-imenu--get-color color-index))) + (overlay-put + ov 'after-string + (concat (propertize "\n" 'face '(:height 0.6)) + (propertize title 'face `(:foreground ,color)) + "\n" + (propertize "\n" 'face '(:height 0.6)))) (overlay-put ov 'priority (setq overlay-priority (1- overlay-priority)))) - ;; Left placement, title is put with the first sub item. Only put a separator here. - (lsp-ui-imenu--put-separator))) + ;; Left placement, title is put with the first sub item. Only put a separator here. + (lsp-ui-imenu--put-separator))) (defun lsp-ui-imenu--put-subtitle (title padding bars depth color-index is-last) (let ((ov (make-overlay (point) (point))) - (title-color (lsp-ui-imenu--get-color (+ color-index depth)))) - (overlay-put - ov 'after-string - (concat (lsp-ui-imenu--pad " " padding bars depth color-index t is-last) - (propertize title 'face `(:foreground ,title-color)) - (propertize "\n" 'face '(:height 1)))) - (overlay-put ov 'priority (setq overlay-priority (1- overlay-priority))))) + (title-color (lsp-ui-imenu--get-color (+ color-index depth)))) + (overlay-put + ov 'after-string + (concat (lsp-ui-imenu--pad " " padding bars depth color-index t is-last) + (propertize title 'face `(:foreground ,title-color)) + (propertize "\n" 'face '(:height 1)))) + (overlay-put ov 'priority (setq overlay-priority (1- overlay-priority))))) (defun lsp-ui-imenu--insert-items (title items padding bars depth color-index) "Insert ITEMS for TITLE. @@ -232,46 +232,46 @@ COLOR-INDEX is the index of the color of the leftmost bar. Return the updated COLOR-INDEX." (--each-indexed items - (let ((is-last (= (1+ it-index) (length items)))) - (if (imenu--subalist-p it) - (-let* (((sub-title . entries) it)) - (if (= depth 0) - (lsp-ui-imenu--put-toplevel-title sub-title color-index) - (lsp-ui-imenu--put-subtitle sub-title padding bars depth color-index is-last)) - (when (and is-last (> depth 0)) - (aset bars (1- depth) nil)) - (let ((lsp-ui-imenu-kind-position (if (> depth 0) 'top - lsp-ui-imenu-kind-position))) - (lsp-ui-imenu--insert-items sub-title - entries - padding - bars - (1+ depth) - color-index)) - (when (and is-last (> depth 0)) - (aset bars (1- depth) t)) - (when (= depth 0) - (setq color-index (1+ color-index)))) - (insert (lsp-ui-imenu--make-line title it-index it - padding bars depth color-index - is-last))))) + (let ((is-last (= (1+ it-index) (length items)))) + (if (imenu--subalist-p it) + (-let* (((sub-title . entries) it)) + (if (= depth 0) + (lsp-ui-imenu--put-toplevel-title sub-title color-index) + (lsp-ui-imenu--put-subtitle sub-title padding bars depth color-index is-last)) + (when (and is-last (> depth 0)) + (aset bars (1- depth) nil)) + (let ((lsp-ui-imenu-kind-position (if (> depth 0) 'top + lsp-ui-imenu-kind-position))) + (lsp-ui-imenu--insert-items sub-title + entries + padding + bars + (1+ depth) + color-index)) + (when (and is-last (> depth 0)) + (aset bars (1- depth) t)) + (when (= depth 0) + (setq color-index (1+ color-index)))) + (insert (lsp-ui-imenu--make-line title it-index it + padding bars depth color-index + is-last))))) color-index) (defun lsp-ui-imenu--get-padding (items) "Get imenu padding determined by `lsp-ui-imenu-kind-position'. -ITEMS are used when the kind position is 'left." +ITEMS are used when the kind position is `left." (cl-case lsp-ui-imenu-kind-position - (top 1) - (left (--> (-filter 'imenu--subalist-p items) - (--map (length (car it)) it) - (-max (or it '(1))))) - (t (user-error "Invalid value for imenu's kind position: %s" lsp-ui-imenu-kind-position)))) + (top 1) + (left (--> (-filter 'imenu--subalist-p items) + (--map (length (car it)) it) + (-max (or it '(1))))) + (t (user-error "Invalid value for imenu's kind position: %s" lsp-ui-imenu-kind-position)))) (defun lsp-ui-imenu--put-bit (bits offset) - (logior bits (lsh 1 offset))) + (logior bits (ash 1 offset))) (defun lsp-ui-imenu--clear-bit (bits offset) - (logand bits (lognot (lsh 1 offset)))) + (logand bits (lognot (ash 1 offset)))) (defvar lsp-ui-imenu-buffer-name "*lsp-ui-imenu*" "Buffer name for imenu buffers.") @@ -279,29 +279,29 @@ ITEMS are used when the kind position is 'left." (defun lsp-ui-imenu--refresh-content () "Refresh imenu content menu" (let ((imenu-auto-rescan t)) - (setq lsp-ui-imenu--origin (current-buffer)) - (imenu--make-index-alist) - (let ((imenu-buffer (get-buffer-create lsp-ui-imenu-buffer-name)) - (list imenu--index-alist)) - (with-current-buffer imenu-buffer - (let* ((padding (lsp-ui-imenu--get-padding list)) - (grouped-by-subs (-partition-by 'imenu--subalist-p list)) - (color-index 0) - (bars (make-bool-vector lsp-ui-imenu--max-bars t)) - (inhibit-read-only t)) - (remove-overlays) - (erase-buffer) - (dolist (group grouped-by-subs) - (if (imenu--subalist-p (car group)) - (setq color-index (lsp-ui-imenu--insert-items "" group padding bars 0 color-index)) - (lsp-ui-imenu--put-separator) - (lsp-ui-imenu--insert-items "" group padding bars 1 color-index) - (setq color-index (1+ color-index)))) - (lsp-ui-imenu-mode) - (when lsp-ui-imenu--custom-mode-line-format - (setq mode-line-format lsp-ui-imenu--custom-mode-line-format)) - (goto-char (point-min)) - (add-hook 'post-command-hook 'lsp-ui-imenu--post-command nil t)))))) + (setq lsp-ui-imenu--origin (current-buffer)) + (imenu--make-index-alist) + (let ((imenu-buffer (get-buffer-create lsp-ui-imenu-buffer-name)) + (list imenu--index-alist)) + (with-current-buffer imenu-buffer + (let* ((padding (lsp-ui-imenu--get-padding list)) + (grouped-by-subs (-partition-by 'imenu--subalist-p list)) + (color-index 0) + (bars (make-bool-vector lsp-ui-imenu--max-bars t)) + (inhibit-read-only t)) + (remove-overlays) + (erase-buffer) + (dolist (group grouped-by-subs) + (if (imenu--subalist-p (car group)) + (setq color-index (lsp-ui-imenu--insert-items "" group padding bars 0 color-index)) + (lsp-ui-imenu--put-separator) + (lsp-ui-imenu--insert-items "" group padding bars 1 color-index) + (setq color-index (1+ color-index)))) + (lsp-ui-imenu-mode) + (when lsp-ui-imenu--custom-mode-line-format + (setq mode-line-format lsp-ui-imenu--custom-mode-line-format)) + (goto-char (point-min)) + (add-hook 'post-command-hook 'lsp-ui-imenu--post-command nil t)))))) (defun lsp-ui-imenu nil "Open ui-imenu in side window." @@ -310,25 +310,25 @@ ITEMS are used when the kind position is 'left." (setq lsp-ui-imenu--origin (current-buffer)) (imenu--make-index-alist) (let ((imenu-buffer (get-buffer-create lsp-ui-imenu-buffer-name))) - (lsp-ui-imenu--refresh-content) - (let ((win (display-buffer-in-side-window imenu-buffer - `((side . ,(if (eq lsp-ui-imenu-buffer-position 'left) - 'left + (lsp-ui-imenu--refresh-content) + (let ((win (display-buffer-in-side-window imenu-buffer + `((side . ,(if (eq lsp-ui-imenu-buffer-position 'left) + 'left 'right)))))) - (set-window-margins win 1) - (select-window win) - (set-window-start win 1) - (lsp-ui-imenu--move-to-name-beginning) - (set-window-dedicated-p win t) - (let ((window-size-fixed)) ;; Temporarily set `window-size-fixed' to nil for resizing. + (set-window-margins win 1) + (select-window win) + (set-window-start win 1) + (lsp-ui-imenu--move-to-name-beginning) + (set-window-dedicated-p win t) + (let ((window-size-fixed)) ;; Temporarily set `window-size-fixed' to nil for resizing. ;; When `lsp-ui-imenu-window-width' is 0, fit window to buffer: (if (= lsp-ui-imenu-window-width 0) - (let ((fit-window-to-buffer-horizontally 'only)) - (fit-window-to-buffer win) - (window-resize win 3 t)) - (let ((x (- lsp-ui-imenu-window-width (window-width)))) - (window-resize (selected-window) x t)))) - ))) + (let ((fit-window-to-buffer-horizontally 'only)) + (fit-window-to-buffer win) + (window-resize win 3 t)) + (let ((x (- lsp-ui-imenu-window-width (window-width)))) + (window-resize (selected-window) x t)))) + ))) (defun lsp-ui-imenu--kill nil "Kill imenu window." @@ -338,11 +338,11 @@ ITEMS are used when the kind position is 'left." (defun lsp-ui-imenu--jump (direction) (let ((current (get-text-property (point) 'title))) - (forward-line direction) - (while (and current - (not (= (line-number-at-pos) 1)) - (equal current (get-text-property (point) 'title))) - (forward-line direction)))) + (forward-line direction) + (while (and current + (not (= (line-number-at-pos) 1)) + (equal current (get-text-property (point) 'title))) + (forward-line direction)))) (defun lsp-ui-imenu--next-kind nil "Jump to next kind of imenu." @@ -354,34 +354,34 @@ ITEMS are used when the kind position is 'left." (interactive) (lsp-ui-imenu--jump -1) (while (not (= (get-text-property (point) 'index) 0)) - (forward-line -1))) + (forward-line -1))) (defun lsp-ui-imenu--visit nil (interactive) (let ((marker (get-text-property (point) 'marker))) - (select-window (get-buffer-window lsp-ui-imenu--origin)) - (goto-char marker) - (pulse-momentary-highlight-one-line (point) 'next-error))) + (select-window (get-buffer-window lsp-ui-imenu--origin)) + (goto-char marker) + (pulse-momentary-highlight-one-line (point) 'next-error))) (defun lsp-ui-imenu--view nil (interactive) (let ((marker (get-text-property (point) 'marker))) - (with-selected-window (get-buffer-window lsp-ui-imenu--origin) - (goto-char marker) - (recenter) - (pulse-momentary-highlight-one-line (point) 'next-error)))) + (with-selected-window (get-buffer-window lsp-ui-imenu--origin) + (goto-char marker) + (recenter) + (pulse-momentary-highlight-one-line (point) 'next-error)))) (defvar lsp-ui-imenu-mode-map (let ((map (make-sparse-keymap))) - (define-key map (kbd "q") 'lsp-ui-imenu--kill) - (define-key map (kbd "r") 'lsp-ui-imenu--refresh) - (define-key map (kbd "") 'lsp-ui-imenu--next-kind) - (define-key map (kbd "") 'lsp-ui-imenu--prev-kind) - (define-key map (kbd "") 'lsp-ui-imenu--view) - (define-key map (kbd "") 'lsp-ui-imenu--visit) - (define-key map (kbd "RET") 'lsp-ui-imenu--view) - (define-key map (kbd "M-RET") 'lsp-ui-imenu--visit) - map) + (define-key map (kbd "q") 'lsp-ui-imenu--kill) + (define-key map (kbd "r") 'lsp-ui-imenu--refresh) + (define-key map (kbd "") 'lsp-ui-imenu--next-kind) + (define-key map (kbd "") 'lsp-ui-imenu--prev-kind) + (define-key map (kbd "") 'lsp-ui-imenu--view) + (define-key map (kbd "") 'lsp-ui-imenu--visit) + (define-key map (kbd "RET") 'lsp-ui-imenu--view) + (define-key map (kbd "M-RET") 'lsp-ui-imenu--visit) + map) "Keymap for ‘lsp-ui-peek-mode’.") (define-derived-mode lsp-ui-imenu-mode special-mode "lsp-ui-imenu" @@ -392,41 +392,41 @@ ITEMS are used when the kind position is 'left." "Safe refresh imenu content." (interactive) (let ((imenu-buffer (get-buffer lsp-ui-imenu-buffer-name))) - (when imenu-buffer - (save-selected-window - (if (equal (current-buffer) imenu-buffer) - (select-window (get-buffer-window lsp-ui-imenu--origin)) - (setq lsp-ui-imenu--origin (current-buffer))) - (lsp-ui-imenu--refresh-content))))) + (when imenu-buffer + (save-selected-window + (if (equal (current-buffer) imenu-buffer) + (select-window (get-buffer-window lsp-ui-imenu--origin)) + (setq lsp-ui-imenu--origin (current-buffer))) + (lsp-ui-imenu--refresh-content))))) (defun lsp-ui-imenu--start-refresh (&rest _) "Starts the auto refresh timer." (lsp-ui-util-safe-kill-timer lsp-ui-imenu--refresh-timer) (setq lsp-ui-imenu--refresh-timer - (run-with-idle-timer lsp-ui-imenu-auto-refresh-delay nil #'lsp-ui-imenu--refresh))) + (run-with-idle-timer lsp-ui-imenu-auto-refresh-delay nil #'lsp-ui-imenu--refresh))) (defun lsp-ui-imenu-buffer--enable () "Enable `lsp-ui-imenu-buffer'." (when lsp-ui-imenu-auto-refresh - (cl-case lsp-ui-imenu-auto-refresh - (after-save - (add-hook 'after-save-hook #'lsp-ui-imenu--start-refresh nil t)) - (t - (add-hook 'after-change-functions #'lsp-ui-imenu--start-refresh nil t) - (add-hook 'after-save-hook #'lsp-ui-imenu--start-refresh nil t))))) + (cl-case lsp-ui-imenu-auto-refresh + (after-save + (add-hook 'after-save-hook #'lsp-ui-imenu--start-refresh nil t)) + (t + (add-hook 'after-change-functions #'lsp-ui-imenu--start-refresh nil t) + (add-hook 'after-save-hook #'lsp-ui-imenu--start-refresh nil t))))) (defun lsp-ui-imenu-buffer--disable () "Disable `lsp-ui-imenu-buffer'." (when lsp-ui-imenu-auto-refresh - (cl-case lsp-ui-imenu-auto-refresh - (after-save - (remove-hook 'after-save-hook #'lsp-ui-imenu--start-refresh t)) - (t - (remove-hook 'after-change-functions #'lsp-ui-imenu--start-refresh t) - (remove-hook 'after-save-hook #'lsp-ui-imenu--start-refresh t))))) + (cl-case lsp-ui-imenu-auto-refresh + (after-save + (remove-hook 'after-save-hook #'lsp-ui-imenu--start-refresh t)) + (t + (remove-hook 'after-change-functions #'lsp-ui-imenu--start-refresh t) + (remove-hook 'after-save-hook #'lsp-ui-imenu--start-refresh t))))) (define-minor-mode lsp-ui-imenu-buffer-mode - "Minor mode 'lsp-ui-imenu-buffer-mode'." + "Minor mode `lsp-ui-imenu-buffer-mode'." :group lsp-ui-imenu (if lsp-ui-imenu-buffer-mode (lsp-ui-imenu-buffer--enable) (lsp-ui-imenu-buffer--disable))) diff --git a/lsp-ui-peek.el b/lsp-ui-peek.el index 6c8d74dc..1cef9ac7 100644 --- a/lsp-ui-peek.el +++ b/lsp-ui-peek.el @@ -70,10 +70,10 @@ (defcustom lsp-ui-peek-fontify 'on-demand "Whether to fontify chunks of code (use semantics colors). -WARNING: 'always can heavily slow the processing when +WARNING: `always can heavily slow the processing when `lsp-ui-peek-expand-function' expands more than 1 file. It is recommended to keep the default value of `lsp-ui-peek-expand-function' -when this variable is set to 'always." +when this variable is set to `always." :type '(choice (const :tag "Never" never) (const :tag "On demand" on-demand) (const :tag "Always" always)) @@ -147,7 +147,7 @@ The function takes one parameter: a list of cons where the car is the filename and the cdr is the number of references in that file. It should returns a list of filenames to expand. WARNING: If you change this variable and expand more than 1 file, it is -recommended to set `lsp-ui-peek-fontify' to 'never or 'on-demand, otherwise it +recommended to set `lsp-ui-peek-fontify' to `never or `on-demand, otherwise it will cause performances issues.") (defvar-local lsp-ui-peek--overlay nil) @@ -635,8 +635,8 @@ EXTRA is a plist of extra parameters." (append extra (lsp--text-document-position-params)))) (defun lsp-ui-peek--extract-chunk-from-buffer (pos start end) - "Return the chunk of code pointed to by POS (a Position object) in the current buffer. -START and END are delimiters." + "Return the chunk of code pointed to by POS (a Position object) in the +current buffer. START and END are delimiters." (let* ((point (lsp--position-to-point pos)) (inhibit-field-text-motion t) (line-start (1+ (- 1 (/ lsp-ui-peek-peek-height 2)))) diff --git a/lsp-ui-sideline.el b/lsp-ui-sideline.el index e0088223..7bee6e8d 100644 --- a/lsp-ui-sideline.el +++ b/lsp-ui-sideline.el @@ -325,8 +325,8 @@ CURRENT is non-nil when the point is on the symbol." (propertize str 'display (lsp-ui-sideline--compute-height))))) (defun lsp-ui-sideline--check-duplicate (symbol info) - "Check if there's already a SYMBOL containing INFO, unless `lsp-ui-sideline-ignore-duplicate' -is set to t." + "Check if there's already a SYMBOL containing INFO, unless +`lsp-ui-sideline-ignore-duplicate' is set to t." (not (when lsp-ui-sideline-ignore-duplicate (--any (and (string= (overlay-get it 'symbol) symbol) (string= (overlay-get it 'info) info)) @@ -435,7 +435,8 @@ is set to t." (lsp-ui-sideline--toggle-current ov nil)))))) (defun lsp-ui-sideline--split-long-lines (lines) - "Fill LINES so that they are not longer than `lsp-ui-sideline-diagnostic-max-line-length' characters." + "Fill LINES so that they are not longer than +`lsp-ui-sideline-diagnostic-max-line-length' characters." (cl-mapcan (lambda (line) (if (< (length line) lsp-ui-sideline-diagnostic-max-line-length) (list line) @@ -449,7 +450,8 @@ is set to t." (defun lsp-ui-sideline--diagnostics (buffer bol eol) "Show diagnostics belonging to the current line. Loop over flycheck errors with `flycheck-overlay-errors-in'. -Find appropriate position for sideline overlays with `lsp-ui-sideline--find-line'. +Find appropriate position for sideline overlays with +`lsp-ui-sideline--find-line'. Push sideline overlays on `lsp-ui-sideline--ovs'." (when (and (bound-and-true-p flycheck-mode) (bound-and-true-p lsp-ui-sideline-mode)