aboutsummaryrefslogtreecommitdiff
path: root/shoshimacs.el
blob: ffd98c13645ccbe7628f52e044c5f77d74c09ee3 (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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
;;; shoshimacs.el --- Beginner's Mind Config  -*- lexical-binding:t -*-

(let ((my-custom-file (expand-file-name
		       "shoshimacs-custom.el" user-emacs-directory)))
  (unless (file-exists-p my-custom-file)
    (make-empty-file my-custom-file))
  (setq custom-file my-custom-file)
  (load custom-file))

(defvar my-themes-to-install
  '(cyberpunk-theme dracula-theme nano-theme)
  "List of themes to install when loading shoshimacs config.")

(defvar my-chosen-themes
  '(cyberpunk dichromacy dracula leuven modus-operandi modus-vivendi
    nano-dark nano-light tango tango-dark)
  "List of themes I prefer for narrowing and random selection.")

;;; Package Management
(when (< emacs-major-version 28)
  (add-to-list 'package-archives '("nongnu" . "https://elpa.nongnu.org/nongnu/")))

(package-initialize)
(package-refresh-contents)

(when (and (functionp #'native-comp-available-p) (native-comp-available-p))
  (setq native-comp-always-compile t
	package-native-compile t))

;;; Major Keybinding
;; these need to be set before requiring the package
(setq xah-fly-use-control-key nil
      xah-fly-use-meta-key nil)
(package-install 'xah-fly-keys)
(require 'xah-fly-keys)
(xah-fly-keys-set-layout "qwerty")
(xah-fly-keys t)

(define-key 'xah-fly-leader-key-map (kbd "1") #'delete-other-windows)

(defmacro with-map-defkey (keymap leader &rest pairs)
  "Define a new KEYMAP with prefix key LEADER, and list of bindings in it."
  (declare (indent 2))
  `(progn
     (defvar ,keymap (make-sparse-keymap))
     (define-prefix-command (quote ,keymap))
     (global-set-key (kbd ,leader) ,keymap)
     (mapc (lambda (pair)
             (define-key ,keymap
               (kbd (if (numberp (car pair)) (number-to-string (car pair))
                      (symbol-name (car pair))))
               (cadr pair)))
           (quote ,(seq-partition pairs 2)))))

(defvar *my-config* "~/projects/shoshimacs/shoshin-config.org"
  "Path to my main configuration file.")

(defun my-configuration ()
  (interactive)
  (find-file *my-config*))

(defun my-reload-config ()
  "Tangles and reloads a literate config with `org-babel-load-file'"
  (interactive)
  (org-babel-load-file *my-config*))

(with-map-defkey my-key-map "M-m"
  1 delete-other-windows
  a apropos
  b consult-buffer
  c my-configuration
  d embark-act
  e eshell
  f find-file
  g magit
  h info
  i consult-imenu
  j describe-function
  k describe-variable
  n tab-next
  s consult-ripgrep
  t consult-theme
  w which-key-mode
  <f1> my-reload-config)

;;; Completion
(setq completion-styles '(flex basic partial-completion emacs22)
      completion-cycle-threshold 3
      tab-always-indent 'complete)

(package-install 'consult)

(global-set-key (kbd "C-x b") #'consult-buffer)
(define-key xah-fly-leader-key-map (kbd "f") #'consult-buffer)
(define-key xah-fly-command-map (kbd "n") #'consult-line)

(with-eval-after-load 'consult
  (consult-customize consult-theme :preview-key '(:debounce 0.5 any))
  (setq consult-themes my-chosen-themes))

(package-install 'embark)
(package-install 'embark-consult)
(global-set-key (kbd "C-;") #'embark-act)
(setq prefix-help-command #'embark-prefix-help-command)

(package-install 'marginalia)
(marginalia-mode)

(package-install 'vertico)
(setq minibuffer-prompt-properties
      '(read-only t cursor-intangible t face minibuffer-prompt))
(add-hook 'minibuffer-setup-hook #'cursor-intangible-mode)
(setq read-extended-command-predicate
      #'command-completion-default-include-p)
(setq enable-recursive-minibuffers t)
(vertico-mode)

(require 'vertico-directory)
(define-key vertico-map (kbd "RET") #'vertico-directory-enter)
(define-key vertico-map (kbd "DEL") #'vertico-directory-delete-char)
(define-key vertico-map (kbd "M-DEL") #'vertico-directory-delete-word)
(define-key vertico-map (kbd "M-j") #'vertico-quick-insert)

(package-install 'corfu)
(setq corfu-auto t
      corfu-cycle t
      corfu-quit-no-match t)
(global-corfu-mode t)

(package-install 'corfu-terminal)
(unless (display-graphic-p)
    (corfu-terminal-mode +1))

(package-install 'which-key)
(which-key-mode)

;;; Editing
(electric-pair-mode)

(package-install 'markdown-mode)

(defun my-org-top-level-heading ()
  (interactive)
  (let ((moo 1))
    (while moo (setq moo (org-up-heading-safe)))))

(package-install 'htmlize)

(recentf-mode)

(setq indent-tabs-mode nil)

;;; Programming
(package-install 'sly)

(package-install 'json-mode)

(package-install 'inf-ruby)

(package-install 'devdocs)

;;; Projects
(package-install 'magit)

;;; External Services
(package-install 'plz)

(package-install 'srht)
(setq srht-username "shoshin")

;;; User Interface
(when (display-graphic-p)
  (scroll-bar-mode -1)
  (fringe-mode '(8 . 0)))

(tab-bar-mode t)
(display-battery-mode t)

(package-install 'darkroom)

(set-frame-font "Victor Mono")

(global-hl-line-mode t)

(load-theme (seq-random-elt my-chosen-themes))

(mapc #'package-install my-themes-to-install)

(package-install 'windresize)