Just my emacs configuration, for convenience purposes. It's all copypasted from somewhere and probably breaks itself multiple times.
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.
 
 

253 lines
6.6 KiB

  1. ;;; init.el --- just my init file
  2. ;;; Commentary:
  3. ;;; This is just my init file, and these comments at the start are
  4. ;;; here to appease the lint.
  5. ;;; Feel free to copy any bits you might need, just don't tell anyone
  6. ;;; you got them from me.
  7. ;;; Code:
  8. (require 'package)
  9. (add-to-list 'package-archives
  10. '("MELPA" . "http://melpa.org/packages/"))
  11. (package-initialize)
  12. ;; use-package
  13. (unless (package-installed-p 'use-package)
  14. (package-refresh-contents)
  15. (package-install 'use-package))
  16. (require 'use-package)
  17. (setq use-package-always-ensure t)
  18. ;; Allow all themes to run
  19. (setq custom-safe-themes t)
  20. ;; Very visual stuff first
  21. ;; Mode line
  22. (use-package smart-mode-line
  23. :config
  24. (setq sml/theme 'dark)
  25. (sml/setup))
  26. ;; Font
  27. (set-face-attribute 'default nil :height 105)
  28. (set-face-attribute 'default nil :font "monospace")
  29. ;; Theme
  30. (add-to-list 'custom-theme-load-path "~/.emacs.d/themes")
  31. (use-package base16-theme
  32. :config
  33. (load-theme 'snazzy))
  34. ;; Whitespace
  35. (setq-default show-trailing-whitespace t)
  36. ;; Misc nice visual stuff
  37. (show-paren-mode 1)
  38. (set-face-attribute 'show-paren-match nil :weight 'normal)
  39. (global-hl-line-mode 0)
  40. ;(global-display-line-numbers-mode)
  41. (setq column-number-mode t)
  42. (setq ring-bell-function 'ignore)
  43. (menu-bar-mode -1)
  44. (when (fboundp 'tool-bar-mode)
  45. (tool-bar-mode -1))
  46. (when (fboundp 'scroll-bar-mode)
  47. (scroll-bar-mode -1))
  48. ;; End of very visual stuff
  49. ;; Customfile
  50. (setq custom-file "~/.emacs.d/custom.el")
  51. (load custom-file)
  52. ;; Increase GC Threshold - Speeds up startup according to zirrostig on GitHub
  53. (setq-default gc-cons-threshold 10000000)
  54. ;; Dear emacs,
  55. ;; please don't leave garbage all around my filesystem.
  56. (setq backup-directory-alist
  57. `((".*" . ,(concat user-emacs-directory
  58. "backups"))))
  59. (setq auto-save-default nil)
  60. (setq create-lockfiles nil)
  61. ;; Window switching
  62. (defun prev-window()
  63. "Other-window but with arg -1."
  64. (interactive)
  65. (other-window -1))
  66. (define-key global-map (kbd "C-x o") 'other-window)
  67. (define-key global-map (kbd "C-x p") 'prev-window)
  68. (when (boundp 'term-raw-map)
  69. (define-key term-raw-map (kbd "C-x o") 'other-window)
  70. (define-key term-raw-map (kbd "C-x p") 'prev-window))
  71. ;; ANSI escape codes in compilation from
  72. ;; http://endlessparentheses.com/ansi-colors-in-the-compilation-buffer-output.html
  73. (use-package ansi-color
  74. :config
  75. (defun endless/colorize-compilation ()
  76. "Colorize from `compilation-filter-start' to `point'."
  77. (let ((inhibit-read-only t))
  78. (ansi-color-apply-on-region
  79. compilation-filter-start (point))))
  80. (add-hook 'compilation-filter-hook
  81. #'endless/colorize-compilation))
  82. ;; Ido
  83. (use-package ido)
  84. (use-package ido-completing-read+)
  85. (ido-mode t)
  86. (setq ido-enable-flex-matching t)
  87. (setq ido-use-filename-at-point nil)
  88. (setq ido-auto-merge-work-directories-length -1)
  89. (setq ido-use-virtual-buffers t)
  90. (ido-ubiquitous-mode 1)
  91. ;; Smex
  92. (use-package smex)
  93. (setq smex-save-file (concat user-emacs-directory ".smex-items"))
  94. (smex-initialize)
  95. (global-set-key (kbd "M-x") 'smex)
  96. ;; Langs that don't need much config
  97. (use-package yaml-mode
  98. :mode "\\.yaml\\'")
  99. (use-package toml-mode
  100. :mode "\\.toml\\'")
  101. (use-package gdscript-mode
  102. :mode "\\.gd\\'")
  103. (use-package papyrus-mode
  104. :load-path "papyrus-mode"
  105. :mode "\\.psc\\'")
  106. (use-package scopes-mode
  107. :load-path "scopes-mode"
  108. :mode "\\.sc\\'")
  109. ;; Langs that do need config below
  110. ;; Rust
  111. (use-package rust-mode
  112. :config (setq rust-format-on-save t))
  113. (use-package flycheck-rust
  114. :config
  115. (with-eval-after-load 'rust-mode
  116. (add-hook 'flycheck-mode-hook #'flycheck-rust-setup)))
  117. ;; GLSL
  118. (use-package glsl-mode
  119. :mode ("\\.glsl\\'"
  120. "\\.vert\\'"
  121. "\\.frag\\'"
  122. "\\.geom\\'"))
  123. ;; Markdown
  124. (use-package markdown-mode)
  125. (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
  126. ;; Purescript
  127. (use-package psc-ide)
  128. (use-package purescript-mode
  129. :hook
  130. (lambda ()
  131. (psc-ide-mode)
  132. (turn-on-purescript-indentation))
  133. :config
  134. (customize-set-variable 'psc-ide-rebuild-on-save t))
  135. ;; JS
  136. (use-package rjsx-mode
  137. :mode ("\\.js\\'"
  138. "\\.json\\'")
  139. :config
  140. (setq js-indent-level 2)
  141. (setq js2-strict-missing-semi-warning nil))
  142. ;; Elm
  143. ;; Keys:
  144. ;; - Compile: C-c M-c
  145. ;; - Add type annotations: C-c C-a
  146. ;; - Clean imports: C-c C-r
  147. ;; - Sort imports: C-c C-s
  148. ;; - Format: C-c C-f
  149. ;; - Test: C-c C-v
  150. (use-package elm-mode
  151. :mode "\\.elm\\'"
  152. :config
  153. (setq elm-sort-imports-on-save t)
  154. (setq elm-format-on-save t))
  155. ;; C
  156. (setq c-default-style "k&r"
  157. c-basic-offset 4)
  158. ;; Flycheck
  159. (use-package flycheck
  160. :config
  161. (setq flycheck-check-syntax-automatically '(mode-enabled save))
  162. (add-hook 'after-init-hook #'global-flycheck-mode))
  163. (use-package flycheck-inline
  164. :after (flycheck)
  165. :config
  166. (with-eval-after-load 'flycheck
  167. (add-hook 'flycheck-mode-hook #'flycheck-inline-mode)))
  168. ;; Org
  169. (use-package org)
  170. (setq org-agenda-files '("~/org"))
  171. (define-key global-map (kbd "C-c l") 'org-store-link)
  172. (define-key global-map (kbd "C-c a") 'org-agenda)
  173. (setq org-checkbox-hierarchical-statistics t)
  174. (setq org-agenda-files '("~/org"))
  175. ;; Yanking
  176. (dolist (command '(yank yank-pop))
  177. (eval `(defadvice ,command (after indent-region activate)
  178. (and (not current-prefix-arg)
  179. (member major-mode '(emacs-lisp-mode python-mode
  180. plain-tex-mode
  181. c-mode
  182. c++-mode
  183. objc-mode
  184. latex-mode
  185. rust-mode))
  186. (let ((mark-even-if-inactive transient-mark-mode))
  187. (indent-region (region-beginning) (region-end) nil))))))
  188. ;; Tabs
  189. (defun infer-indentation-style ()
  190. (let ((space-count (how-many "^ " (point-min) (point-max)))
  191. (tab-count (how-many "^\t" (point-min) (point-max))))
  192. (if (> space-count tab-count) (setq indent-tabs-mode nil))
  193. (if (> tab-count space-count) (setq indent-tabs-mode t))))
  194. (setq-default indent-tabs-mode nil)
  195. (infer-indentation-style)
  196. (define-key global-map (kbd "RET") 'newline-and-indent)
  197. ;; Rainbow parens
  198. (use-package rainbow-delimiters
  199. :config
  200. (add-hook 'prog-mode-hook 'rainbow-delimiters-mode))
  201. ;; Company
  202. (use-package company
  203. :config
  204. (add-hook 'after-init-hook 'global-company-mode)
  205. (define-key global-map (kbd "<backtab>") 'company-complete))
  206. ;; Compiling
  207. (global-set-key [f6] 'recompile)
  208. ;; Misc packages
  209. (use-package eldoc)
  210. ;; Fix hang on exit in Sway
  211. (setq x-select-enable-clipboard-manager nil)
  212. (provide 'init)
  213. ;;; init.el ends here