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

174 lines
4.6 KiB
EmacsLisp
Raw Normal View History

2019-10-14 17:38:14 +02:00
;;; ui.el --- Configure user interfaces. -*- lexical-binding: t; -*-
2020-01-20 20:25:29 +01:00
;; Time-stamp: <2020-01-20T19:46:38+0100>
2019-10-14 17:38:14 +02:00
;;; Commentary:
2019-11-09 18:55:55 +01:00
;; * treemacs
2019-10-14 18:02:20 +02:00
;; * ivy + counsel.
2019-10-14 17:38:14 +02:00
;;; Code:
2019-11-09 18:55:55 +01:00
;; Directory tree.
(use-package treemacs
2020-01-20 20:25:29 +01:00
:pin melpa ; We need > 2.6 for lsp-treemacs.
2019-10-14 17:38:14 +02:00
:demand t
:after (display-line-numbers)
2019-10-14 17:38:14 +02:00
:custom
2019-11-09 18:55:55 +01:00
(treemacs-project-follow-cleanup t)
2019-11-09 21:57:10 +01:00
(treemacs-silent-refresh t) ; No log message on refresh.
2019-10-14 17:38:14 +02:00
:bind
2019-11-09 18:55:55 +01:00
("<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)
2019-11-09 18:55:55 +01:00
)
(use-package treemacs-projectile
:after (treemacs projectile)
)
(use-package treemacs-magit
:after (treemacs magit)
2019-10-14 17:38:14 +02:00
)
;; Completion in many Emacs commands.
(use-package ivy
2019-10-15 14:23:28 +02:00
:demand t
2019-10-14 17:38:14 +02:00
: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.
2019-10-14 17:38:14 +02:00
)
)
;; Extensions for ivy
(use-package counsel
2019-10-15 14:23:28 +02:00
:after (ivy)
:demand t
2019-10-14 17:38:14 +02:00
: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)
:functions (ivy-format-function-line)
:config
(defun ivy-rich-switch-buffer-icon (candidate)
(with-current-buffer
(get-buffer candidate)
(let ((icon (all-the-icons-icon-for-mode major-mode)))
(if (symbolp icon)
(all-the-icons-icon-for-mode 'fundamental-mode)
icon))))
(ivy-rich-mode 1)
(setcdr (assq t ivy-format-functions-alist) #'ivy-format-function-line)
:custom
;; It seems I have to copy this whole list to get icons in switch-buffer.
(ivy-rich-display-transformers-list
(quote
(ivy-switch-buffer
(:columns
((ivy-rich-switch-buffer-icon :width 2)
(ivy-rich-candidate
(:width 30))
(ivy-rich-switch-buffer-size
(:width 7))
(ivy-rich-switch-buffer-indicators
(:width 4 :face error :align right))
(ivy-rich-switch-buffer-major-mode
(:width 12 :face warning))
(ivy-rich-switch-buffer-project
(:width 15 :face success))
(ivy-rich-switch-buffer-path
(:width
(lambda
(x)
(ivy-rich-switch-buffer-shorten-path
x (ivy-rich-minibuffer-width 0.3))))))
:predicate
(lambda
(cand)
(get-buffer cand)))
counsel-M-x
(:columns
((counsel-M-x-transformer
(:width 40))
(ivy-rich-counsel-function-docstring
(:face font-lock-doc-face))))
counsel-describe-function
(:columns
((counsel-describe-function-transformer
(:width 40))
(ivy-rich-counsel-function-docstring
(:face font-lock-doc-face))))
counsel-describe-variable
(:columns
((counsel-describe-variable-transformer
(:width 40))
(ivy-rich-counsel-variable-docstring
(:face font-lock-doc-face))))
counsel-recentf
(:columns
((ivy-rich-candidate
(:width 0.8))
(ivy-rich-file-last-modified-time
(:face font-lock-comment-face)))))))
)
;; 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"))))
2019-12-26 21:38:03 +01:00
(tab-line-highlight ((t (:inherit tab-line-tab-current
:foreground "white"))))
))
2019-10-14 17:38:14 +02:00
(provide 'basics/ui)
;;; ui.el ends here