dotfiles/emacs-lisp/treemacs.org
Magic_RB 5453379403
Emacs koy compatibility
Signed-off-by: Magic_RB <magic_rb@redalder.org>
2021-11-22 16:48:26 +01:00

2.3 KiB
Raw Blame History

Treemacs

Treemacs is a file and project explorer similar to NeoTree or vims NerdTree, but largely inspired by the Project Explorer in Eclipse. It shows the file system outlines of your projects in a simple tree layout allowing quick navigation and exploration, while also possessing basic file management utilities.

Treemacs is really cool.

  (use-package treemacs
    :straight t
    :after (doom-themes)
    :config

Read input from a minibuffer not a child frame.

  (setq treemacs-read-string-input 'from-minibuffer)

Load the doom-colors theme, it looks nicer.

  (setq doom-themes-treemacs-theme "doom-colors")
  (doom-themes-treemacs-config)
  (treemacs-load-theme 'doom-colors)

Evil

Treemacs is nice, but evil Treemacs is even nicer! Enable Evil compatibility and my custom koy compatibility.

  (use-package treemacs-evil
    :after (treemacs evil)
    :straight t
    :init

We first have to define a new minor mode, magic_rb-koy-treemacs-mode, then hook it onto the existing treemacs-mode

  (define-minor-mode magic_rb-koy-treemacs-mode
    "Enable koy compatibility for Treemacs."
    :lighter " koy"
    :keymap (make-sparse-keymap)
    (evil-normalize-keymaps))
 (add-hook 'treemacs-mode-hook 'magic_rb-koy-treemacs-mode)

Then we actually populate the keymap using general.el.

  :after (general)
  :general
  (:states 'treemacs
           :predicate 'magic_rb-koy-compat-p
           :keymaps 'magic_rb-koy-treemacs-mode-map
           "t" 'ignore
           "r" 'treemacs-previous-line
           "n" 'treemacs-next-line
           "l" 'ignore))

LSP

Integration between Treemacs and LSP. Needs some work still.

  (use-package lsp-treemacs
    :straight t
    :after (lsp-mode treemacs)
    :config
    (lsp-treemacs-sync-mode 1))