init.el 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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. :if (version<= "24.4" emacs-version)
  88. :pin melpa-stable)
  89. ; --------- C Syntax checker ---------
  90. (use-package flycheck-irony
  91. :hook c-mode
  92. :mode ("\\.c\\'" "\\.h\\'"))
  93. (use-package auto-complete)
  94. (use-package auto-complete-clang-async
  95. :requires auto-complete
  96. :hook c-mode
  97. :mode ("\\.c\\'" "\\.h\\'"))
  98. ;; ------------ Web Mode ------------
  99. (use-package multi-web-mode
  100. :init
  101. (setq mweb-default-major-mode 'html-mode
  102. mweb-tags '((php-mode "<\\?php\\|<\\? \\|<\\?=" "\\?>")
  103. (js-mode "<script[^>]*>" "</script>")
  104. (css-mode "<style[^>]*>" "</style>"))
  105. mweb-filename-extensions '("php" "htm" "html" "ctp" "phtml" "php4" "php5"))
  106. ; :mode (mapcar-dot* (format "\\.%s\\'" ext '("php" "htm" "html" "ctp" "phtml" "php4" "php5")))
  107. :config
  108. (multi-web-global-mode 1))
  109. ;; ------------ Git Mode ------------
  110. (when (version<= "24.4" emacs-version)
  111. (use-package magit
  112. :bind ("C-x g" . magit-status)))
  113. ;; ----------- Rust Mode ------------
  114. (use-package rust-mode
  115. :mode ("\\.rs\\'"))
  116. (use-package rust-playground
  117. :requires rust-mode)
  118. (use-package cargo
  119. :after rust-mode)
  120. (use-package flycheck-rust
  121. :after rust-mode)
  122. ;; ----------- i3 Support ----------
  123. (use-package i3wm
  124. :disabled
  125. :if (equal (getenv "DESKTOP_SESSION") "i3"))
  126. ;; --------- Racket Mode ----------
  127. (use-package racket-mode)
  128. ;; ---------- C# Mode -------------
  129. (use-package csharp-mode
  130. :if (version<= "24.4" emacs-version)
  131. :mode ("\\.cs\\'"))
  132. ;; ------- Markdown Mode ----------
  133. (when (version<= "24.4" emacs-version)
  134. (use-package markdown-mode
  135. :mode ("\\.markdown\\'" "\\.md\\'")))
  136. ;; ---- StackOverflow Client ------
  137. (use-package sx
  138. :disabled)
  139. ;; -------- Spellcheck ------------
  140. (defun flyspell-detect-ispell-args (&optional run-together)
  141. (cond ((string-match "aspell$" ispell-program-name)
  142. (append (list "--sug-mode=ultra" "--lang=en_US") (if run-together '("--run-together" "--run-together-limit=5" "--run-together-min=2"))))
  143. ((string-match "hunspell$" ispell-program-name)
  144. "-d en_US")))
  145. (use-package flyspell-correct-popup
  146. :bind ("M-s" . ispell-word)
  147. :hook ((text-mode . flyspell-mode)
  148. (prog-mode . flyspell-prog-mode)
  149. ((flyspell-mode flyspell-prog-mode) . flyspell-buffer))
  150. :config
  151. (cond
  152. ((executable-find "aspell")
  153. (setq ispell-program-name "aspell"))
  154. ((executable-find "hunspell")
  155. (setq ispell-program-name "hunspell")
  156. (setq ispell-local-dictionary "en_US")
  157. (setq ispell-local-dictionary-alist '(("en_US" "[[:alpha:]]" "[^[:alpha:]]" "[']" nil ("-d" "en_US") nil utf-8))))
  158. (t
  159. (setq ispell-program-name nil)))
  160. (setq-default ispell-extra-args (flyspell-detect-ispell-args t))
  161. (setq-default flyspell-issue-message-flag nil))
  162. ;; -------- REST Client ---------
  163. (use-package restclient
  164. :commands (restclient-copy-curl-command
  165. restclient-http-send-current
  166. restclient-http-send-current-raw
  167. restclient-http-send-current-stay-in-window
  168. restclient-jump-next
  169. restclient-jump-prev
  170. restclient-mark-current
  171. restclient-mode
  172. restclient-narrow-to-current
  173. restclient-outline-mode
  174. restclient-toggle-body-visibility
  175. restclient-toggle-body-visibility-or-indent))
  176. ;; ------- Highlight TODO -------
  177. (use-package hl-todo
  178. :commands (hl-todo-mode
  179. hl-todo-next
  180. hl-todo-occur
  181. hl-todo-previous)
  182. :hook (prog-mode . hl-todo-mode))
  183. ;; ---- Printer Integration -----
  184. (use-package printing
  185. :bind ("M-p" . print-buffer)
  186. :commands (print-buffer
  187. print-region
  188. lpr-buffer
  189. lpr-customize
  190. lpr-region)
  191. :config
  192. (pr-update-menus t))
  193. (custom-set-variables
  194. ;; custom-set-variables was added by Custom.
  195. ;; If you edit it by hand, you could mess it up, so be careful.
  196. ;; Your init file should contain only one such instance.
  197. ;; If there is more than one, they won't work right.
  198. '(package-selected-packages
  199. (quote
  200. (auto-complete auto-complete-clang-async 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))))
  201. (custom-set-faces
  202. ;; custom-set-faces was added by Custom.
  203. ;; If you edit it by hand, you could mess it up, so be careful.
  204. ;; Your init file should contain only one such instance.
  205. ;; If there is more than one, they won't work right.
  206. )