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.

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