commit 6e123b4502246471ec37696d7def3b43f3514979
parent 2be4817ec4ddafed297afdc3cdb30158be982bfd
Author: andsy10 <andsy1016@gmail.com>
Date: Sun, 23 Aug 2026 01:35:06 +0800
Add speedbar integration
Diffstat:
5 files changed, 54 insertions(+), 1 deletion(-)
diff --git a/lisp/init-base.el b/lisp/init-base.el
@@ -266,5 +266,29 @@
tramp-auto-save-directory "~/.emacs.d/tramp-auto-save")
(setq tramp-completion-use-auth-sources nil))
+;; speedbar
+(use-package speedbar
+ :straight nil
+ :init
+ (setq speedbar-window-default-width 30)
+ :config
+ (if (boundp 'speedbar-prefer-window)
+ (setq speedbar-prefer-window t))
+ (setq speedbar-use-images nil)
+
+ (defun my-speedbar-line-expanded-p ()
+ "Return non-nil if the speedbar line at point is expanded."
+ (save-excursion
+ (beginning-of-line)
+ (and (re-search-forward ":\\s-*.\\([-+?]\\)" (line-end-position) t)
+ (equal (match-string 1) "-"))))
+
+ (defun my-speedbar-tab ()
+ "Expand or contract current line."
+ (interactive)
+ (if (my-speedbar-line-expanded-p)
+ (speedbar-contract-line)
+ (speedbar-expand-line))))
+
(provide 'init-base)
;;; init-base.el ends here
diff --git a/lisp/init-kbd-func.el b/lisp/init-kbd-func.el
@@ -35,6 +35,14 @@
(interactive)
(message "Emacs loaded in %s." (emacs-init-time)))
+(defun my-speedbar ()
+ "Run `speedbar-get-focus' if current buffer is not speedbar, otherwise run `speedbar'"
+ (interactive)
+ (if (not (boundp 'speedbar-buffer))
+ (speedbar)
+ (if (eq (current-buffer) speedbar-buffer)
+ (speedbar)
+ (speedbar-get-focus))))
(defun my-straight-packages-count ()
"Count how many straight.el package are currently installed."
diff --git a/lisp/init-kbd.el b/lisp/init-kbd.el
@@ -152,7 +152,7 @@
(general-def
:prefix "C-c d"
"a" #'dirvish-quick-access
- "s" #'dirvish-side
+ "s" #'my-speedbar
"h" #'dirvish-history-menu
"f" #'dirvish-fd
"F" #'dirvish-fd-switches-menu
@@ -210,6 +210,11 @@
"i" #'dirvish-file-info-menu
"y" #'dirvish-yank-menu)
+;; speedbar
+(general-def speedbar-mode-map
+ "^" #'speedbar-up-directory
+ "<tab>" #'my-speedbar-tab)
+
;; magit
(general-def (magit-mode-map tokei-mode-map)
"C-<tab>" #'my-magit-toggle-parent-section)
diff --git a/lisp/my-dark-theme.el b/lisp/my-dark-theme.el
@@ -143,6 +143,14 @@
`(proced-cpu ((,class (:foreground ,base0))))
`(proced-mem ((,class (:foreground ,base0))))
+ `(speedbar-separator-face ((,class (:foreground ,base03 :background ,blue))))
+ `(speedbar-file-face ((,class (:foreground ,base0))))
+ `(speedbar-tag-face ((,class (:foreground ,green))))
+ `(speedbar-button-face ((,class (:foreground ,base01))))
+ `(speedbar-selected-face ((,class (:inherit button))))
+ `(speedbar-directory-face ((,class (:foreground ,blue))))
+ `(speedbar-highlight-face ((,class (:foreground ,base1 :background ,base02))))
+
`(syncthing-bold ((,class (:inherit bold))))
`(syncthing-italic ((,class (:inherit italic))))
`(syncthing-my-id ((,class (:foreground ,blue :weight bold))))
diff --git a/lisp/my-light-theme.el b/lisp/my-light-theme.el
@@ -143,6 +143,14 @@
`(proced-cpu ((,class (:foreground ,base0))))
`(proced-mem ((,class (:foreground ,base0))))
+ `(speedbar-separator-face ((,class (:foreground ,base03 :background ,blue))))
+ `(speedbar-file-face ((,class (:foreground ,base0))))
+ `(speedbar-tag-face ((,class (:foreground ,green))))
+ `(speedbar-button-face ((,class (:foreground ,base01))))
+ `(speedbar-selected-face ((,class (:inherit button))))
+ `(speedbar-directory-face ((,class (:foreground ,blue))))
+ `(speedbar-highlight-face ((,class (:foreground ,base1 :background ,base02))))
+
`(syncthing-bold ((,class (:inherit bold))))
`(syncthing-italic ((,class (:inherit italic))))
`(syncthing-my-id ((,class (:foreground ,blue :weight bold))))