2019-10-14 17:38:14 +02:00
|
|
|
|
;;; appearance.el --- Configure appearance. -*- lexical-binding: t; -*-
|
|
|
|
|
|
|
|
|
|
;;; Commentary:
|
|
|
|
|
|
2020-03-08 10:51:04 +01:00
|
|
|
|
;; * Helpful visualizations.
|
|
|
|
|
;; * Colors and theme.
|
|
|
|
|
;; * Icon font.
|
|
|
|
|
;; * Modeline stuff.
|
|
|
|
|
|
2019-10-14 17:38:14 +02:00
|
|
|
|
;;; Code:
|
|
|
|
|
|
2020-03-18 15:00:17 +01:00
|
|
|
|
(require 'basics/package-management)
|
2019-10-14 17:38:14 +02:00
|
|
|
|
(require 'basics/global-variables)
|
|
|
|
|
|
|
|
|
|
(use-package emacs
|
2020-11-18 18:38:55 +01:00
|
|
|
|
:straight (:type built-in)
|
2020-05-24 22:59:31 +02:00
|
|
|
|
:demand t
|
2020-01-27 02:39:22 +01:00
|
|
|
|
;; If 2 files have the same name, append directory name after the filename.
|
2020-03-08 10:51:04 +01:00
|
|
|
|
:custom ((uniquify-after-kill-buffer-p t)
|
|
|
|
|
(uniquify-buffer-name-style 'post-forward)
|
|
|
|
|
(uniquify-strip-common-suffix t))
|
|
|
|
|
:config (progn
|
2020-03-24 22:38:17 +01:00
|
|
|
|
(defun my/set-default-fonts ()
|
|
|
|
|
"Set the default font and the emoji font."
|
|
|
|
|
(when (member "Source Code Pro" (font-family-list)) ; Default.
|
|
|
|
|
(set-frame-font "Source Code Pro-10" t t))
|
|
|
|
|
(when (member "Noto Color Emoji" (font-family-list)) ; Emojis.
|
|
|
|
|
(set-fontset-font t 'unicode "Noto Color Emoji" nil 'prepend)))
|
|
|
|
|
|
|
|
|
|
(tool-bar-mode -1) ; Hide toolbar.
|
2020-04-18 01:16:30 +02:00
|
|
|
|
(menu-bar-mode -1) ; Hide menu bar.
|
2020-05-20 07:59:31 +02:00
|
|
|
|
(when (fboundp #'set-scroll-bar-mode)
|
|
|
|
|
(set-scroll-bar-mode 'right))
|
2020-05-17 18:19:30 +02:00
|
|
|
|
(add-to-list 'default-frame-alist '(scroll-bar-width . 8))
|
2020-03-24 22:38:17 +01:00
|
|
|
|
(my/set-default-fonts)
|
2021-08-20 22:01:05 +02:00
|
|
|
|
;; (show-paren-mode t) ; Visualize matching parens.
|
2020-03-24 22:38:17 +01:00
|
|
|
|
(setq frame-title-format ; Show filename in frame title.
|
2020-03-08 10:51:04 +01:00
|
|
|
|
'(multiple-frames
|
|
|
|
|
"%b" ("" invocation-name "@" system-name
|
|
|
|
|
" – " buffer-file-truename)))))
|
2019-10-14 17:38:14 +02:00
|
|
|
|
|
2020-11-29 09:11:03 +01:00
|
|
|
|
;; Highlight current line.
|
|
|
|
|
(use-package hl-line
|
|
|
|
|
:straight (:type built-in)
|
|
|
|
|
:demand t
|
|
|
|
|
:config (global-hl-line-mode t))
|
|
|
|
|
|
2019-10-14 17:38:14 +02:00
|
|
|
|
;; Icon font (required by doom and others).
|
|
|
|
|
(use-package all-the-icons
|
2020-05-24 22:59:31 +02:00
|
|
|
|
:demand t
|
2020-03-08 10:42:42 +01:00
|
|
|
|
:init (defun my/font-installed-p (font-name)
|
|
|
|
|
"Check if font with FONT-NAME is available."
|
|
|
|
|
(if (find-font (font-spec :name font-name))
|
|
|
|
|
t
|
|
|
|
|
nil))
|
2019-12-13 17:54:59 +01:00
|
|
|
|
;; Install fonts if we have a GUI and the font is not already installed.
|
2020-03-08 10:42:42 +01:00
|
|
|
|
;; See <https://github.com/domtronn/all-the-icons.el/issues/58>.
|
2020-11-14 22:47:57 +01:00
|
|
|
|
:config (when (and (display-graphic-p)
|
2020-03-08 10:42:42 +01:00
|
|
|
|
(not (my/font-installed-p "all-the-icons")))
|
2020-03-08 10:51:04 +01:00
|
|
|
|
(all-the-icons-install-fonts t)))
|
2019-10-14 17:38:14 +02:00
|
|
|
|
|
2020-11-30 15:50:41 +01:00
|
|
|
|
(use-package doom-themes
|
|
|
|
|
:demand t
|
|
|
|
|
:after (all-the-icons)
|
|
|
|
|
:custom ((doom-themes-treemacs-theme "doom-colors")
|
|
|
|
|
(doom-themes-treemacs-enable-variable-pitch nil))
|
|
|
|
|
:config (progn
|
2020-12-05 08:58:46 +01:00
|
|
|
|
(defvar my/run-fix-theme t)
|
|
|
|
|
(defun my/fix-theme ()
|
|
|
|
|
"Fix some colors, needed the for the first frame after server start."
|
|
|
|
|
(when my/run-fix-theme
|
2021-02-23 18:57:39 +01:00
|
|
|
|
(set-face-background 'hl-line "#140f50")
|
2021-02-24 05:34:38 +01:00
|
|
|
|
(set-face-background 'region "#340f50")
|
2020-12-05 08:58:46 +01:00
|
|
|
|
(when (display-graphic-p)
|
|
|
|
|
(set-face-background 'scroll-bar (face-background 'default))
|
|
|
|
|
(set-face-foreground 'scroll-bar (face-foreground 'shadow)))
|
|
|
|
|
(when (fboundp #'my/ruler-set-colors)
|
|
|
|
|
(my/ruler-set-colors))
|
|
|
|
|
(when (fboundp #'my/volatile-highlights-reset-color)
|
|
|
|
|
(my/volatile-highlights-reset-color))
|
2020-12-06 12:03:32 +01:00
|
|
|
|
(my/set-default-fonts)
|
2020-12-05 08:58:46 +01:00
|
|
|
|
(when (display-graphic-p)
|
2021-08-23 15:15:52 +02:00
|
|
|
|
(setq my/run-fix-theme nil))
|
|
|
|
|
(when (fboundp #'my/hl-paren-set-faces)
|
|
|
|
|
(my/hl-paren-set-faces))))
|
2020-12-05 08:58:46 +01:00
|
|
|
|
(load-theme 'doom-outrun-electric t)
|
|
|
|
|
(my/fix-theme)
|
2020-11-26 13:21:04 +01:00
|
|
|
|
|
2020-11-30 15:50:41 +01:00
|
|
|
|
(doom-themes-visual-bell-config) ; Flash modeline on error.
|
|
|
|
|
;; No icons in TUI, see
|
|
|
|
|
;; <https://github.com/hlissner/emacs-doom-themes/issues/489>
|
|
|
|
|
(doom-themes-treemacs-config)
|
2020-04-25 18:23:31 +02:00
|
|
|
|
|
2020-11-30 15:50:41 +01:00
|
|
|
|
;; Write a minimal theme to file, to load it in early-init.el.
|
|
|
|
|
(unless (string= (face-background 'default) "unspecified-bg")
|
|
|
|
|
(let ((minimal-theme))
|
|
|
|
|
(setq minimal-theme (concat "(set-face-background 'default \""
|
|
|
|
|
(face-background 'default) "\")\n"
|
|
|
|
|
"(set-face-foreground 'default \""
|
|
|
|
|
(face-foreground 'default) "\")\n"
|
|
|
|
|
"(menu-bar-mode -1)\n"
|
|
|
|
|
"(when (display-graphic-p)\n"
|
|
|
|
|
" (tool-bar-mode -1))\n"))
|
|
|
|
|
(with-temp-file (expand-file-name "early-theme.el"
|
|
|
|
|
user-emacs-directory)
|
|
|
|
|
(insert minimal-theme))))
|
2020-11-14 22:49:09 +01:00
|
|
|
|
|
2020-11-30 15:50:41 +01:00
|
|
|
|
(defun my/treemacs-reset-fringe ()
|
|
|
|
|
"Make fringe in treemacs visible again."
|
|
|
|
|
(set-window-fringes (selected-window) 8))
|
|
|
|
|
(advice-add #'doom-themes-hide-fringes-maybe
|
|
|
|
|
:after #'my/treemacs-reset-fringe))
|
2020-12-05 08:58:46 +01:00
|
|
|
|
:hook (server-after-make-frame . my/fix-theme))
|
2019-10-14 17:38:14 +02:00
|
|
|
|
|
|
|
|
|
;; Neat modeline.
|
|
|
|
|
(use-package doom-modeline
|
2020-11-29 09:11:03 +01:00
|
|
|
|
:after (all-the-icons hl-line)
|
2020-03-08 10:23:07 +01:00
|
|
|
|
:init (column-number-mode t) ; Show column number.
|
|
|
|
|
:custom ((doom-modeline-minor-modes t) ; Show minor modes.
|
2020-11-21 23:32:39 +01:00
|
|
|
|
(doom-modeline-buffer-file-name-style 'truncate-all)
|
2020-03-08 10:23:07 +01:00
|
|
|
|
(mode-line-percent-position nil) ; Don't display percentage.
|
|
|
|
|
(doom-modeline-buffer-state-icon nil)) ; Don't display save icon.
|
2020-11-30 09:59:18 +01:00
|
|
|
|
:hook ((after-init . doom-modeline-mode)
|
|
|
|
|
;; <https://github.com/seagle0128/doom-modeline/issues/375>
|
|
|
|
|
(server-after-make-frame . (lambda ()
|
2021-06-24 18:02:02 +02:00
|
|
|
|
(customize-set-variable
|
|
|
|
|
'doom-modeline-icon
|
|
|
|
|
(display-graphic-p))))))
|
2019-10-14 17:38:14 +02:00
|
|
|
|
|
|
|
|
|
;; Show line numbers on the left side of the buffer.
|
|
|
|
|
(use-package display-line-numbers
|
2020-11-29 09:11:37 +01:00
|
|
|
|
:straight (:type built-in)
|
2020-05-24 22:59:31 +02:00
|
|
|
|
:demand t
|
2019-10-14 17:38:14 +02:00
|
|
|
|
:if (>= emacs-major-version 26)
|
2020-03-08 10:51:04 +01:00
|
|
|
|
:config (progn (defun my/disable-line-numbers ()
|
|
|
|
|
(display-line-numbers-mode -1))
|
|
|
|
|
(global-display-line-numbers-mode)))
|
2019-10-14 17:38:14 +02:00
|
|
|
|
|
2021-08-23 15:02:08 +02:00
|
|
|
|
;; Visualize and transform whitespace.
|
|
|
|
|
(use-package whitespace
|
2021-08-23 15:15:52 +02:00
|
|
|
|
:after (company doom-themes)
|
2021-08-23 15:02:08 +02:00
|
|
|
|
:functions (my/on-off-whitespace-before-company)
|
|
|
|
|
:diminish whitespace-mode
|
|
|
|
|
:custom (whitespace-line-column nil) ; Set to fill-column.
|
|
|
|
|
:config (progn (delete 'newline-mark whitespace-style) ; Don't paint $ at eol.
|
|
|
|
|
(delete 'lines whitespace-style) ; Don't mark whole long lines.
|
2021-10-28 21:55:32 +02:00
|
|
|
|
(delete 'space-mark whitespace-style) ; Don't show dots.
|
2021-08-23 15:02:08 +02:00
|
|
|
|
(when (< emacs-major-version 27) ; Mark end of too long lines.
|
|
|
|
|
(add-to-list 'whitespace-style 'lines-tail))
|
|
|
|
|
|
|
|
|
|
;; Workaround to not show dots in popup menus.
|
|
|
|
|
(defvar-local my/ws-enabled nil)
|
|
|
|
|
(defun my/whitespace-mode-off ()
|
|
|
|
|
(setq-local my/ws-enabled whitespace-mode)
|
|
|
|
|
(when my/ws-enabled
|
|
|
|
|
(whitespace-mode -1)))
|
|
|
|
|
(defun my/whitespace-mode-on ()
|
|
|
|
|
(when my/ws-enabled
|
|
|
|
|
(whitespace-mode t)))
|
|
|
|
|
;; company:
|
|
|
|
|
(defun my/on-off-whitespace-before-company (command)
|
|
|
|
|
(when (string= "show" command)
|
|
|
|
|
(my/whitespace-mode-off))
|
|
|
|
|
(when (string= "hide" command)
|
|
|
|
|
(my/whitespace-mode-on)))
|
|
|
|
|
(advice-add 'company-call-frontends
|
|
|
|
|
:before #'my/on-off-whitespace-before-company)
|
|
|
|
|
;; popup:
|
|
|
|
|
(defadvice popup-create (before my/popup-suspend-ws activate)
|
|
|
|
|
"Suspend whitespace-mode while popups are visible."
|
|
|
|
|
(my/whitespace-mode-off))
|
|
|
|
|
(defadvice popup-delete (after my/popup-restore-ws activate)
|
|
|
|
|
"Restore whitespace-mode when all popups have closed."
|
|
|
|
|
(my/whitespace-mode-on))
|
|
|
|
|
|
|
|
|
|
(if (display-graphic-p)
|
|
|
|
|
(custom-set-faces
|
|
|
|
|
'(whitespace-line
|
|
|
|
|
((t (:inherit whitespace-line
|
|
|
|
|
:weight normal
|
|
|
|
|
:foreground nil
|
|
|
|
|
:background nil
|
|
|
|
|
:box
|
|
|
|
|
(:line-width 1 :color "dark red"))))))
|
|
|
|
|
(custom-set-faces ; else
|
|
|
|
|
'(whitespace-line ((t (:inherit whitespace-line
|
|
|
|
|
:background nil
|
|
|
|
|
:underline t))))))
|
|
|
|
|
|
|
|
|
|
;; Workaround for
|
|
|
|
|
;; <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=36837>, fixed
|
|
|
|
|
;; in 28.1.
|
|
|
|
|
(defun my/ws-load-local-vars-first ()
|
|
|
|
|
"Loads fill-column before enabling whitespace-mode."
|
|
|
|
|
;; We don't use 'lines-tail in Emacs >= 27.
|
|
|
|
|
(when (< emacs-major-version 27)
|
|
|
|
|
(hack-local-variables))
|
|
|
|
|
(whitespace-mode))
|
|
|
|
|
|
|
|
|
|
(defun my/ws-maybe-cleanup ()
|
|
|
|
|
"Run `whitespace-cleanup' if `my/reformat-save' is t."
|
|
|
|
|
(when my/reformat-save
|
|
|
|
|
(whitespace-cleanup))))
|
|
|
|
|
:bind ("C-c w" . whitespace-mode)
|
|
|
|
|
:hook ((prog-mode . my/ws-load-local-vars-first)
|
|
|
|
|
(conf-mode . my/ws-load-local-vars-first)
|
|
|
|
|
(text-mode . my/ws-load-local-vars-first)))
|
|
|
|
|
|
2021-08-17 13:10:27 +02:00
|
|
|
|
(use-package highlight-parentheses
|
2021-08-22 19:03:30 +02:00
|
|
|
|
:after (whitespace)
|
2021-08-21 14:58:11 +02:00
|
|
|
|
:demand t
|
2021-08-22 19:03:30 +02:00
|
|
|
|
:diminish (highlight-parentheses-mode)
|
2021-08-17 13:10:27 +02:00
|
|
|
|
:custom ((highlight-parentheses-colors nil)
|
2021-08-23 15:15:52 +02:00
|
|
|
|
(highlight-parentheses-background-colors nil))
|
|
|
|
|
:config (progn(global-highlight-parentheses-mode)
|
|
|
|
|
(defun my/hl-paren-set-faces ()
|
|
|
|
|
"Faces have to be set after the first frame is created."
|
|
|
|
|
(customize-set-variable
|
|
|
|
|
'highlight-parentheses-attributes
|
|
|
|
|
`((:weight bold :background
|
|
|
|
|
,(face-foreground 'whitespace-space))
|
|
|
|
|
(:weight ultrabold)))))
|
2021-08-21 22:42:45 +02:00
|
|
|
|
:hook (minibuffer-setup . highlight-parentheses-minibuffer-setup))
|
2021-08-17 13:10:27 +02:00
|
|
|
|
|
2019-10-14 17:38:14 +02:00
|
|
|
|
(provide 'basics/appearance)
|
|
|
|
|
;;; appearance.el ends here
|