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.

452 lines
12KB

  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 #'agw-flyspell-prog-mode)
  22. (add-hook 'prog-mode-hook #'prettify-symbols-mode)
  23. (add-hook 'prog-mode-hook #'subword-mode)
  24. ;; `text-mode'
  25. (add-hook 'text-mode-hook #'agw-flyspell-prog-mode)
  26. (add-hook 'text-mode-hook #'subword-mode)
  27. ;; `hack-local-variables'
  28. (add-hook 'hack-local-variables-hook #'agw-after-local-vars)
  29. ;; macros
  30. (setq initial-buffer-choice
  31. (lambda ()
  32. (if (buffer-file-name)
  33. (current-buffer)
  34. (find-file "~/org/init.org"))))
  35. (add-hook 'emacs-lisp-mode-hook #'agw-fp-mode)
  36. (add-hook 'lisp-mode-hook #'agw-fp-mode)
  37. (add-hook 'reb-lisp-mode-hook #'agw-fp-mode)
  38. (add-hook 'scheme-mode-hook #'agw-fp-mode)
  39. (add-hook 'before-save-hook #'agw-before-save)
  40. (agw-set-key "b d" #'kill-this-buffer)
  41. (agw-set-key "b e" #'ibuffer)
  42. (agw-set-key "m j" #'agw-create-back-link)
  43. (agw-set-key "m k" #'agw-create-memb-link)
  44. (agw-set-key "m l" #'agw-create-mthd-link)
  45. (agw-set-key "a" #'org-archive-to-archive-sibling)
  46. (agw-set-key "A" #'org-force-cycle-archived)
  47. (agw-set-key "k" #'deadgrep)
  48. (agw-key-map-mode)
  49. (global-set-key (kbd "C-x C-<tab>") #'agw-key-map-mode)
  50. ;; packages
  51. (require 'package)
  52. (unless (package-installed-p 'use-package)
  53. (package-refresh-contents)
  54. (package-install 'use-package))
  55. ;; theme
  56. (use-package base16-theme
  57. :ensure t
  58. :config
  59. (defvar agw-base16-fira-colors
  60. '(:base00 "#0f0c11" ; default bg
  61. :base01 "#1b161f" ; lighter bg
  62. :base02 "#382c3f" ; selection bg
  63. :base03 "#505170" ; comments
  64. :base04 "#8d6f9f" ; dark fg
  65. :base05 "#ffffff" ; default fg, caret, delims, ops
  66. :base06 "#c59cdf" ; light fg
  67. :base07 "#e1b2ff" ; light bg
  68. :base08 "#e873af" ; vars, tags, lists, deletion
  69. :base09 "#f367f8" ; ints, bools, constants, attribs
  70. :base0A "#53bdb1" ; classes, bold, search bg
  71. :base0B "#5dffae" ; strings, inherited, code, insertion
  72. :base0C "#ff344f" ; support, regexps, escapes, quotes
  73. :base0D "#ba8cc6" ; funcs, methods, attrib ids, headings
  74. :base0E "#e8a8c9" ; keywords, storage, change
  75. :base0F "#b03060")) ; deprecated, open/close tags
  76. (deftheme agw-base16-fira)
  77. (base16-theme-define 'agw-base16-fira agw-base16-fira-colors)
  78. (provide-theme 'agw-base16-fira)
  79. (provide 'agw-base16-fira-theme)
  80. (enable-theme 'agw-base16-fira))
  81. (use-package inkpot-theme
  82. :after base16-theme
  83. :ensure t
  84. :config
  85. (unless (display-graphic-p)
  86. (load-theme 'inkpot t nil))
  87. (set-face-attribute 'mode-line nil
  88. :background "#0a0a0a"
  89. :foreground "#92ebf0"))
  90. ;; major modes
  91. (use-package elisp-mode)
  92. (use-package eldoc)
  93. (use-package powershell
  94. :ensure t
  95. :init
  96. (defvaralias 'powershell-indent 'tab-width))
  97. (use-package js
  98. :init
  99. (defvaralias 'js-indent-level 'tab-width))
  100. (use-package css-mode
  101. :init
  102. (defvaralias 'css-indent-offset 'tab-width))
  103. (use-package lua-mode
  104. :ensure t
  105. :init
  106. (setq lua-indent-nested-block-content-align nil))
  107. (use-package json-mode
  108. :ensure t
  109. :after js
  110. :init
  111. (defvaralias 'json-reformat:indent-width 'tab-width))
  112. (use-package mmm-mode
  113. :ensure t)
  114. (use-package mmm-auto
  115. :init
  116. (setq mmm-submode-decoration-level 0)
  117. :config
  118. (mmm-add-mode-ext-class 'ruby-mode nil 'here-doc))
  119. (use-package python
  120. :init
  121. (defvaralias 'python-indent-offset 'tab-width))
  122. (use-package cc-mode
  123. :hook (( c-mode . agw-cc-mode)
  124. (c++-mode . agw-cc-mode))
  125. :mode (("\\.zsc\\'" . c-mode)
  126. ("\\.zc\\'" . c-mode))
  127. :init
  128. (setq c-auto-align-backslashes nil
  129. c-basic-offset tab-width
  130. c-default-style "linux")
  131. (defvaralias 'c-basic-offset 'tab-width))
  132. (use-package fish-mode
  133. :ensure t
  134. :init
  135. (defvaralias 'fish-indent-offset 'tab-width))
  136. (use-package glsl-mode
  137. :ensure t)
  138. (use-package haskell-mode
  139. :ensure t
  140. :hook (haskell-mode . agw-fp-mode))
  141. (use-package markdown-mode
  142. :ensure t
  143. :hook ((markdown-mode . agw-flyspell-mode))
  144. :mode (("\\.mdwn\\'" . markdown-mode)))
  145. (use-package ninja-mode
  146. :ensure t)
  147. (use-package ruby-mode
  148. :hook ((ruby-mode . mmm-mode))
  149. :init
  150. (defvaralias 'ruby-indent-level 'tab-width)
  151. (setq ruby-insert-encoding-magic-comment nil))
  152. (use-package rust-mode
  153. :ensure t
  154. :init
  155. (defvaralias 'rust-indent-offset 'tab-width))
  156. ;; org-mode
  157. (use-package org
  158. :hook ((org-mode . agw-flyspell-mode)
  159. (org-mode . agw-org-mode))
  160. :init
  161. (setq org-fontify-whole-heading-line t
  162. org-hide-emphasis-markers t
  163. org-hide-leading-stars t
  164. org-hide-macro-markers t
  165. org-image-actual-width nil
  166. org-indent-indentation-per-level 2
  167. org-list-indent-offset 2
  168. org-log-done '(note)
  169. org-pretty-entities t
  170. org-return-follows-link t
  171. org-startup-folded nil
  172. org-startup-with-inline-images t
  173. org-link-frame-setup '((vm . vm-visit-folder)
  174. (vm-imap . vm-visit-imap-folder)
  175. (gnus . gnus)
  176. (file . find-file)
  177. (wl . wl)))
  178. :config
  179. (set-face-attribute
  180. 'org-document-title nil
  181. :foreground "#aa573c"
  182. :weight 'bold
  183. :height 1.6)
  184. (font-lock-add-keywords 'org-mode
  185. '(("^ +\\([-*+]\\) "
  186. (0 (prog1 ()
  187. (compose-region (match-beginning 1)
  188. (match-end 1)
  189. "•"))))))
  190. (dolist (face '((org-level-1 outline-1 1.35 "#ff6161")
  191. (org-level-2 outline-2 1.30 "#ff9b61")
  192. (org-level-3 outline-3 1.25 "#fff861")
  193. (org-level-4 outline-4 1.20 "#81ff61")
  194. (org-level-5 outline-5 1.15 "#61ffb5")
  195. (org-level-6 outline-6 1.10 "#61c8ff")
  196. (org-level-7 outline-7 1.05 "#8161ff")
  197. (org-level-8 outline-8 1.00 "#ff61e2")))
  198. (set-face-attribute
  199. (nth 0 face) nil
  200. :inherit (nth 1 face)
  201. :height (nth 2 face))
  202. (set-face-attribute
  203. (nth 1 face) nil
  204. :foreground (nth 3 face))))
  205. (use-package org-bullets
  206. :ensure t
  207. :after org
  208. :hook (org-mode . org-bullets-mode)
  209. :init
  210. (setq org-bullets-bullet-list '("•" "‣" "⁃" "◦" "○")))
  211. ;; adjustments
  212. (use-package smart-tabs-mode
  213. :ensure t
  214. :after (fish-mode glsl-mode rust-mode lua-mode)
  215. :config
  216. (smart-tabs-add-language-support powershell powershell-mode-hook
  217. ((powershell-indent-line . powershell-indent)))
  218. (smart-tabs-add-language-support rust rust-mode-hook
  219. ((rust-mode-indent-line . rust-indent-offset)))
  220. (smart-tabs-add-language-support fish fish-mode-hook
  221. ((fish-indent-line . fish-indent-offset)))
  222. (smart-tabs-add-language-support glsl glsl-mode-hook
  223. ((c-indent-line . c-basic-offset)
  224. (c-indent-region . c-basic-offset)))
  225. (smart-tabs-add-language-support lua lua-mode-hook
  226. ((lua-indent-line . lua-indent-level)))
  227. (smart-tabs-insinuate
  228. 'c
  229. 'fish
  230. 'glsl
  231. 'javascript
  232. 'lua
  233. 'rust))
  234. (use-package ialign
  235. :ensure t
  236. :init
  237. (setq ialign-initial-repeat t))
  238. (use-package rainbow-delimiters
  239. :ensure t
  240. :hook (prog-mode . rainbow-delimiters-mode)
  241. :init
  242. (setq rainbow-delimiters-max-face-count 8)
  243. :config
  244. (dolist (face '((rainbow-delimiters-depth-1-face . "#e88385")
  245. (rainbow-delimiters-depth-2-face . "#ec79c0")
  246. (rainbow-delimiters-depth-3-face . "#cb88e8")
  247. (rainbow-delimiters-depth-4-face . "#9181e8")
  248. (rainbow-delimiters-depth-5-face . "#8dc8e8")
  249. (rainbow-delimiters-depth-6-face . "#9fe8b6")
  250. (rainbow-delimiters-depth-7-face . "#e2e8ab")
  251. (rainbow-delimiters-depth-8-face . "#e8c498")))
  252. (set-face-attribute (car face) nil :foreground (cdr face))))
  253. (use-package undo-tree
  254. :ensure t)
  255. (use-package whitespace
  256. :hook (prog-mode . whitespace-mode)
  257. :init
  258. (setq whitespace-style '(face
  259. space-before-tab
  260. space-mark
  261. spaces
  262. tab-mark
  263. tabs
  264. trailing))
  265. :config
  266. (dolist (face '(whitespace-space whitespace-tab))
  267. (set-face-attribute face nil :background nil :foreground "#7e4594")))
  268. (use-package hl-line
  269. :hook (prog-mode . hl-line-mode))
  270. (use-package image-file
  271. :config
  272. (auto-image-file-mode))
  273. (use-package editorconfig
  274. :ensure t
  275. :config
  276. (editorconfig-mode 1))
  277. ;; ergonomics
  278. (use-package mwheel
  279. :init
  280. (setq mouse-wheel-progressive-speed nil))
  281. (use-package vc
  282. :init
  283. (setq vc-follow-symlinks t))
  284. (use-package files
  285. :init
  286. (setq require-final-newline t))
  287. (use-package iedit
  288. :ensure t
  289. :init
  290. (setq iedit-toggle-key-default nil)
  291. :config
  292. (agw-set-key "s" #'iedit-mode))
  293. ;; file management
  294. (use-package dired
  295. :config
  296. (setq dired-listing-switches "-alhp --si")
  297. (agw-set-key "f" #'dired-jump)
  298. (agw-set-key "t" #'dired-create-empty-file))
  299. (use-package ranger
  300. :ensure t
  301. :after dired
  302. :hook (dired-mode . ranger-override-dired-fn)
  303. :config
  304. (setq ranger-override-dired 'ranger))
  305. (use-package deadgrep
  306. :ensure t)
  307. ;; input
  308. (unless (eq system-type 'windows-nt)
  309. (use-package mule
  310. :init
  311. (setq current-language-environment "UTF-8"
  312. keyboard-coding-system 'utf-8-unix))
  313. (use-package mozc
  314. :ensure t
  315. :after mule
  316. :config
  317. (setq default-input-method "japanese-mozc")))
  318. (use-package evil
  319. :ensure t
  320. :init
  321. (setq evil-cjk-emacs-word-boundary t
  322. evil-cross-lines t
  323. evil-mode-line-format 'after
  324. evil-shift-width 3
  325. evil-vsplit-window-right t
  326. evil-want-keybinding nil
  327. evil-indent-convert-tabs nil)
  328. ;; tags
  329. (setq evil-normal-state-tag "~"
  330. evil-insert-state-tag "i"
  331. evil-operator-state-tag "o"
  332. evil-replace-state-tag "r"
  333. evil-visual-state-tag 'agw-evil-visual-state-tag
  334. evil-motion-state-tag "m"
  335. evil-emacs-state-tag "x")
  336. :config
  337. (evil-mode t)
  338. (evil-global-set-key 'visual (kbd "g s") #'sort-lines)
  339. (evil-global-set-key 'visual (kbd "g a") #'ialign))
  340. (use-package evil-collection
  341. :ensure t
  342. :after evil
  343. :config
  344. (evil-collection-init))
  345. ;; visuals
  346. (use-package simple
  347. :init
  348. (setq line-move-ignore-invisible nil)
  349. :config
  350. (transient-mark-mode t))
  351. (use-package tool-bar
  352. :config
  353. (tool-bar-mode 0))
  354. (use-package menu-bar
  355. :config
  356. (menu-bar-mode 0))
  357. (use-package paren
  358. :init
  359. (setq show-paren-delay 0.0
  360. show-paren-style 'parenthesis)
  361. :config
  362. (show-paren-mode t))
  363. (use-package fringe
  364. :config
  365. (fringe-mode 0))
  366. (use-package subword)
  367. (use-package dim
  368. :ensure t
  369. :after (editorconfig
  370. eldoc
  371. simple
  372. subword
  373. undo-tree
  374. whitespace)
  375. :config
  376. (dim-minor-names
  377. '((abbrev-mode "Ab")
  378. (editorconfig-mode "Ec")
  379. (eldoc-mode "El")
  380. (isearch-mode "Is")
  381. (subword-mode "Sw")
  382. (undo-tree-mode "Ut")
  383. (whitespace-mode "Ws"))))
  384. ;; end of init
  385. (setq gc-cons-threshold (* 1 1000 1000))
  386. ;; EOF