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

150 lines
3.8 KiB
EmacsLisp

;;; ui.el --- Configure user interfaces. -*- lexical-binding: t; -*-
;; Time-stamp: <2020-02-20T18:49:40+0100>
;;; Commentary:
;; * treemacs
;; * ivy + counsel.
;;; Code:
;; Directory tree.
(use-package treemacs
:pin melpa ; We need > 2.6 for lsp-treemacs.
:demand t
:after (display-line-numbers)
:custom
(treemacs-project-follow-cleanup t) ; Collapse projects when leaving.
(treemacs-silent-refresh t) ; No log message on refresh.
:bind
("<f8>" . treemacs-select-window) ; Focus treemacs.
("C-<f8>" . treemacs) ; Toggle treemacs.
("M-<f8>" . treemacs-add-and-display-current-project) ; Add current project.
(:map treemacs-mode-map
("<mouse-1>" . treemacs-single-click-expand-action))
:hook
(treemacs-mode . my/disable-line-numbers)
)
(use-package treemacs-projectile
:after (treemacs projectile)
)
(use-package treemacs-magit
:after (treemacs magit)
)
;; Completion in many Emacs commands.
(use-package ivy
:demand t
:diminish ivy-mode
:custom
(ivy-use-virtual-buffers t)
(ivy-count-format "[%d/%d] ")
(ivy-wrap t)
:config
(ivy-mode 1)
:bind
("C-c C-r" . ivy-resume)
(:map ivy-minibuffer-map
("M-<up>" . ivy-previous-history-element)
("M-<down>" . ivy-next-history-element)
("S-<return>" . ivy-immediate-done) ; Ignore completion.
)
)
;; Extensions for ivy
(use-package counsel
:after (ivy)
:demand t
:bind
("C-x C-f" . counsel-find-file)
("M-x" . counsel-M-x)
)
;; Use icons in ivy.
(use-package all-the-icons-ivy
:after (all-the-icons counsel)
:config
(all-the-icons-ivy-setup)
)
;; More information in ivy mini-buffers.
(use-package ivy-rich
;; all-the-icons-ivy would override the ivy-rich switch-buffer improvements.
:after (all-the-icons-ivy counsel)
:config (ivy-rich-mode 1)
)
;; Use icons in ivy-rich.
(use-package all-the-icons-ivy-rich
:pin melpa ; We need > 1.0.0.
:after (all-the-icons ivy-rich)
:config (all-the-icons-ivy-rich-mode 1)
)
(use-package ivy-purpose
:after (window-purpose)
:config
(ivy-purpose-setup)
:bind
(:map purpose-mode-map
("C-x b" . ivy-switch-buffer)
;; ("C-x b" . ivy-purpose-switch-buffer-without-purpose)
)
)
(use-package counsel-projectile
:after (projectile)
:custom
(counsel-projectile-mode t) ; Turn on projectile-mode and enable keybindings.
(projectile-switch-project-action 'my/switch-project)
:config
(defun my/counsel-projectile-switch-project-action (project)
"Call `my/switch-project'."
(let ((projectile-switch-project-action 'my/switch-project))
(counsel-projectile-switch-project-by-name project)))
(counsel-projectile-modify-action
'counsel-projectile-switch-project-action
'((add ("Y" my/counsel-projectile-switch-project-action
"open project in treemacs") 1)))
)
;; Switch between named persistent window configurations.
(when (>= emacs-major-version 27)
(use-package tab-bar
:bind
("C-<prior>" . tab-bar-switch-to-prev-tab)
("C-<next>" . tab-bar-switch-to-next-tab)
))
;; Shows tabs of all visible buffers per window.
(when (>= emacs-major-version 27)
(use-package tab-line
: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 tab-line-tab
:background "grey10"
:foreground "grey70"))))
(tab-line-highlight ((t (:inherit tab-line-tab-current
:foreground "white"))))
))
(provide 'basics/ui)
;;; ui.el ends here