random scripts I use
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

400 lines
10KB

  1. ;; startup
  2. (let ((usr-data (locate-user-emacs-file "data.el")))
  3. (load custom-file)
  4. (load usr-data))
  5. ;; mode line
  6. (setq-default mode-line-format
  7. '("%+"
  8. mode-line-buffer-identification
  9. mode-line-modes
  10. "%5l↑%3c→%6i⇆"
  11. (:eval
  12. (number-to-string (count-lines (point-min) (point-max))))
  13. "↓"
  14. mode-line-percent-position))
  15. ;; scrolling
  16. (setq scroll-conservatively 101
  17. scroll-step 1
  18. hscroll-step 1)
  19. (set-scroll-bar-mode nil)
  20. ;; `prog-mode'
  21. (add-hook 'prog-mode-hook #'flyspell-prog-mode)
  22. (add-hook 'prog-mode-hook #'prettify-symbols-mode)
  23. (add-hook 'prog-mode-hook #'subword-mode)
  24. (add-hook 'prog-mode-hook #'agw-prog-mode)
  25. ;; `text-mode'
  26. (add-hook 'text-mode-hook #'flyspell-prog-mode)
  27. (add-hook 'text-mode-hook #'subword-mode)
  28. (add-hook 'text-mode-hook #'agw-prog-mode)
  29. ;; `hack-local-variables'
  30. (add-hook 'hack-local-variables-hook #'agw-after-local-vars)
  31. ;; macros
  32. (setq initial-buffer-choice
  33. (lambda ()
  34. (if (buffer-file-name)
  35. (current-buffer)
  36. (find-file "~/org/init.org"))))
  37. (add-hook 'emacs-lisp-mode-hook #'agw-fp-mode)
  38. (add-hook 'lisp-mode-hook #'agw-fp-mode)
  39. (add-hook 'reb-lisp-mode-hook #'agw-fp-mode)
  40. (add-hook 'scheme-mode-hook #'agw-fp-mode)
  41. (add-hook 'before-save-hook #'agw-before-save)
  42. (agw-set-key "b d" #'kill-this-buffer)
  43. (agw-set-key "b e" #'ibuffer)
  44. (agw-set-key "m j" #'agw-create-back-link)
  45. (agw-set-key "m k" #'agw-create-memb-link)
  46. (agw-set-key "m l" #'agw-create-mthd-link)
  47. (agw-set-key "a" #'org-archive-to-archive-sibling)
  48. (agw-set-key "A" #'org-force-cycle-archived)
  49. (agw-set-key "k" #'deadgrep)
  50. (agw-key-map-mode)
  51. (global-set-key (kbd "C-x C-<tab>") #'agw-key-map-mode)
  52. ;; packages
  53. (require 'package)
  54. (unless (package-installed-p 'use-package)
  55. (package-refresh-contents)
  56. (package-install 'use-package))
  57. ;; theme
  58. (use-package base16-theme
  59. :ensure t
  60. :config
  61. (load-theme 'base16-atelier-cave t)
  62. (dolist (face '(mode-line
  63. mode-line-buffer-id
  64. mode-line-emphasis
  65. mode-line-highlight
  66. mode-line-inactive
  67. header-line
  68. header-line-highlight))
  69. (set-face-attribute face nil
  70. :height 120
  71. :family agw-mode-line-family
  72. :weight 'normal
  73. :width 'normal))
  74. (set-face-attribute 'mode-line nil
  75. :background "#0a0a0a"
  76. :foreground "#92ebf0"))
  77. ;; major modes
  78. (use-package powershell
  79. :ensure t
  80. :init
  81. (defvaralias 'powershell-indent 'tab-width))
  82. (use-package js
  83. :init
  84. (defvaralias 'js-indent-level 'tab-width))
  85. (use-package json-mode
  86. :ensure t
  87. :after js
  88. :init
  89. (defvaralias 'json-reformat:indent-width 'tab-width))
  90. (use-package mmm-mode
  91. :ensure t
  92. :init
  93. (setq mmm-submode-decoration-level 0)
  94. :config
  95. (require 'mmm-auto)
  96. (mmm-add-group 'rust-doc
  97. '((rust-doc-line
  98. :submode markdown-mode
  99. :face mmm-comment-submode-face
  100. :front "///\s+"
  101. :back "\n")
  102. (rust-doc-block
  103. :submode markdown-mode
  104. :face mmm-comment-submode-face
  105. :front "/\\*\\*"
  106. :back "\\*\\*/")))
  107. (mmm-add-mode-ext-class 'ruby-mode nil 'here-doc)
  108. (mmm-add-mode-ext-class 'rust-mode nil 'rust-doc))
  109. (use-package cc-mode
  110. :mode (("\\.zsc\\'" . c-mode)
  111. ("\\.zc\\'" . c-mode))
  112. :init
  113. (setq c-auto-align-backslashes nil
  114. c-basic-offset tab-width
  115. c-default-style "linux")
  116. (defvaralias 'c-basic-offset 'tab-width))
  117. (use-package fish-mode
  118. :ensure t
  119. :init
  120. (defvaralias 'fish-indent-offset 'tab-width))
  121. (use-package glsl-mode
  122. :ensure t)
  123. (use-package haskell-mode
  124. :ensure t
  125. :hook (haskell-mode . agw-fp-mode))
  126. (use-package markdown-mode
  127. :ensure t
  128. :hook ((markdown-mode . flyspell-mode))
  129. :mode (("\\.mdwn\\'" . markdown-mode)))
  130. (use-package ninja-mode
  131. :ensure t)
  132. (use-package ruby-mode
  133. :hook ((ruby-mode . mmm-mode))
  134. :init
  135. (defvaralias 'ruby-indent-level 'tab-width)
  136. (setq ruby-insert-encoding-magic-comment nil))
  137. (use-package rust-mode
  138. :ensure t
  139. :hook ((rust-mode . mmm-mode))
  140. :init
  141. (defvaralias 'rust-indent-offset 'tab-width))
  142. ;; org-mode
  143. (use-package org
  144. :hook ((org-mode . flyspell-mode)
  145. (org-mode . agw-org-mode))
  146. :init
  147. (setq org-fontify-whole-heading-line t
  148. org-hide-emphasis-markers t
  149. org-hide-leading-stars t
  150. org-hide-macro-markers t
  151. org-image-actual-width nil
  152. org-indent-indentation-per-level 2
  153. org-list-indent-offset 2
  154. org-log-done '(note)
  155. org-pretty-entities t
  156. org-return-follows-link t
  157. org-startup-folded nil
  158. org-startup-with-inline-images t
  159. org-link-frame-setup '((vm . vm-visit-folder)
  160. (vm-imap . vm-visit-imap-folder)
  161. (gnus . gnus)
  162. (file . find-file)
  163. (wl . wl)))
  164. :config
  165. (set-face-attribute
  166. 'org-document-title nil
  167. :foreground "#aa573c"
  168. :weight 'bold
  169. :height 1.6)
  170. (font-lock-add-keywords 'org-mode
  171. '(("^ +\\([-*+]\\) "
  172. (0 (prog1 ()
  173. (compose-region (match-beginning 1)
  174. (match-end 1)
  175. "•"))))))
  176. (dolist (face '((org-level-1 outline-1 1.35 "#ff6161")
  177. (org-level-2 outline-2 1.30 "#ff9b61")
  178. (org-level-3 outline-3 1.25 "#fff861")
  179. (org-level-4 outline-4 1.20 "#81ff61")
  180. (org-level-5 outline-5 1.15 "#61ffb5")
  181. (org-level-6 outline-6 1.10 "#61c8ff")
  182. (org-level-7 outline-7 1.05 "#8161ff")
  183. (org-level-8 outline-8 1.00 "#ff61e2")))
  184. (set-face-attribute
  185. (nth 0 face) nil
  186. :inherit (nth 1 face)
  187. :height (nth 2 face))
  188. (set-face-attribute
  189. (nth 1 face) nil
  190. :foreground (nth 3 face))))
  191. (use-package org-bullets
  192. :ensure t
  193. :after org
  194. :hook (org-mode . org-bullets-mode)
  195. :init
  196. (setq org-bullets-bullet-list '("•" "‣" "⁃" "◦" "○")))
  197. ;; adjustments
  198. (use-package smart-tabs-mode
  199. :ensure t
  200. :after (fish-mode glsl-mode rust-mode)
  201. :config
  202. (smart-tabs-add-language-support powershell powershell-mode-hook
  203. ((powershell-indent-line . powershell-indent)))
  204. (smart-tabs-add-language-support rust rust-mode-hook
  205. ((rust-mode-indent-line . rust-indent-offset)))
  206. (smart-tabs-add-language-support fish fish-mode-hook
  207. ((fish-indent-line . fish-indent-offset)))
  208. (smart-tabs-add-language-support glsl glsl-mode-hook
  209. ((c-indent-line . c-basic-offset)
  210. (c-indent-region . c-basic-offset)))
  211. (smart-tabs-insinuate
  212. 'c
  213. 'fish
  214. 'javascript
  215. 'rust
  216. 'glsl))
  217. (use-package ialign
  218. :ensure t
  219. :init
  220. (setq ialign-initial-repeat t))
  221. (use-package rainbow-delimiters
  222. :ensure t
  223. :hook (prog-mode . rainbow-delimiters-mode)
  224. :init
  225. (setq rainbow-delimiters-max-face-count 8)
  226. :config
  227. (dolist (face '((rainbow-delimiters-depth-1-face . "#e88385")
  228. (rainbow-delimiters-depth-2-face . "#ec79c0")
  229. (rainbow-delimiters-depth-3-face . "#cb88e8")
  230. (rainbow-delimiters-depth-4-face . "#9181e8")
  231. (rainbow-delimiters-depth-5-face . "#8dc8e8")
  232. (rainbow-delimiters-depth-6-face . "#9fe8b6")
  233. (rainbow-delimiters-depth-7-face . "#e2e8ab")
  234. (rainbow-delimiters-depth-8-face . "#e8c498")))
  235. (set-face-attribute (car face) nil :foreground (cdr face))))
  236. (use-package undo-tree
  237. :ensure t)
  238. (use-package whitespace
  239. :hook (prog-mode . whitespace-mode)
  240. :init
  241. (setq whitespace-style '(face
  242. space-before-tab
  243. space-mark
  244. spaces
  245. tab-mark
  246. tabs
  247. trailing))
  248. :config
  249. (dolist (face '(whitespace-space whitespace-tab))
  250. (set-face-attribute face nil :background nil :foreground "#7e4594")))
  251. (use-package hl-line
  252. :hook (prog-mode . hl-line-mode))
  253. (use-package image-file
  254. :config
  255. (auto-image-file-mode))
  256. ;; ergonomics
  257. (use-package mwheel
  258. :init
  259. (setq mouse-wheel-progressive-speed nil))
  260. (use-package vc
  261. :init
  262. (setq vc-follow-symlinks t))
  263. (use-package files
  264. :init
  265. (setq require-final-newline t))
  266. (use-package iedit
  267. :ensure t
  268. :init
  269. (setq iedit-toggle-key-default nil)
  270. :config
  271. (agw-set-key "s" #'iedit-mode))
  272. ;; file management
  273. (use-package dired
  274. :config
  275. (setq dired-listing-switches "-alhp --si")
  276. (agw-set-key "f" #'dired-jump)
  277. (agw-set-key "t" #'dired-create-empty-file))
  278. (use-package ranger
  279. :ensure t
  280. :after dired
  281. :hook (dired-mode . ranger-override-dired-fn)
  282. :config
  283. (setq ranger-override-dired 'ranger))
  284. (use-package deadgrep
  285. :ensure t)
  286. ;; input
  287. (use-package mule
  288. :init
  289. (setq current-language-environment "UTF-8"
  290. keyboard-coding-system 'utf-8-unix))
  291. (use-package mozc
  292. :ensure t
  293. :after mule
  294. :config
  295. (setq default-input-method "japanese-mozc"))
  296. (use-package evil
  297. :ensure t
  298. :init
  299. (setq evil-cjk-emacs-word-boundary t
  300. evil-cross-lines t
  301. evil-mode-line-format 'after
  302. evil-shift-width 3
  303. evil-vsplit-window-right t
  304. evil-want-keybinding nil
  305. evil-indent-convert-tabs nil)
  306. ;; tags
  307. (setq evil-normal-state-tag "~"
  308. evil-insert-state-tag "i"
  309. evil-operator-state-tag "o"
  310. evil-replace-state-tag "r"
  311. evil-visual-state-tag 'agw-evil-visual-state-tag
  312. evil-motion-state-tag "m"
  313. evil-emacs-state-tag "x")
  314. :config
  315. (evil-mode t)
  316. (evil-global-set-key 'visual (kbd "g s") #'sort-lines)
  317. (evil-global-set-key 'visual (kbd "g a") #'ialign))
  318. (use-package evil-collection
  319. :ensure t
  320. :after evil
  321. :config
  322. (evil-collection-init))
  323. ;; visuals
  324. (use-package simple
  325. :init
  326. (setq line-move-ignore-invisible nil)
  327. :config
  328. (transient-mark-mode t))
  329. (use-package tool-bar
  330. :config
  331. (tool-bar-mode 0))
  332. (use-package menu-bar
  333. :config
  334. (menu-bar-mode 0))
  335. (use-package paren
  336. :init
  337. (setq show-paren-delay 0.0
  338. show-paren-style 'parenthesis)
  339. :config
  340. (show-paren-mode t))
  341. (use-package fringe
  342. :config
  343. (fringe-mode 0))
  344. ;; EOF