.emacs.d/init.d/basics/appearance.el

142 lines
6.0 KiB
EmacsLisp
Raw Normal View History

2019-10-14 17:38:14 +02:00
;;; appearance.el --- Configure appearance. -*- lexical-binding: t; -*-
;; Time-stamp: <2020-12-06T12:02:22+0100>
2019-10-14 17:38:14 +02:00
;;; 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:
(require 'basics/package-management)
2019-10-14 17:38:14 +02:00
(require 'basics/global-variables)
(use-package emacs
:straight (:type built-in)
: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
(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.
(when (fboundp #'set-scroll-bar-mode)
(set-scroll-bar-mode 'right))
(add-to-list 'default-frame-alist '(scroll-bar-width . 8))
(my/set-default-fonts)
(show-paren-mode t) ; Visualize matching parens.
(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
;; 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
:demand t
: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.
;; See <https://github.com/domtronn/all-the-icons.el/issues/58>.
:config (when (and (display-graphic-p)
(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
(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
(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
(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))
(when (fboundp #'markdown-mode)
(set-face-background 'markdown-code-face
(face-background 'hl-line)))
(my/set-default-fonts)
(when (display-graphic-p)
(setq my/run-fix-theme nil))))
(load-theme 'doom-outrun-electric t)
(my/fix-theme)
(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)
;; 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))))
(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))
:hook (server-after-make-frame . my/fix-theme))
2019-10-14 17:38:14 +02:00
;; Neat modeline.
(use-package doom-modeline
:after (all-the-icons hl-line)
:init (column-number-mode t) ; Show column number.
:custom ((doom-modeline-minor-modes t) ; Show minor modes.
(doom-modeline-buffer-file-name-style 'truncate-all)
(mode-line-percent-position nil) ; Don't display percentage.
(doom-modeline-buffer-state-icon nil)) ; Don't display save icon.
:hook ((after-init . doom-modeline-mode)
;; <https://github.com/seagle0128/doom-modeline/issues/375>
(server-after-make-frame . (lambda ()
(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
:straight (:type built-in)
: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
(provide 'basics/appearance)
;;; appearance.el ends here