filetrees: remap winum-select-window-0-or-10

Problem:
`C-x w 0` calls `winum-select-window-0-or-10` which shows:
winum-select-window-by-number: No window numbered 10

Solution (Thanks Miciah):
Remap `winum-select-window-0-or-10` to the current filetree command:
`neotree-show` or `treemacs-select-window`

Then all three key bindings:
`C-x w 0`, `SPC 0` and `M-0` will call the same filetree command.

Additionally:
Renamed the remapped which-key name to the filetree command.

Wrapped lines to keep them under 80 chars.
This commit is contained in:
duianto 2018-09-10 19:55:44 +02:00 committed by duianto
parent e1cde25da6
commit 8a4bf9c655
3 changed files with 20 additions and 8 deletions

View File

@ -1785,6 +1785,8 @@ Other:
- ~SPC 0~ and ~M-0~ are consistent across Neotree and Treemacs
- Fixed ~RET~ binding functionality (thanks to Lupco Kotev)
- Use "open" instead of "xdg-open" on macos (thanks to Alexander-Miller)
- Remapped =winum-select-window-0-or-10= to =neotree-show= so that ~C-x w 0~,
~SPC 0~ and ~M-0~ call the same command (thanks to duianto and Miciah)
**** NixOS
- Enabled Flycheck (thanks to William Casarin)
- Defer loading (thanks to Benno Fünfstück)
@ -2307,6 +2309,8 @@ Other:
**** Treemacs
- =Treemacs= replaces =NeoTree= as the default sidebar
- Add missing ~SPC p t~ to =readme.org= (thanks to oo6)
- Remapped =winum-select-window-0-or-10= to =treemacs-select-window= so that
~C-x w 0~, ~SPC 0~ and ~M-0~ call the same command (thanks to duianto, Miciah)
**** Typescript
- Call tsfmt with extension of current buffer for TSX formatting
(thanks to Victor Andrée)

View File

@ -116,7 +116,10 @@ Navigation^^^^ Actions^^ Visual actions/config^^^
(defun neotree/pre-init-winum ()
(spacemacs|use-package-add-hook winum
:post-config
;; window 0 is reserved for file trees
(spacemacs/set-leader-keys "0" #'neotree-show)
(define-key winum-keymap (kbd "M-0") #'neotree-show)
(add-to-list 'winum-assign-functions #'spacemacs//winum-neotree-assign-func)))
;; `0', `M-0' and `C-x w 0' are bound to `winum-select-window-0-or-10'
(define-key winum-keymap [remap winum-select-window-0-or-10] #'neotree-show)
;; replace the which-key name
(push '((nil . "winum-select-window-0-or-10") . (nil . "neotree-show"))
which-key-replacement-alist)
(add-to-list 'winum-assign-functions
#'spacemacs//winum-neotree-assign-func)))

View File

@ -85,10 +85,15 @@
(spacemacs|use-package-add-hook winum
:post-config
(progn
;; window 0 is reserved for file trees
(spacemacs/set-leader-keys "0" 'treemacs-select-window)
(define-key winum-keymap (kbd "M-0") 'treemacs-select-window)
;; `0', `M-0' and `C-x w 0' are bound to `winum-select-window-0-or-10'
(define-key winum-keymap
[remap winum-select-window-0-or-10] #'treemacs-select-window)
;; replace the which-key name
(push '((nil . "winum-select-window-0-or-10") .
(nil . "treemacs-select-window"))
which-key-replacement-alist)
(with-eval-after-load 'treemacs
(dolist (n (number-sequence 1 5))
(add-to-list 'winum-ignored-buffers
(format "%sFramebuffer-%s*" treemacs--buffer-name-prefix n)))))))
(format "%sFramebuffer-%s*"
treemacs--buffer-name-prefix n)))))))