aboutsummaryrefslogtreecommitdiffstats
path: root/oni-gui.el
blob: 5ba6a132c4f6398b5b66a0958c1e2f5edd0dc67a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
;;; oni-gui.el --- GUI settings for Emacs            -*- lexical-binding: t; -*-

;; Copyright (C) 2019  Tom Willemse

;; Author: Tom Willemse <tom@ryuslash.org>
;; Keywords: local
;; Version: 2023.0805.233624
;; Package-Requires: (oni-ui oni-hydra yoshi-theme diminish)

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program.  If not, see <https://www.gnu.org/licenses/>.

;;; Commentary:

;; These are my GUI settings.

;;; Code:

(require 'hydra)
(require 'oni-ui)

(add-to-list 'default-frame-alist '(font . "Fantasque Sans Mono-15"))
(add-to-list 'default-frame-alist '(internal-border-width . 15))

(defconst oni-gui-isearch-icon #xf002)
(defconst oni-gui-arev-icon #xf1b8)

(defun oni-gui-setup-faces (frame)
  "Setup faces for FRAME."
  (set-face-attribute 'fixed-pitch frame :font "Fantasque Sans Mono-15")
  (set-face-attribute 'variable-pitch frame :font "Comic Neue-15"))

(defun oni-gui-setup-fontsets (frame)
  "Setup fontsets for FRAME.
If FRAME is nil, they’re set for the current frame."
  (let ((font-awesome "Font Awesome 5 Free Solid-12"))
    (set-fontset-font t oni-gui-isearch-icon font-awesome frame)
    (set-fontset-font t #xf026 font-awesome frame)
    (set-fontset-font t #xf027 font-awesome frame)
    (set-fontset-font t #xf028 font-awesome frame)
    (set-fontset-font t #xf240 font-awesome frame)
    (set-fontset-font t #xf241 font-awesome frame)
    (set-fontset-font t #xf242 font-awesome frame)
    (set-fontset-font t #xf243 font-awesome frame)
    (set-fontset-font t #xf244 font-awesome frame)
    (set-fontset-font t #xf2c9 font-awesome frame)
    (set-fontset-font t #xf6a9 font-awesome frame)
    (set-fontset-font t #xf769 font-awesome frame)
    (set-fontset-font t #xf76b font-awesome frame)
    (set-fontset-font t oni-gui-arev-icon font-awesome frame))
  (let ((font-awesome "Font Awesome 5 Free Regular-12"))
    (set-fontset-font t #xf0c8 font-awesome frame)
    (set-fontset-font t #xf14a font-awesome frame))
  (let ((dejavu-sans-mono "DejaVu Sans Mono-12"))
    (set-fontset-font t #x25c9 dejavu-sans-mono frame)
    (set-fontset-font t #x25cb dejavu-sans-mono frame)
    (set-fontset-font t #x2738 dejavu-sans-mono frame)
    (set-fontset-font t #x273f dejavu-sans-mono frame)
    (set-fontset-font t #x2713 dejavu-sans-mono frame)))

;; Thanks to the article at
;; https://andreyorst.gitlab.io/posts/2020-07-21-programming-ligatures-in-emacs/
(defun oni-gui-setup-ligatures (&optional _)
  "Define ligatures supported by Fantasque Sans Mono."
  (let ((ligatures
         `((?= . ,(regexp-opt '("==" "===" "=/=" "=>" "==>" "=>>" "=<<")))
           (?! . ,(regexp-opt '("!=" "!==")))
           (?< . ,(regexp-opt '("<-<" "<<-" "<--" "<-" "<->" "<=<" "<<=" "<=="
                                "<=>" "<~>" "<~~" "<~" "<<<" "<<" "<=" "<>"
                                "<|||" "<||" "<|" "<|>" "<!--")))
           (?- . ,(regexp-opt '("->" "-->" "->>" "-<" "-<<")))
           (?> . ,(regexp-opt '(">->" ">=>" ">>=" ">>-" ">-" ">=" ">>" ">>>")))
           (?~ . ,(regexp-opt '("~~" "~>" "~~>")))
           (?| . ,(regexp-opt '("|>" "||>" "|||>" "||")))
           (?: . ,(regexp-opt '("::")))
           (?& . ,(regexp-opt '("&&")))
           (?/ . ,(regexp-opt '("//" "/*")))
           (?* . ,(regexp-opt '("*/" "**/"))))))
    (dolist (char-regexp ligatures)
      (set-char-table-range composition-function-table (car char-regexp)
                            `([,(cdr char-regexp) 0 font-shape-gstring])))))

(with-eval-after-load 'isearch
  (diminish 'isearch-mode (string ?\s oni-gui-isearch-icon)))
(with-eval-after-load 'autorevert
  (diminish 'auto-revert-mode (string ?\s oni-gui-arev-icon)))

(defhydra oni-gui-hydra (:color teal :hint nil)
  "
^Buffer^           ^Packages^  ^Sort^
^^^^^^-----------------------------------
_br_: Revert       _pl_: List  _sl_: Sort
_bi_: Auto Insert  ^^          ^^
"
  ("br" (revert-buffer nil t))
  ("bi" auto-insert)
  ("pl" list-packages)
  ("sl" sort-lines))

(setq-default cursor-type '(bar . 2))
(setq-default cursor-in-non-selected-windows 'box)
(setq frame-resize-pixelwise t)

(scroll-bar-mode -1)

(unless (eq system-type 'windows-nt)
  (if (daemonp)
      (progn
        (add-hook 'after-make-frame-functions #'oni-gui-setup-ligatures)
        (add-hook 'after-make-frame-functions #'oni-gui-setup-fontsets)
        (add-hook 'after-make-frame-functions #'oni-gui-setup-faces))
    (oni-gui-setup-fontsets nil)
    (oni-gui-setup-faces nil)
    (oni-gui-setup-ligatures)))

(global-unset-key (kbd "C-z"))
(global-set-key (kbd "C-c c") '("Frequently used commands" . oni-gui-hydra/body))

(load-theme 'yoshi :no-confirm)

(when (fboundp 'pixel-scroll-precision-mode)
  (pixel-scroll-precision-mode))

(provide 'oni-gui)
;;; oni-gui.el ends here