init.el 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. ;; Requires:
  2. ;; aspell
  3. ;; ----------- Default Variables -----------
  4. ;; Global variables
  5. (defvar backup-directory (concat user-emacs-directory "backups"))
  6. (unless (file-exists-p backup-directory)
  7. (make-directory backup-directory))
  8. (setq-default inhibit-startup-screen t
  9. column-number-mode t
  10. scroll-error-top-bottom t
  11. show-paren-delay 0.25
  12. tab-width 4
  13. indent-tabs-mode nil
  14. x-select-enable-clipboard t
  15. backup-directory-alist `(("." . ,backup-directory))
  16. delete-old-versions t)
  17. ;; (global-linum-mode)
  18. ;; Delete selected text when typing (normal editor behavior)
  19. (delete-selection-mode t)
  20. (defun mapcar-dot* (f list)
  21. (loop for (a . b) on list
  22. collect (funcall f a)
  23. unless (listp b)
  24. collect (funcall f b)))
  25. ;; ------------- Keybindings -------------
  26. (global-set-key (kbd "C-c /") 'comment-or-uncomment-region)
  27. (global-set-key (kbd "C-c C-k") 'compile)
  28. ;; ----------- Package Managing -----------
  29. ;; The package manager
  30. (require 'package)
  31. ;; Add package sources
  32. (setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
  33. ("org" . "https://orgmode.org/elpa/")
  34. ("melpa" . "https://melpa.org/packages/")
  35. ("melpa-stable" . "https://stable.melpa.org/packages/"))
  36. package-archive-priorities '(("melpa" . 1)))
  37. (package-initialize)
  38. (unless (package-installed-p 'use-package)
  39. (package-refresh-contents)
  40. (package-install 'use-package))
  41. (require 'use-package)
  42. (setq use-package-always-ensure t)
  43. ;; ---------- Use X11 clipboard -----------
  44. (use-package xclip
  45. :hook ((text-mode-hook prog-mode-hook) . xclip-mode)
  46. :if (executable-find "xclip"))
  47. ;; ---------- Color Themes ----------
  48. (use-package color-theme
  49. :init
  50. ;; TODO: Fixes error about missing directory. Don't know why.
  51. (unless (file-exists-p "~/.emacs.d/elpa/color-theme-20070910.1007/themes")
  52. (make-directory "~/.emacs.d/elpa/color-theme-20070910.1007/themes"))
  53. :config
  54. (color-theme-initialize))
  55. (use-package base16-theme
  56. :requires color-theme
  57. :config (load-theme 'base16-tomorrow-night t))
  58. ;; --------- Parentheses Matching ---------
  59. (show-paren-mode)
  60. (use-package highlight-parentheses
  61. :config
  62. (define-globalized-minor-mode global-highlight-parentheses-mode
  63. highlight-parentheses-mode
  64. (lambda ()
  65. (highlight-parentheses-mode t)))
  66. (global-highlight-parentheses-mode t))
  67. (use-package autopair
  68. :config
  69. (autopair-global-mode))
  70. ;; ------------ xTerm Mouse ------------
  71. ;; Disable because it became annoying, sounds cool though.
  72. (use-package mouse
  73. :disabled
  74. :config
  75. (xterm-mouse-mode t))
  76. ;; ----------- Ensime -----------
  77. ;; Java/Scala featues. Includes:
  78. ;; * Inferred types
  79. ;; * Autocomplete
  80. ;; * Syntax highlighting
  81. ;; * Jump to source/docs
  82. ;; * Refactoring
  83. ;; * Error detection
  84. (use-package scala-mode
  85. :mode "\\.scala\\'")
  86. (use-package ensime
  87. :disabled
  88. :if (version<= "24.4" emacs-version)
  89. :pin melpa-stable)
  90. ; --------- C Syntax checker ---------
  91. (use-package flycheck-irony
  92. :hook c-mode
  93. :mode ("\\.c\\'" "\\.h\\'"))
  94. ;; ------------ Web Mode ------------
  95. (use-package multi-web-mode
  96. :init
  97. (setq mweb-default-major-mode 'html-mode
  98. mweb-tags '((php-mode "<\\?php\\|<\\? \\|<\\?=" "\\?>")
  99. (js-mode "<script[^>]*>" "</script>")
  100. (css-mode "<style[^>]*>" "</style>"))
  101. mweb-filename-extensions '("php" "htm" "html" "ctp" "phtml" "php4" "php5"))
  102. ; :mode (mapcar-dot* (format "\\.%s\\'" ext '("php" "htm" "html" "ctp" "phtml" "php4" "php5")))
  103. :config
  104. (multi-web-global-mode 1))
  105. ;; ------------ Git Mode ------------
  106. (when (version<= "24.4" emacs-version)
  107. (use-package magit
  108. :bind ("C-x g" . magit-status)))
  109. ;; ----------- Rust Mode ------------
  110. (use-package rust-mode
  111. :mode ("\\.rs\\'"))
  112. (use-package rust-playground
  113. :requires rust-mode)
  114. (use-package cargo
  115. :after rust-mode)
  116. (use-package flycheck-rust
  117. :after rust-mode)
  118. ;; ----------- i3 Support ----------
  119. (use-package i3wm
  120. :disabled
  121. :if (equal (getenv "DESKTOP_SESSION") "i3"))
  122. ;; --------- Racket Mode ----------
  123. (use-package racket-mode)
  124. ;; ---------- C# Mode -------------
  125. (use-package csharp-mode
  126. :if (version<= "24.4" emacs-version)
  127. :mode ("\\.cs\\'"))
  128. ;; ------- Markdown Mode ----------
  129. (when (version<= "24.4" emacs-version)
  130. (use-package markdown-mode
  131. :mode ("\\.markdown\\'" "\\.md\\'")))
  132. ;; ---- StackOverflow Client ------
  133. (use-package sx
  134. :disabled)
  135. ;; -------- Spellcheck ------------
  136. (defun flyspell-detect-ispell-args (&optional run-together)
  137. (cond ((string-match "aspell$" ispell-program-name)
  138. (append (list "--sug-mode=ultra" "--lang=en_US") (if run-together '("--run-together" "--run-together-limit=5" "--run-together-min=2"))))
  139. ((string-match "hunspell$" ispell-program-name)
  140. "-d en_US")))
  141. (use-package flyspell-correct-popup
  142. :bind ("M-s" . ispell-word)
  143. :hook ((text-mode . flyspell-mode)
  144. (prog-mode . flyspell-prog-mode)
  145. ((flyspell-mode flyspell-prog-mode) . flyspell-buffer))
  146. :config
  147. (cond
  148. ((executable-find "aspell")
  149. (setq ispell-program-name "aspell"))
  150. ((executable-find "hunspell")
  151. (setq ispell-program-name "hunspell")
  152. (setq ispell-local-dictionary "en_US")
  153. (setq ispell-local-dictionary-alist '(("en_US" "[[:alpha:]]" "[^[:alpha:]]" "[']" nil ("-d" "en_US") nil utf-8))))
  154. (t
  155. (setq ispell-program-name nil)))
  156. (setq-default ispell-extra-args (flyspell-detect-ispell-args t))
  157. (setq-default flyspell-issue-message-flag nil))
  158. ;; -------- REST Client ---------
  159. (use-package restclient
  160. :commands (restclient-copy-curl-command
  161. restclient-http-send-current
  162. restclient-http-send-current-raw
  163. restclient-http-send-current-stay-in-window
  164. restclient-jump-next
  165. restclient-jump-prev
  166. restclient-mark-current
  167. restclient-mode
  168. restclient-narrow-to-current
  169. restclient-outline-mode
  170. restclient-toggle-body-visibility
  171. restclient-toggle-body-visibility-or-indent))
  172. ;; ------- Highlight TODO -------
  173. (use-package hl-todo
  174. :commands (hl-todo-mode
  175. hl-todo-next
  176. hl-todo-occur
  177. hl-todo-previous)
  178. :hook (prog-mode . hl-todo-mode))
  179. ;; ---- Printer Integration -----
  180. (use-package printing
  181. :bind ("M-p" . print-buffer)
  182. :commands (print-buffer
  183. print-region
  184. lpr-buffer
  185. lpr-customize
  186. lpr-region)
  187. :config
  188. (pr-update-menus t))
  189. (custom-set-variables
  190. ;; custom-set-variables was added by Custom.
  191. ;; If you edit it by hand, you could mess it up, so be careful.
  192. ;; Your init file should contain only one such instance.
  193. ;; If there is more than one, they won't work right.
  194. '(package-selected-packages
  195. (quote
  196. (xclip hl-todo comment-tags restclient markdown-mode autopair highlight-parentheses flyspell-correct-popup rust-mode rust-playground slime-volleyball use-package multi-web-mode magit ensime color-theme base16-theme))))
  197. (custom-set-faces
  198. ;; custom-set-faces was added by Custom.
  199. ;; If you edit it by hand, you could mess it up, so be careful.
  200. ;; Your init file should contain only one such instance.
  201. ;; If there is more than one, they won't work right.
  202. )