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.

477 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 yaml-mode
  94. :ensure t)
  95. (use-package cmake-mode
  96. :ensure t
  97. :init
  98. (defvaralias 'cmake-tab-width 'tab-width))
  99. (use-package powershell
  100. :ensure t
  101. :init
  102. (defvaralias 'powershell-indent 'tab-width))
  103. (use-package js
  104. :init
  105. (defvaralias 'js-indent-level 'tab-width))
  106. (use-package css-mode
  107. :init
  108. (defvaralias 'css-indent-offset 'tab-width))
  109. (use-package lua-mode
  110. :ensure t
  111. :init
  112. (setq lua-indent-nested-block-content-align nil))
  113. (use-package json-mode
  114. :ensure t
  115. :after js
  116. :init
  117. (defvaralias 'json-reformat:indent-width 'tab-width))
  118. (use-package nim-mode
  119. :ensure t
  120. :init
  121. (defvaralias 'nim-indent-offset 'tab-width))
  122. (use-package mmm-mode
  123. :ensure t)
  124. (use-package mmm-auto
  125. :init
  126. (setq mmm-submode-decoration-level 0)
  127. :config
  128. (mmm-add-mode-ext-class 'ruby-mode nil 'here-doc))
  129. (use-package python
  130. :init
  131. (defvaralias 'python-indent-offset 'tab-width))
  132. (use-package cc-mode
  133. :hook (( c-mode . agw-cc-mode)
  134. (c++-mode . agw-cc-mode))
  135. :mode (("\\.zsc\\'" . c-mode)
  136. ("\\.zc\\'" . c-mode)
  137. ("\\.build\\'" . c++-mode))
  138. :init
  139. (setq c-auto-align-backslashes nil
  140. c-basic-offset tab-width
  141. c-default-style "linux")
  142. (defvaralias 'c-basic-offset 'tab-width))
  143. (use-package fish-mode
  144. :ensure t
  145. :init
  146. (defvaralias 'fish-indent-offset 'tab-width))
  147. (use-package glsl-mode
  148. :ensure t)
  149. (use-package haskell-mode
  150. :ensure t
  151. :hook (haskell-mode . agw-fp-mode))
  152. (use-package markdown-mode
  153. :ensure t
  154. :hook ((markdown-mode . agw-flyspell-mode))
  155. :mode (("\\.mdwn\\'" . markdown-mode)))
  156. (use-package ninja-mode
  157. :ensure t)
  158. (use-package ruby-mode
  159. :hook ((ruby-mode . mmm-mode))
  160. :init
  161. (defvaralias 'ruby-indent-level 'tab-width)
  162. (setq ruby-insert-encoding-magic-comment nil))
  163. (use-package rust-mode
  164. :ensure t
  165. :init
  166. (defvaralias 'rust-indent-offset 'tab-width))
  167. (use-package sgml-mode
  168. :hook (html-mode . agw-fp-mode))
  169. ;; org-mode
  170. (use-package org
  171. :hook ((org-mode . agw-flyspell-mode)
  172. (org-mode . agw-org-mode))
  173. :init
  174. (setq org-fontify-whole-heading-line t
  175. org-hide-emphasis-markers t
  176. org-hide-leading-stars t
  177. org-hide-macro-markers t
  178. org-image-actual-width nil
  179. org-indent-indentation-per-level 2
  180. org-list-indent-offset 2
  181. org-log-done '(note)
  182. org-pretty-entities t
  183. org-return-follows-link t
  184. org-startup-folded nil
  185. org-startup-with-inline-images t
  186. org-link-frame-setup '((vm . vm-visit-folder)
  187. (vm-imap . vm-visit-imap-folder)
  188. (gnus . gnus)
  189. (file . find-file)
  190. (wl . wl)))
  191. :config
  192. (set-face-attribute
  193. 'org-document-title nil
  194. :foreground "#aa573c"
  195. :weight 'bold
  196. :height 1.6)
  197. (font-lock-add-keywords 'org-mode
  198. '(("^ +\\([-*+]\\) "
  199. (0 (prog1 ()
  200. (compose-region (match-beginning 1)
  201. (match-end 1)
  202. "•"))))))
  203. (dolist (face '((org-level-1 outline-1 1.35 "#ff6161")
  204. (org-level-2 outline-2 1.30 "#ff9b61")
  205. (org-level-3 outline-3 1.25 "#fff861")
  206. (org-level-4 outline-4 1.20 "#81ff61")
  207. (org-level-5 outline-5 1.15 "#61ffb5")
  208. (org-level-6 outline-6 1.10 "#61c8ff")
  209. (org-level-7 outline-7 1.05 "#8161ff")
  210. (org-level-8 outline-8 1.00 "#ff61e2")))
  211. (set-face-attribute
  212. (nth 0 face) nil
  213. :inherit (nth 1 face)
  214. :height (nth 2 face))
  215. (set-face-attribute
  216. (nth 1 face) nil
  217. :foreground (nth 3 face))))
  218. (use-package org-bullets
  219. :ensure t
  220. :after org
  221. :hook (org-mode . org-bullets-mode)
  222. :init
  223. (setq org-bullets-bullet-list '("•" "‣" "⁃" "◦" "○")))
  224. ;; adjustments
  225. (use-package smart-tabs-mode
  226. :ensure t
  227. :after (fish-mode glsl-mode rust-mode lua-mode)
  228. :config
  229. (smart-tabs-add-language-support powershell powershell-mode-hook
  230. ((powershell-indent-line . powershell-indent)))
  231. (smart-tabs-add-language-support rust rust-mode-hook
  232. ((rust-mode-indent-line . rust-indent-offset)))
  233. (smart-tabs-add-language-support fish fish-mode-hook
  234. ((fish-indent-line . fish-indent-offset)))
  235. (smart-tabs-add-language-support glsl glsl-mode-hook
  236. ((c-indent-line . c-basic-offset)
  237. (c-indent-region . c-basic-offset)))
  238. (smart-tabs-add-language-support lua lua-mode-hook
  239. ((lua-indent-line . lua-indent-level)))
  240. (smart-tabs-insinuate
  241. 'c
  242. 'fish
  243. 'glsl
  244. 'javascript
  245. 'lua
  246. 'rust))
  247. (use-package ialign
  248. :ensure t
  249. :init
  250. (setq ialign-initial-repeat t))
  251. (use-package rainbow-delimiters
  252. :ensure t
  253. :hook (prog-mode . rainbow-delimiters-mode)
  254. :init
  255. (setq rainbow-delimiters-max-face-count 8)
  256. :config
  257. (dolist (face '((rainbow-delimiters-depth-1-face . "#e88385")
  258. (rainbow-delimiters-depth-2-face . "#ec79c0")
  259. (rainbow-delimiters-depth-3-face . "#cb88e8")
  260. (rainbow-delimiters-depth-4-face . "#9181e8")
  261. (rainbow-delimiters-depth-5-face . "#8dc8e8")
  262. (rainbow-delimiters-depth-6-face . "#9fe8b6")
  263. (rainbow-delimiters-depth-7-face . "#e2e8ab")
  264. (rainbow-delimiters-depth-8-face . "#e8c498")))
  265. (set-face-attribute (car face) nil :foreground (cdr face))))
  266. (use-package undo-tree
  267. :ensure t)
  268. (use-package whitespace
  269. :hook (prog-mode . whitespace-mode)
  270. :init
  271. (setq whitespace-style '(face
  272. space-before-tab
  273. space-mark
  274. spaces
  275. tab-mark
  276. tabs
  277. trailing))
  278. :config
  279. (dolist (face '(whitespace-space whitespace-tab))
  280. (set-face-attribute face nil :background nil :foreground "#7e4594")))
  281. (use-package hl-line
  282. :hook (prog-mode . hl-line-mode))
  283. (use-package image-file
  284. :config
  285. (auto-image-file-mode))
  286. (use-package editorconfig
  287. :ensure t
  288. :config
  289. (editorconfig-mode 1))
  290. ;; ergonomics
  291. (use-package mwheel
  292. :init
  293. (setq mouse-wheel-progressive-speed nil))
  294. (use-package vc
  295. :init
  296. (setq vc-follow-symlinks t))
  297. (use-package files
  298. :init
  299. (setq require-final-newline t))
  300. (use-package iedit
  301. :ensure t
  302. :init
  303. (setq iedit-toggle-key-default nil)
  304. :config
  305. (agw-set-key "s" #'iedit-mode))
  306. ;; file management
  307. (use-package dired
  308. :config
  309. (setq dired-listing-switches "-alhp --si")
  310. (agw-set-key "f" #'dired-jump)
  311. (agw-set-key "t" #'dired-create-empty-file))
  312. (use-package ranger
  313. :ensure t
  314. :after dired
  315. :hook (dired-mode . ranger-override-dired-fn)
  316. :config
  317. (setq ranger-override-dired 'ranger))
  318. (use-package deadgrep
  319. :ensure t)
  320. ;; input
  321. (unless (eq system-type 'windows-nt)
  322. (use-package mule
  323. :init
  324. (setq current-language-environment "UTF-8"
  325. keyboard-coding-system 'utf-8-unix))
  326. (use-package mozc
  327. :ensure t
  328. :after mule
  329. :config
  330. (setq default-input-method "japanese-mozc")))
  331. (use-package evil
  332. :ensure t
  333. :init
  334. (setq evil-cjk-emacs-word-boundary t
  335. evil-cross-lines t
  336. evil-mode-line-format 'after
  337. evil-shift-width 3
  338. evil-vsplit-window-right t
  339. evil-want-keybinding nil
  340. evil-indent-convert-tabs nil)
  341. ;; tags
  342. (setq evil-normal-state-tag "~"
  343. evil-insert-state-tag "i"
  344. evil-operator-state-tag "o"
  345. evil-replace-state-tag "r"
  346. evil-visual-state-tag 'agw-evil-visual-state-tag
  347. evil-motion-state-tag "m"
  348. evil-emacs-state-tag "x")
  349. :config
  350. (evil-mode t)
  351. (evil-global-set-key 'visual (kbd "g s") #'sort-lines)
  352. (evil-global-set-key 'visual (kbd "g a") #'ialign))
  353. (use-package evil-collection
  354. :ensure t
  355. :after evil
  356. :config
  357. (evil-collection-init))
  358. ;; visuals
  359. (use-package simple
  360. :init
  361. (setq line-move-ignore-invisible nil)
  362. :config
  363. (transient-mark-mode t))
  364. (use-package tool-bar
  365. :config
  366. (tool-bar-mode 0))
  367. (use-package menu-bar
  368. :config
  369. (menu-bar-mode 0))
  370. (use-package paren
  371. :init
  372. (setq show-paren-delay 0.0
  373. show-paren-style 'parenthesis)
  374. :config
  375. (show-paren-mode t))
  376. (use-package fringe
  377. :config
  378. (fringe-mode 0))
  379. (use-package subword)
  380. (use-package dim
  381. :ensure t
  382. :after (editorconfig
  383. eldoc
  384. rainbow-mode
  385. simple
  386. subword
  387. undo-tree
  388. whitespace)
  389. :config
  390. (dim-minor-names
  391. '((abbrev-mode "Ab")
  392. (editorconfig-mode "Ec")
  393. (eldoc-mode "El")
  394. (isearch-mode "Is")
  395. (subword-mode "Sw")
  396. (undo-tree-mode "Ut")
  397. (whitespace-mode "Ws")
  398. (flyspell-mode "Fs")
  399. (rainbow-mode "Rb"))))
  400. (use-package rainbow-mode
  401. :ensure t
  402. :hook ((prog-mode . rainbow-mode)
  403. (text-mode . rainbow-mode)))
  404. ;; end of init
  405. (setq gc-cons-threshold (* 1 1000 1000))
  406. ;; EOF