init.el 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  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. (defun smart-beginning-of-line ()
  27. "Move point to first non-whitespace character or beginning-of-line.
  28. Move point to the first non-whitespace character on this line.
  29. If point was already at that position, move point to beginning of line."
  30. (interactive "^")
  31. ;(if (version< "22" emacs-version) (interactive "^") (interactive))
  32. (let ((oldpos (point)))
  33. (beginning-of-line-text); goes to first significant character
  34. ;(back-to-indentation); goes to first non-whitespace
  35. (and (= oldpos (point))
  36. (beginning-of-line))))
  37. (global-set-key [home] 'smart-beginning-of-line)
  38. (global-set-key (kbd "C-c /") 'comment-or-uncomment-region)
  39. (global-set-key (kbd "C-c C-k") 'compile)
  40. ;; ----------- Package Managing -----------
  41. ;; The package manager
  42. (require 'package)
  43. ;; Add package sources
  44. (setq package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
  45. ("org" . "https://orgmode.org/elpa/")
  46. ("melpa" . "https://melpa.org/packages/")
  47. ("melpa-stable" . "https://stable.melpa.org/packages/"))
  48. package-archive-priorities '(("melpa" . 1)))
  49. (package-initialize)
  50. (unless (package-installed-p 'use-package)
  51. (package-refresh-contents)
  52. (package-install 'use-package))
  53. (require 'use-package)
  54. (setq use-package-always-ensure t)
  55. ;; ---------- Use X11 clipboard -----------
  56. (use-package xclip
  57. :if (executable-find "xclip")
  58. :config (xclip-mode 1))
  59. ;; ---------- Color Themes ----------
  60. (use-package color-theme
  61. :init
  62. ;; TODO: Fixes error about missing directory. Don't know why.
  63. (unless (file-exists-p "~/.emacs.d/elpa/color-theme-20070910.1007/themes")
  64. (make-directory "~/.emacs.d/elpa/color-theme-20070910.1007/themes"))
  65. :config
  66. (color-theme-initialize))
  67. (use-package base16-theme
  68. :requires color-theme
  69. :config (load-theme 'base16-tomorrow-night t))
  70. ;; --------- Parentheses Matching ---------
  71. (show-paren-mode)
  72. (use-package highlight-parentheses
  73. :config
  74. (define-globalized-minor-mode global-highlight-parentheses-mode
  75. highlight-parentheses-mode
  76. (lambda ()
  77. (highlight-parentheses-mode t)))
  78. (global-highlight-parentheses-mode t))
  79. (use-package autopair
  80. :config
  81. (autopair-global-mode))
  82. ;; ------------ xTerm Mouse ------------
  83. ;; Disable because it became annoying, sounds cool though.
  84. (use-package mouse
  85. :disabled
  86. :config
  87. (xterm-mouse-mode t))
  88. ;; ----------- Ensime -----------
  89. ;; Java/Scala featues. Includes:
  90. ;; * Inferred types
  91. ;; * Autocomplete
  92. ;; * Syntax highlighting
  93. ;; * Jump to source/docs
  94. ;; * Refactoring
  95. ;; * Error detection
  96. (use-package scala-mode
  97. :commands (scala-mode))
  98. ;:mode "\\.scala\\'")
  99. (use-package company)
  100. (when (version<= "24.4" emacs-version)
  101. (use-package ensime
  102. :requires company
  103. :hook (scala-mode java-mode)
  104. :config (setq ensime-startup-notification nil)
  105. :pin melpa-stable))
  106. ; --------- C Syntax checker ---------
  107. (use-package flycheck-irony
  108. :hook c-mode)
  109. ; :mode ("\\.c\\'" "\\.h\\'")
  110. (use-package auto-complete)
  111. (use-package auto-complete-clang-async
  112. :requires auto-complete
  113. :hook c-mode
  114. :mode ("\\.c\\'" "\\.h\\'"))
  115. ;; ------------ Web Mode ------------
  116. (use-package multi-web-mode
  117. :init
  118. (setq mweb-default-major-mode 'html-mode
  119. mweb-tags '((php-mode "<\\?php\\|<\\? \\|<\\?=" "\\?>")
  120. (js-mode "<script[^>]*>" "</script>")
  121. (css-mode "<style[^>]*>" "</style>"))
  122. mweb-filename-extensions '("php" "htm" "html" "ctp" "phtml" "php4" "php5"))
  123. ; :mode (mapcar-dot* (format "\\.%s\\'" ext '("php" "htm" "html" "ctp" "phtml" "php4" "php5")))
  124. :config
  125. (multi-web-global-mode 1))
  126. ;; ------------ Git Mode ------------
  127. (when (version<= "24.4" emacs-version)
  128. (use-package magit
  129. :bind ("C-x g" . magit-status)))
  130. ;; ----------- Rust Mode ------------
  131. (use-package rust-mode)
  132. ; :mode ("\\.rs\\'")
  133. (use-package rust-playground
  134. :requires rust-mode)
  135. (use-package cargo
  136. :after rust-mode)
  137. (use-package flycheck-rust
  138. :after rust-mode)
  139. ;; ----------- i3 Support ----------
  140. (use-package i3wm
  141. :disabled
  142. :if (equal (getenv "DESKTOP_SESSION") "i3"))
  143. ;; --------- Racket Mode ----------
  144. (use-package racket-mode)
  145. ;; ---------- C# Mode -------------
  146. (use-package csharp-mode
  147. :if (version<= "24.4" emacs-version))
  148. ; :mode ("\\.cs\\'")
  149. ;; ------- Markdown Mode ----------
  150. (when (version<= "24.4" emacs-version)
  151. (use-package markdown-mode))
  152. ; :mode ("\\.markdown\\'" "\\.md\\'")
  153. ;; ---- StackOverflow Client ------
  154. (use-package sx
  155. :disabled)
  156. ;; -------- Spellcheck ------------
  157. (defun flyspell-detect-ispell-args (&optional run-together)
  158. (cond ((string-match "aspell$" ispell-program-name)
  159. (append (list "--sug-mode=ultra" "--lang=en_US") (if run-together '("--run-together" "--run-together-limit=5" "--run-together-min=2"))))
  160. ((string-match "hunspell$" ispell-program-name)
  161. "-d en_US")))
  162. (use-package flyspell-correct-popup
  163. :bind ("M-s" . ispell-word)
  164. :hook ((text-mode . flyspell-mode)
  165. (prog-mode . flyspell-prog-mode)
  166. ((flyspell-mode flyspell-prog-mode) . flyspell-buffer))
  167. :config
  168. (cond
  169. ((executable-find "aspell")
  170. (setq ispell-program-name "aspell"))
  171. ((executable-find "hunspell")
  172. (setq ispell-program-name "hunspell")
  173. (setq ispell-local-dictionary "en_US")
  174. (setq ispell-local-dictionary-alist '(("en_US" "[[:alpha:]]" "[^[:alpha:]]" "[']" nil ("-d" "en_US") nil utf-8))))
  175. (t
  176. (setq ispell-program-name nil)))
  177. (setq-default ispell-extra-args (flyspell-detect-ispell-args t))
  178. (setq-default flyspell-issue-message-flag nil))
  179. ;; -------- REST Client ---------
  180. (use-package restclient
  181. :commands (restclient-copy-curl-command
  182. restclient-http-send-current
  183. restclient-http-send-current-raw
  184. restclient-http-send-current-stay-in-window
  185. restclient-jump-next
  186. restclient-jump-prev
  187. restclient-mark-current
  188. restclient-mode
  189. restclient-narrow-to-current
  190. restclient-outline-mode
  191. restclient-toggle-body-visibility
  192. restclient-toggle-body-visibility-or-indent))
  193. ;; ------- Highlight TODO -------
  194. (use-package hl-todo
  195. :commands (hl-todo-mode
  196. hl-todo-next
  197. hl-todo-occur
  198. hl-todo-previous)
  199. :hook (prog-mode . hl-todo-mode))
  200. ;; ---- Printer Integration -----
  201. (use-package printing
  202. :bind ("M-p" . print-buffer)
  203. :commands (print-buffer
  204. print-region
  205. lpr-buffer
  206. lpr-customize
  207. lpr-region)
  208. :config
  209. (pr-update-menus t))
  210. (custom-set-variables
  211. ;; custom-set-variables was added by Custom.
  212. ;; If you edit it by hand, you could mess it up, so be careful.
  213. ;; Your init file should contain only one such instance.
  214. ;; If there is more than one, they won't work right.
  215. '(package-selected-packages
  216. (quote
  217. <<<<<<< HEAD
  218. (company 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))))
  219. =======
  220. (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))))
  221. >>>>>>> 7ce8d5af1ffc98a8f6ac335c67e48bbbd53e8f56
  222. (custom-set-faces
  223. ;; custom-set-faces was added by Custom.
  224. ;; If you edit it by hand, you could mess it up, so be careful.
  225. ;; Your init file should contain only one such instance.
  226. ;; If there is more than one, they won't work right.
  227. )