Skip to content

Commit 267a2c9

Browse files
DivvyCrbrotzeit
authored andcommitted
Add an option that will impose window-size-fixed on imenu buffer.
1 parent 11a3a65 commit 267a2c9

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

lsp-ui-imenu.el

+17-8
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@
6262
(const :tag "Right" right))
6363
:group 'lsp-ui-imenu)
6464

65+
(defcustom lsp-ui-imenu-persistent-buffer nil
66+
"If non-nil, the `lsp-ui-imenu' buffer will permanently maintain its size.
67+
ie. it will not be affected by `balance-windows' etc."
68+
:type 'boolean
69+
:group 'lsp-ui-imenu)
70+
6571
(defcustom lsp-ui-imenu-colors '("deep sky blue" "green3")
6672
"Color list to cycle through for entry groups."
6773
:type '(repeat color)
@@ -314,13 +320,15 @@ ITEMS are used when the kind position is 'left."
314320
(set-window-start win 1)
315321
(lsp-ui-imenu--move-to-name-beginning)
316322
(set-window-dedicated-p win t)
317-
;; when `lsp-ui-imenu-window-width' is 0, fit window to buffer
318-
(if (= lsp-ui-imenu-window-width 0)
319-
(let ((fit-window-to-buffer-horizontally 'only))
320-
(fit-window-to-buffer win)
321-
(window-resize win 3 t))
322-
(let ((x (- lsp-ui-imenu-window-width (window-width))))
323-
(window-resize (selected-window) x t))))))
323+
(let ((window-size-fixed)) ;; Temporarily set `window-size-fixed' to nil for resizing.
324+
;; When `lsp-ui-imenu-window-width' is 0, fit window to buffer:
325+
(if (= lsp-ui-imenu-window-width 0)
326+
(let ((fit-window-to-buffer-horizontally 'only))
327+
(fit-window-to-buffer win)
328+
(window-resize win 3 t))
329+
(let ((x (- lsp-ui-imenu-window-width (window-width))))
330+
(window-resize (selected-window) x t))))
331+
)))
324332

325333
(defun lsp-ui-imenu--kill nil
326334
"Kill imenu window."
@@ -377,7 +385,8 @@ ITEMS are used when the kind position is 'left."
377385
"Keymap for ‘lsp-ui-peek-mode’.")
378386

379387
(define-derived-mode lsp-ui-imenu-mode special-mode "lsp-ui-imenu"
380-
"Mode showing imenu entries.")
388+
"Mode showing imenu entries."
389+
(setq window-size-fixed (if lsp-ui-imenu-persistent-buffer 'width nil)))
381390

382391
(defun lsp-ui-imenu--refresh ()
383392
"Safe refresh imenu content."

0 commit comments

Comments
 (0)