-
Notifications
You must be signed in to change notification settings - Fork 0
/
local.ox.el
333 lines (276 loc) · 10.4 KB
/
local.ox.el
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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
(use-package json)
(use-package request)
(message "local.ox.el loading...")
;; Allow Ctrl-u to scroll up a page like vim
(setq evil-want-C-u-scroll t)
(setq mac-right-command-modifier 'super)
(setq mac-command-modifier 'super)
;; Option or Alt is naturally 'Meta'
(setq mac-option-modifier 'meta)
;; Right Alt (option) can be used to enter symbols like em dashes '—' and euros '€' and stuff.
(setq mac-right-option-modifier 'nil)
(global-auto-revert-mode t)
(defun ox/open-init-el ()
(interactive)
(find-file (expand-file-name "local.ox.el" user-emacs-directory)))
(setq custom-file (concat user-emacs-directory "custom.el"))
(load custom-file 'noerror)
;; You will most likely need to adjust this font size for your system!
(defvar ox/default-font-size 180)
(defvar ox/default-variable-font-size 180)
(set-face-attribute 'default nil :font "Iosevka" :height ox/default-font-size)
(set-face-attribute 'fixed-pitch nil :font "Iosevka" :height ox/default-font-size)
;; Unfortunately emacs launched from `.app` launcher does not get the full exec path which our shell has. Let's fix that
(use-package exec-path-from-shell
:config
(when (memq window-system '(mac ns x))
(exec-path-from-shell-initialize)))
(use-package evil
:init
(setq evil-want-integration t)
(setq evil-want-keybinding nil)
(setq evil-want-C-u-scroll t)
(setq evil-want-C-i-jump nil)
(fset 'evil-visual-update-x-selection 'ignore)
(setq evil-kill-on-visual-paste nil)
(setq-default evil-symbol-word-search t)
:config
(evil-mode t)
(define-key evil-insert-state-map (kbd "C-g") 'evil-normal-state)
(define-key evil-insert-state-map (kbd "C-h") 'evil-delete-backward-char-and-join)
;; Use visual line motions even outside of visual-line-mode buffers
(evil-global-set-key 'motion "j" 'evil-next-visual-line)
(evil-global-set-key 'motion "k" 'evil-previous-visual-line)
(require 'evil-maps)
(define-key evil-motion-state-map "L" nil)
(define-key evil-motion-state-map "M" nil)
(evil-set-initial-state 'messages-buffer-mode 'normal)
(evil-set-initial-state 'dashboard-mode 'normal))
;; Use another key to go into normal / escape mode. I have it configured as `qp`
(use-package evil-escape
:config
(setq-default evil-escape-key-sequence "qp")
(evil-escape-mode))
(use-package evil-cleverparens
:after (evil smartparens)
:commands evil-cleverparens-mode
:init
(add-hook 'clojure-mode-hook #'evil-cleverparens-mode)
(add-hook 'emacs-lisp-mode-hook #'evil-cleverparens-mode)
(setq evil-cleverparens-complete-parens-in-yanked-region t)
:config
(setq evil-cleverparens-use-s-and-S nil)
(evil-define-key '(normal visual) evil-cleverparens-mode-map
"s" nil
"S" nil
"{" nil
"}" nil
"[" nil
"]" nil
(kbd "M-[") nil
(kbd "<tab>") 'evil-jump-item))
(use-package projectile
:init
(setq projectile-create-missing-test-files t)
(setq projectile-project-search-path '("~/projects/" "~/playground/" "~/projects/lambdaisland"))
(defun ox/refresh-projects-dir ()
(interactive)
;; (projectile-discover-projects-in-directory "~/projects")
(projectile-discover-projects-in-search-path))
:config
(projectile-global-mode))
;; command-log-mode is useful for displaying a panel showing each key binding
;; you use in a panel on the right side of the frame. Great for live streams and
;; screencasts!
(use-package command-log-mode)
(use-package forge
:after magit
:config
(transient-append-suffix 'forge-dispatch '(0)
["Forge browse"
("@" "browse" forge-browse)])
(transient-append-suffix 'forge-dispatch '(0)
["PR"
("p c" "pullreq checkout" forge-checkout-pullreq)]
)
(transient-append-suffix 'forge-dispatch '(0)
["Edit"
("e p" "post" forge-edit-post)
("e a" "assignees" forge-edit-topic-assignees)
("e r" "review requests" forge-edit-topic-review-requests)]))
(use-package git-link
:config
(setq git-link-open-in-browser t
git-link-use-commit t))
(use-package emojify)
(use-package gitmoji
:straight nil
:load-path "~/projects/emacs-gitmoji")
(use-package default-text-scale)
(use-package html-to-hiccup
:straight nil
:load-path "~/projects/html-to-hiccup")
(use-package ivy-rich
:config
(ivy-rich-mode 1)
(setcdr (assq t ivy-format-functions-alist) #'ivy-format-function-line))
(message "loading secrets...")
(load-file (expand-file-name (concat user-emacs-directory "/secrets.el")))
(message "secrets loaded")
(defun send-discord-message-with-webhook (webhook-url message)
"Send a message to a Discord channel using a webhook URL."
(request webhook-url
:type "POST"
:data (json-encode `(("content" . ,message)))
:headers '(("Content-Type" . "application/json"))
:parser 'json-read
:sync t
:complete (cl-function
(lambda (&key response &allow-other-keys)
(message "Done: %s" (request-response-status-code response))))))
(defun ox-journal-discord-gaiwan ()
"Interactively send a message to a Discord channel using a webhook URL."
(interactive)
(let* ((message (read-string "Enter message: ")))
(send-discord-message-with-webhook discord-ox-journal-webhook-url message)))
;; (use-package clockify
;; :ensure nil
;; :load-path "~/projects/emacs-clockify")
;; Usage example: M-x send-discord-message
(setq create-lockfiles nil)
(defun css-region-to-garden (start end)
(interactive "r")
(replace-regexp "\\([a-z-]+\\): \\(.*\\);" ":\\1 \"\\2\"" nil start end))
(defun projectile-kill-all-repl-buffers ()
"Kill all repls in the current project"
(interactive)
(dolist (buffer (buffer-list))
(when (or (string-match-p (concat "cider-repl projects/" (projectile-project-name) ":localhost") (buffer-name buffer)))
(kill-buffer buffer))))
(use-package piglet-emacs)
(use-package adoc-mode)
(use-package just-mode)
(use-package web-mode)
(use-package dotenv-mode)
(use-package git-timemachine)
(use-package evil-collection
:after evil
:ensure t
:config
(evil-collection-init 'git-timemachine))
(use-package coverlay)
(use-package origami)
(use-package css-in-js-mode
:straight '(css-in-js-mode :type git :host github :repo "orzechowskid/tree-sitter-css-in-js"))
(use-package corfu)
(use-package tsx-mode
:straight '(tsx-mode :type git :host github :repo "orzechowskid/tsx-mode.el"))
;; (evil-define-key '(normal visual insert operator)
;; global-map
;; (kbd "C-v") 'evil-paste-after
;; (kbd "C-V") 'evil-paste-before)
;; (define-key input-decode-map (kbd "M-v") 'my-paste-from-clipboard)
;; (defun my-paste-from-clipboard ()
;; "Paste from clipboard in Evil normal and insert modes."
;; (interactive)
;; (if (not (evil-insert-state-p))
;; (progn
;; (evil-normal-state)
;; (evil-paste-after))
;; (yank)))
;; (use-package consult
;; :hook (completion-list-mode . consult-preview-at-point-mode))
;; Define a function to paste text
(defun my-paste ()
"Paste text."
(interactive)
(yank))
(use-package flycheck
:ensure t
:init (global-flycheck-mode))
;; (define-key input-decode-map (kbd "M-v") 'my-paste-from-clipboard)
;; (defun my-paste-from-clipboard ()
;; "Paste from clipboard in Evil normal and insert modes."
;; (interactive)
;; (if (not (evil-insert-state-p))
;; (progn
;; (evil-normal-state)
;; (evil-paste-after))
;; (yank)))
(use-package lsp-mode
:ensure t
:hook ((clojure-mode . lsp)
(clojurec-mode . lsp)
(clojurescript-mode . lsp))
:config
;; add paths to your local installation of project mgmt tools, like lein
(setenv "PATH" (concat
"/usr/local/bin" path-separator
(getenv "PATH")))
(setq lsp-enable-indentation nil)
(dolist (m '(clojure-mode
clojurec-mode
clojurescript-mode
clojurex-mode))
(add-to-list 'lsp-language-id-configuration `(,m . "clojure"))))
(use-package lsp-ui
:ensure t
:commands lsp-ui-mode
:config
(ivy-rich-mode 1)
(setcdr (assq t ivy-format-functions-alist) #'ivy-format-function-line)
(define-key lsp-ui-mode-map [remap xref-find-definitions] #'lsp-ui-peek-find-definitions)
(define-key lsp-ui-mode-map [remap xref-find-references] #'lsp-ui-peek-find-references)
(setq lsp-ui-doc-show-with-cursor t)
)
;; (add-hook 'evil-insert-state-entry-hook (lambda () (send-string-to-terminal "\033[5 q"))) (add-hook 'evil-normal-state-entry-hook (lambda () (send-string-to-terminal "\033[0 q")))
;; `evil-terminal-cursor-changer' utilizes custom terminal escape sequences
;; (which work in most, but not all, terminals) to adjust the appearance of the
;; Emacs cursor based on which Vim mode is currently active. Note that this
;; package is only required when running in a terminal (hence the `unless').
(use-package evil-terminal-cursor-changer
:config
(unless (display-graphic-p)
(require 'evil-terminal-cursor-changer)
(evil-terminal-cursor-changer-activate)
(setq evil-insert-state-cursor 'bar)
))
(setq-default c-default-style "linux")
(setq-default c-basic-offset 4)
;; (use-package company
;; :disabled t)
(use-package cider
:ensure t
:init
(setq cider-clojure-cli-global-options ""))
(defun ox/counsel-rg-change-dir (arg)
(let ((current-prefix-arg '(4)))
(counsel-rg ivy-text nil "")))
(with-eval-after-load 'counsel
(setq counsel-rg-base-command "rg -M 240 --with-filename --no-heading --line-number --color never %s || true"))
(with-eval-after-load 'ivy
(with-eval-after-load 'counsel
(ivy-add-actions
'counsel-rg
'(("r" ox/counsel-rg-change-dir "change root directory")))))
(use-package avy
:straight t
:config
(setq avy-timeout-seconds 0.5)
(setq avy-ignored-modes
'(image-mode magit-mode doc-view-mode pdf-view-mode exwm-mode))
(evil-define-key nil evil-normal-state-map
"s" 'avy-goto-char-2))
(use-package copilot
:straight (:host github :repo "copilot-emacs/copilot.el" :files ("*.el"))
:ensure t
:config
(define-key copilot-completion-map (kbd "<tab>") 'copilot-accept-completion)
(define-key copilot-completion-map (kbd "TAB") 'copilot-accept-completion))
;; you can utilize :map :hook and :config to customize copilot
(message "local.ox.el finished loading.")
(message "loading tailwind cheatsheet...")
(load-file (expand-file-name (concat user-emacs-directory "/tailwind_cheatsheet.el")))
(message "tailwind cheatsheet loaded")
(provide 'local.ox)
;;; local.ox.el ends here