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