Make neotree cooperate with popups and other window-changing actions
This commit is contained in:
parent
ea2372f025
commit
f376006284
3 changed files with 24 additions and 4 deletions
|
@ -55,8 +55,20 @@
|
|||
;; There is no shackle-popup hook, so I created one:
|
||||
(advice-add 'shackle-display-buffer :around 'doom*popup-init)
|
||||
;; Tell these functions not to mess with popups:
|
||||
(advice-add 'balance-windows :around 'doom*save-neotree)
|
||||
(advice-add 'balance-windows :around 'doom*save-popup)
|
||||
(advice-add 'doom/evil-window-move :around 'doom*save-popup))
|
||||
(advice-add 'doom/evil-window-move :around 'doom*save-popup)
|
||||
|
||||
(advice-add 'evil-window-move-very-bottom :around 'doom*save-popup)
|
||||
(advice-add 'evil-window-move-very-top :around 'doom*save-popup)
|
||||
(advice-add 'evil-window-move-far-left :around 'doom*save-popup)
|
||||
(advice-add 'evil-window-move-far-right :around 'doom*save-popup)
|
||||
|
||||
(advice-add 'evil-window-move-very-bottom :around 'doom*save-neotree)
|
||||
(advice-add 'evil-window-move-very-top :around 'doom*save-neotree)
|
||||
(advice-add 'evil-window-move-far-left :around 'doom*save-neotree)
|
||||
(advice-add 'evil-window-move-far-right :around 'doom*save-neotree)
|
||||
)
|
||||
|
||||
|
||||
;;
|
||||
|
|
|
@ -60,13 +60,14 @@
|
|||
(advice-add 'neotree-create-node :around 'doom*neotree-create-node)
|
||||
;; Prevents messing up the neotree buffer on window changes
|
||||
(advice-add 'doom/evil-window-move :around 'doom*save-neotree)
|
||||
(advice-add 'doom/popup-buffer :around 'doom*save-neotree)
|
||||
;; Adding keybindings to `neotree-mode-map' wouldn't work for me (they get
|
||||
;; overridden when the neotree buffer is spawned). So we bind them in a hook.
|
||||
(add-hook 'neo-after-create-hook 'doom|neotree-init-keymap)
|
||||
(defun doom|neotree-init-keymap (&rest _)
|
||||
(map! :Lm "\\\\" 'evil-window-prev
|
||||
:Lm "ESC ESC" 'neotree-hide
|
||||
:Lm "q" 'neotree-hide
|
||||
:Lm "ESC ESC" 'doom/neotree-close
|
||||
:Lm "q" 'doom/neotree-close
|
||||
:Lm [return] 'neotree-enter
|
||||
:Lm "RET" 'neotree-enter
|
||||
:Lm "<return>" 'neotree-enter
|
||||
|
|
|
@ -17,10 +17,17 @@
|
|||
(neotree-dir project-root))
|
||||
(neotree-find path project-root)))))
|
||||
|
||||
;;;###autoload
|
||||
(defun doom/neotree-close ()
|
||||
(interactive)
|
||||
(when (neo-global--window-exists-p)
|
||||
(with-selected-window neo-global--window
|
||||
(evil-window-delete))))
|
||||
|
||||
;;;###autoload
|
||||
(defmacro doom/neotree-save (&rest body)
|
||||
`(let ((neo-p (neo-global--window-exists-p)))
|
||||
(when neo-p (neotree-hide))
|
||||
(when neo-p (doom/neotree-close))
|
||||
,@body
|
||||
(when neo-p
|
||||
(save-selected-window
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue