142 lines
3.4 KiB
EmacsLisp
142 lines
3.4 KiB
EmacsLisp
|
;;; ui.el --- Configure user interfaces. -*- lexical-binding: t; -*-
|
||
|
|
||
|
;; Time-stamp: <2019-10-14T14:44:16+00:00>
|
||
|
|
||
|
;;; Commentary:
|
||
|
|
||
|
;;; Code:
|
||
|
|
||
|
;; Show directory tree in a window.
|
||
|
(use-package neotree
|
||
|
:pin melpa ; <= 0.5.2 changes directory on file switch.
|
||
|
:demand t
|
||
|
:after (all-the-icons)
|
||
|
|
||
|
:custom
|
||
|
(neo-smart-open t)
|
||
|
(neo-show-updir-line t) ; Disabled by doom-themes?
|
||
|
(neo-window-width 40)
|
||
|
(neo-show-hidden-files t)
|
||
|
(neo-theme 'icons)
|
||
|
|
||
|
:bind
|
||
|
("<f8>" . neotree-show)
|
||
|
("C-<f8>" . neotree-hide)
|
||
|
)
|
||
|
|
||
|
;; Completion in many Emacs commands.
|
||
|
(use-package ivy
|
||
|
: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)
|
||
|
)
|
||
|
)
|
||
|
|
||
|
;; Extensions for ivy
|
||
|
(use-package counsel
|
||
|
: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)))))))
|
||
|
)
|
||
|
|
||
|
;; Better search.
|
||
|
(use-package swiper
|
||
|
:after ivy
|
||
|
:functions (swiper)
|
||
|
|
||
|
:bind
|
||
|
("C-s" . 'swiper)
|
||
|
)
|
||
|
|
||
|
(provide 'basics/ui)
|
||
|
;;; ui.el ends here
|