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.

250 lines
6.6KB

  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 100)
  28. (set-face-attribute 'default nil :font "Consolas")
  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. :config
  85. (ido-mode 1)
  86. (ido-everywhere 1))
  87. ;; Smex
  88. (use-package smex)
  89. (setq smex-save-file (concat user-emacs-directory ".smex-items"))
  90. (smex-initialize)
  91. (global-set-key (kbd "M-x") 'smex)
  92. ;; Langs that don't need much config
  93. (use-package yaml-mode
  94. :mode "\\.yaml\\'")
  95. (use-package toml-mode
  96. :mode "\\.toml\\'")
  97. (use-package gdscript-mode
  98. :mode "\\.gd\\'")
  99. (use-package papyrus-mode
  100. :load-path "papyrus-mode"
  101. :mode "\\.psc\\'")
  102. (use-package scopes-mode
  103. :load-path "scopes-mode"
  104. :mode "\\.sc\\'")
  105. (use-package nix-mode
  106. :mode "\\.nix\\'")
  107. (use-package json-mode
  108. :mode "\\.json\\'")
  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. ;; Haskell
  118. (use-package haskell-mode
  119. :mode "\\.hs\\'")
  120. ;; GLSL
  121. (use-package glsl-mode
  122. :mode ("\\.glsl\\'"
  123. "\\.vert\\'"
  124. "\\.frag\\'"
  125. "\\.geom\\'"))
  126. ;; Markdown
  127. (use-package markdown-mode)
  128. (add-to-list 'auto-mode-alist '("\\.md\\'" . markdown-mode))
  129. ;; Purescript
  130. (use-package psc-ide)
  131. (use-package purescript-mode
  132. :hook
  133. (lambda ()
  134. (psc-ide-mode)
  135. (turn-on-purescript-indentation))
  136. :config
  137. (customize-set-variable 'psc-ide-rebuild-on-save t))
  138. ;; JS
  139. (use-package js2-mode
  140. :mode ("\\.js\\'")
  141. :config
  142. (setq js-indent-level 2)
  143. (setq js2-strict-missing-semi-warning nil))
  144. ;; C
  145. (setq c-default-style "k&r"
  146. c-basic-offset 4)
  147. ;; Org
  148. (use-package org)
  149. (setq org-agenda-files '("~/org"))
  150. (define-key global-map (kbd "C-c l") 'org-store-link)
  151. (define-key global-map (kbd "C-c a") 'org-agenda)
  152. (setq org-checkbox-hierarchical-statistics t)
  153. (setq org-agenda-files '("~/org"))
  154. ;; Indent-after-yank
  155. (dolist (command '(yank yank-pop))
  156. (eval `(defadvice ,command (after indent-region activate)
  157. (and (not current-prefix-arg)
  158. (member major-mode '(emacs-lisp-mode python-mode
  159. plain-tex-mode
  160. c-mode
  161. c++-mode
  162. objc-mode
  163. latex-mode
  164. rust-mode))
  165. (let ((mark-even-if-inactive transient-mark-mode))
  166. (indent-region (region-beginning) (region-end) nil))))))
  167. ;; Tabs
  168. (defun infer-indentation-style ()
  169. "Counts spaces and tabs at the start of lines, the one found most is used as the indentation mode."
  170. (let ((space-count (how-many "^ " (point-min) (point-max)))
  171. (tab-count (how-many "^\t" (point-min) (point-max))))
  172. (if (> space-count tab-count) (setq indent-tabs-mode nil))
  173. (if (> tab-count space-count) (setq indent-tabs-mode t))))
  174. (setq-default indent-tabs-mode nil)
  175. (infer-indentation-style)
  176. (define-key global-map (kbd "RET") 'newline-and-indent)
  177. ;; Rainbow parens
  178. (use-package rainbow-delimiters
  179. :config
  180. (add-hook 'prog-mode-hook 'rainbow-delimiters-mode))
  181. ;; Flycheck
  182. (use-package flycheck
  183. :config
  184. (setq flycheck-check-syntax-automatically '(mode-enabled save))
  185. (add-hook 'after-init-hook #'global-flycheck-mode))
  186. (use-package flycheck-inline
  187. :after (flycheck)
  188. :config
  189. (with-eval-after-load 'flycheck
  190. (add-hook 'flycheck-mode-hook #'flycheck-inline-mode)))
  191. ;; Company
  192. (use-package company
  193. :config
  194. (add-hook 'after-init-hook 'global-company-mode)
  195. (define-key global-map (kbd "<backtab>") 'company-complete))
  196. ;; Compiling
  197. (global-set-key [f6] 'recompile)
  198. ;; Alacritty keys
  199. (define-key input-decode-map "\e[1;5A" [C-up])
  200. (define-key input-decode-map "\e[1;5B" [C-down])
  201. (define-key input-decode-map "\e[1;5D" [C-left])
  202. (define-key input-decode-map "\e[1;5C" [C-right])
  203. ;; Misc packages
  204. (use-package eldoc)
  205. ;; Fix hang on exit in Sway
  206. (setq x-select-enable-clipboard-manager nil)
  207. (provide 'init)
  208. ;;; init.el ends here