This is a collection of dotfiles and scripts for my bspwm setup
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

254 lines
6.8 KiB

#+TITLE: UI
#+OPTIONS: toc:nil
#+PROPERTY: header-args:emacs-lisp :shebang ";;; -*- lexical-binding: t; -*-\n"
** Table of Contents :toc_4:
- [[#all-the-icons][All the icons]]
- [[#centaur-tabs][Centaur Tabs]]
- [[#dashboard][Dashboard]]
- [[#helpful][Helpful]]
- [[#neotree][NeoTree]]
- [[#telephone-line][Telephone Line]]
- [[#theme][Theme]]
- [[#which-key][Which-key]]
** All the icons
#+BEGIN_SRC emacs-lisp
(use-package all-the-icons
:defer t
:config
;; Install all-the-icons if font files are not found
(unless (find-font (font-spec :name "all-the-icons"))
(all-the-icons-install-fonts t)))
(use-package all-the-icons-dired
:after all-the-icons
:hook (dired-mode . all-the-icons-dired-mode)
:config (setq all-the-icons-dired-monochrome nil))
#+END_SRC
** Centaur Tabs
Places buffers as tabs in a bar at the top of the frame.
#+BEGIN_SRC emacs-lisp
(use-package centaur-tabs
:after all-the-icons
:demand
:hook
((eshell-mode
help-mode
helpful-mode
mu4e-view-mode
neotree-mode
shell-mode)
. centaur-tabs-local-mode)
:config
(setq centaur-tabs-enable-ido-completion nil)
(setq centaur-tabs-height (if dot/hidpi 38 18))
(setq centaur-tabs-modified-marker "•")
(setq centaur-tabs-set-icons t)
(setq centaur-tabs-set-modified-marker t)
(setq centaur-tabs-style "slant")
(setq centaur-tabs-project-buffer-group-calc nil)
(defun centaur-tabs-buffer-groups ()
"Organize tabs into groups by buffer."
(unless centaur-tabs-project-buffer-group-calc
(set (make-local-variable 'centaur-tabs-project-buffer-group-calc)
(list
(cond
((string-equal "*" (substring (buffer-name) 0 1)) "Emacs")
((or (memq major-mode '(magit-process-mode
magit-status-mode
magit-diff-mode
magit-log-mode
magit-file-mode
magit-blob-mode
magit-blame-mode))
(string= (buffer-name) "COMMIT_EDITMSG")) "Magit")
((project-current) (dot/project-project-name))
((memq major-mode '(org-mode
emacs-lisp-mode)) "Org Mode")
((derived-mode-p 'dired-mode) "Dired")
((derived-mode-p 'prog-mode
'text-mode) "Editing")
(t "Other")))))
(symbol-value 'centaur-tabs-project-buffer-group-calc))
(defun centaur-tabs-hide-tab (buffer)
"Hide from the tab bar by BUFFER name."
(let ((name (format "%s" buffer)))
(or
;; Current window is dedicated window
(window-dedicated-p (selected-window))
;; Buffer name matches below blacklist
(string-match-p "^ ?\\*.*\\*" name))))
(defun dot/centaur-tabs-is-buffer-unimportant (buffer)
"Return t if BUFFER is unimportant and can be killed without caution."
(let ((name (format "%s" buffer)))
(cond
((centaur-tabs-hide-tab name) t)
((string-match-p "^magit\\(-[a-z]+\\)*: .*" name) t)
(t nil))))
(defun dot/centaur-tabs-buffer-cleanup ()
"Clean up all the hidden buffers."
(interactive)
(dolist (buffer (buffer-list))
(when (dot/centaur-tabs-is-buffer-unimportant buffer)
(kill-buffer buffer)))
(princ "Cleaned buffers"))
(defun dot/centaur-tabs-kill-buffer-or-window ()
"Delete window of the current buffer, also kill if the buffer is hidden."
(interactive)
(if (dot/centaur-tabs-is-buffer-unimportant (buffer-name))
(kill-buffer-and-window)
(delete-window)))
(centaur-tabs-headline-match)
(centaur-tabs-mode))
#+END_SRC
** Dashboard
#+BEGIN_SRC emacs-lisp
(use-package page-break-lines)
(use-package dashboard
:demand
:hook (dashboard-mode . dot/hook-disable-line-numbers)
:config
(setq initial-buffer-choice (lambda () (get-buffer "*dashboard*")))
(setq dashboard-banner-logo-title "GNU Emacs master race!")
(setq dashboard-center-content t)
(setq dashboard-page-separator "\n\f\n")
(setq dashboard-projects-backend 'project-el)
(setq dashboard-set-file-icons t)
(setq dashboard-set-footer nil)
(setq dashboard-set-heading-icons t)
(setq dashboard-show-shortcuts t)
(setq dashboard-startup-banner 'logo)
(setq dashboard-items '((projects . 10)
(bookmarks . 5)
(recents . 5)))
(defun dot/dashboard-goto ()
"Go to the *dashboard* buffer, create if non-existing."
(interactive)
(let ((buffer "*dashboard*"))
(unless (get-buffer buffer)
(generate-new-buffer buffer)
(dashboard-refresh-buffer))
(switch-to-buffer buffer)))
;; Fix keybinds..
(defun dot/dashboard-goto-bookmarks ()
"Move point to bookmarks."
(interactive)
(funcall (local-key-binding "m")))
(defun dot/dashboard-goto-projects ()
"Move point to projects."
(interactive)
(funcall (local-key-binding "p")))
(defun dot/dashboard-goto-recent-files ()
"Move point to recent files."
(interactive)
(funcall (local-key-binding "r")))
(dashboard-setup-startup-hook))
#+END_SRC
** Helpful
A better *help* buffer.
#+BEGIN_SRC emacs-lisp
(use-package helpful
:hook (helpful-mode . dot/hook-disable-line-numbers))
#+END_SRC
** NeoTree
Provides Emacs with a file tree.
#+BEGIN_SRC emacs-lisp
(use-package neotree
:after all-the-icons
:hook (neotree-mode . dot/hook-disable-line-numbers)
:hook (neotree-mode . hl-line-mode)
:init
;; This needs to be in init to actually start loading the package
(with-eval-after-load 'project
(defun neotree-toggle-in-project-root ()
"Toggle Neotree in project root."
(interactive)
(let ((default-directory (dot/find-project-root)))
(call-interactively #'neotree-toggle))))
:config
(setq neo-theme (if (display-graphic-p) 'icons 'arrow))
(setq neo-autorefresh nil)
(setq neo-mode-line-type 'none)
(setq neo-show-hidden-files t)
(setq neo-vc-integration '(face)))
#+END_SRC
** Telephone Line
Emacs mode line replacement.
#+BEGIN_SRC emacs-lisp
(use-package telephone-line
:config
(setq telephone-line-height (if dot/hidpi 30 15))
(setq telephone-line-lhs
'((evil . (telephone-line-evil-tag-segment))
(accent . (telephone-line-erc-modified-channels-segment
telephone-line-process-segment
telephone-line-buffer-segment))
(nil . (telephone-line-project-segment))))
(telephone-line-mode))
#+END_SRC
** Theme
#+BEGIN_SRC emacs-lisp
(use-package hybrid-reverse-theme
:ensure nil
:load-path "~/code/elisp/emacs-hybrid-reverse"
:config (load-theme 'hybrid-reverse t))
#+END_SRC
** Which-key
Popup that displays available key bindings.
#+BEGIN_SRC emacs-lisp
(use-package which-key
:hook (emacs-startup . which-key-mode)
:config
(setq which-key-add-column-padding 1)
(setq which-key-max-display-columns nil)
(setq which-key-min-display-lines 6)
(setq which-key-sort-order #'dot/which-key-prefix-then-key-order-alpha)
(setq which-key-sort-uppercase-first nil)
(defun dot/which-key-prefix-then-key-order-alpha (acons bcons)
"Order by prefix, then lexicographical."
(let ((apref? (which-key--group-p (cdr acons)))
(bpref? (which-key--group-p (cdr bcons))))
(if (not (eq apref? bpref?))
(and (not apref?) bpref?)
(which-key-key-order-alpha acons bcons)))))
#+END_SRC