summaryrefslogtreecommitdiff
path: root/.emacs.d/modules/thanos-tools.el
blob: 36bc51188f3790eeafd30466e0a0cdd51a76e371 (about) (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
;;; thanos-tools.el --- Tools Configuration   -*- lexical-binding: t; -*-

;; Copyright (C) 2023  Thanos Apollo

;; Author: Thanos Apollo <[email protected]>
;; Keywords: extensions

;; 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:
;; ╭━━━━┳╮╱╱╱╱╱╱╱╱╱╱╱╱╱╱╭━━━╮╱╱╱╱╱╭╮╭╮╱╱╱╱╱╱╱╱╭━━━╮
;; ┃╭╮╭╮┃┃╱╱╱╱╱╱╱╱╱╱╱╱╱╱┃╭━╮┃╱╱╱╱╱┃┃┃┃╱╱╱╱╱╱╱╱┃╭━━╯
;; ╰╯┃┃╰┫╰━┳━━┳━╮╭━━┳━━╮┃┃╱┃┣━━┳━━┫┃┃┃╭━━╮╱╱╱╱┃╰━━┳╮╭┳━━┳━━┳━━╮
;; ╱╱┃┃╱┃╭╮┃╭╮┃╭╮┫╭╮┃━━┫┃╰━╯┃╭╮┃╭╮┃┃┃┃┃╭╮┃╭━━╮┃╭━━┫╰╯┃╭╮┃╭━┫━━┫
;; ╱╱┃┃╱┃┃┃┃╭╮┃┃┃┃╰╯┣━━┃┃╭━╮┃╰╯┃╰╯┃╰┫╰┫╰╯┃╰━━╯┃╰━━┫┃┃┃╭╮┃╰━╋━━┃
;; ╱╱╰╯╱╰╯╰┻╯╰┻╯╰┻━━┻━━╯╰╯╱╰┫╭━┻━━┻━┻━┻━━╯╱╱╱╱╰━━━┻┻┻┻╯╰┻━━┻━━╯
;; ╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱┃┃
;; ╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╰╯
;;; Code:
(require 'corfu)
(require 'orderless)
(require 'dabbrev)

;; Find definitions
(global-set-key (kbd "M-.") 'xref-find-definitions)
(global-set-key (kbd "C-c L") 'display-line-numbers-mode)

;; electric pair
(electric-pair-mode 1)

;; auto insert templates
(auto-insert-mode 1)

;; flycheck
(require 'flycheck)
(global-flycheck-mode)

;; Tramp
(require 'tramp)
(setf tramp-default-method "ssh")

;; sudo-edit
(require 'sudo-edit)
(setf sudo-edit-local-method "doas") ;; sudo is bloat

;; Completions
(setf dabbrev-ignored-buffer-regexps '("\\.\\(?:pdf\\|jpe?g\\|png\\)\\'"))

(setf completion-category-overrides '((file (style basic partial-completion)))
      completion-styles '(orderless)
      completion-cycle-threshold 2)

;; Corfu
(global-corfu-mode)
(corfu-popupinfo-mode)

(setf corfu-auto t
      corfu-auto-delay 0.1
      corfu-auto-prefix 2
      corfu-cycle t
      corfu-popupinfo-delay 0.3
      corfu-quit-at-boundary 'separator
      corfu-quit-no-match t
      corfu-preselect 'first
      corfu-preview-current t
      corfu-echo-mode t)

(setf indent-tabs-mode nil)

;; Register & Consult
(define-key global-map (kbd "C-x r d") 'bookmark-delete)
(define-key global-map (kbd "C-x r C-r") 'bookmark-rename)
(define-key global-map (kbd "C-x r .") 'consult-register)
(define-key global-map (kbd "C-x r s") 'consult-register-store)
(define-key global-map (kbd "C-x r b") 'consult-bookmark)

(defvar-keymap thanos/search
  :doc "Keymap for search commands."
  "f" #'isearch-forward
  "b" #'isearch-backward
  "s" #'consult-line
  "C-f" #'consult-find
  "C-g" #'consult-grep
  "C-i" #'consult-info
  "C-l" #'consult-locate)

(define-key global-map (kbd "C-s") thanos/search)
(define-key project-prefix-map (kbd "b") 'consult-project-buffer)
(define-key global-map (kbd "M-y") 'consult-yank-from-kill-ring)

(setf xref-show-xrefs-function #'consult-xref
      xref-show-definitions-function #'consult-xref)

(setf register-preview-delay 0.5
      register-preview-function #'consult-register-format)

(defun insert-brackets (&optional arg)
  "Insert ARG brackets."
  (interactive "P")
  (insert-pair arg ?\[ ?\]))

(global-set-key (kbd "C-x M-[") 'insert-brackets)

;; Magit
(require 'magit)

(defun project-magit ()
  "Run magit-status in the current project's root."
  (interactive)
  (magit-status (project-root (project-current t))))

(define-key project-prefix-map (kbd "g") 'project-magit)

(setf magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1)


;; shell scripting
(define-auto-insert
  '("\\.sh\\'" . "Bash skeleton")
  '("Description:"
    "#!/bin/bash\n\n"))

(add-hook 'shell-script-mode #'auto-insert)

;; Emacs lisp
(require 'flycheck)
(require 'rainbow-delimiters)

(setf tab-always-indent 'complete)
(add-to-list 'completion-styles 'initials t)

(add-hook 'emacs-lisp-mode-hook #'rainbow-delimiters-mode)
(setf flycheck-emacs-lisp-load-path 'inherit)

(add-hook 'emacs-lisp-mode-hook 'prettify-symbols-mode)

;; Disable checkdoc flycheck for org-src buffers
(add-hook 'org-src-mode-hook #'(lambda ()
				 (flycheck-disable-checker 'emacs-lisp-checkdoc)))

;; Common lisp
(setf inferior-lisp-program "sbcl")
(add-hook 'lisp-mode-hook #'rainbow-delimiters-mode)

;; Scheme
(add-hook 'scheme-mode-hook #'rainbow-delimiters-mode)

;; Python
(require 'python-mode)
(add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode))

;; json
(require 'json-mode)
(add-to-list 'auto-mode-alist '("\\.json'" . json-mode))

;; Markdown
(require 'markdown-mode)
(add-hook 'markdown-mode-hook #'(lambda () (flyspell-mode)))
(setq markdown-header-scaling t
      markdown-command "multimarkdown")

(add-to-list 'auto-mode-alist '("\\.md\\'" . gfm-mode))

(provide 'thanos-tools)
;;; thanos-tools.el ends here