.emacs.d/init.d/basics/ui.el

64 lines
2.3 KiB
EmacsLisp

;;; ui.el --- Configure user interfaces. -*- lexical-binding: t; -*-
;;; Commentary:
;; * treemacs
;;; Code:
;; Directory tree.
(require 'basics/package-management)
(use-package treemacs
:after (display-line-numbers doom-themes hl-line)
:commands (my/treemacs-show-maybe)
:custom ((treemacs-project-follow-cleanup t) ; Collapse projects when leaving.
(treemacs-silent-refresh t)) ; No log message on refresh.
:config (progn
;; (treemacs-tag-follow-mode)
(make-face 'hl-line-treemacs-face)
(when (>= emacs-major-version 27)
(set-face-attribute 'hl-line-treemacs-face nil
:extend t))
(defun my/treemacs-set-hl-line ()
(set (make-local-variable 'hl-line-face)
'hl-line-treemacs-face))
(defun my/treemacs-show-maybe ()
(when (and (>= (frame-width) 120)
(file-exists-p treemacs-persist-file)
(<= (length (frame-list)) 2))
(treemacs-select-window)
(other-window 1))))
:bind (("<f9>" . treemacs-select-window) ; Focus treemacs.
("C-<f9>" . treemacs) ; Toggle treemacs.
("M-<f9>" . treemacs-add-and-display-current-project)
(:map treemacs-mode-map
("<mouse-1>" . treemacs-single-click-expand-action)))
:hook ((treemacs-mode . my/disable-line-numbers)
(treemacs-mode . my/treemacs-set-hl-line)
(after-init . (lambda () (when (display-graphic-p)
(my/treemacs-show-maybe))))
(server-after-make-frame . my/treemacs-show-maybe)))
(use-package treemacs-projectile
:demand t
:after (treemacs projectile))
(use-package treemacs-magit
:demand t
:after (treemacs magit))
;; Shows tabs of all visible buffers per window.
(when (>= emacs-major-version 27)
(use-package tab-line
:defer 4
:custom-face
(tab-line ((t (:inherit ruler-mode-default))))
(tab-line-tab ((t (:inherit ruler-mode-default))))
(tab-line-tab-inactive ((t (:inherit tab-line-tab))))
(tab-line-tab-current ((t (:inherit ruler-mode-fill-column))))
(tab-line-highlight ((t (:inherit tab-line-tab-current))))))
(provide 'basics/ui)
;;; ui.el ends here