init.el 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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. ;; ------------- Keybindings -------------
  21. (global-set-key (kbd "C-c /") 'comment-or-uncomment-region)
  22. (global-set-key (kbd "C-x g") 'magit-status)
  23. (global-set-key (kbd "C-c C-k") 'compile)
  24. (global-set-key (kbd "M-p") 'print-buffer)
  25. ;; ----------- Package Managing -----------
  26. ;; The package manager
  27. (require 'package)
  28. ;; Add package sources
  29. (setq
  30. package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
  31. ("org" . "https://orgmode.org/elpa/")
  32. ("melpa" . "https://melpa.org/packages/")
  33. ("melpa-stable" . "https://stable.melpa.org/packages/"))
  34. package-archive-priorities '(("melpa-stable" . 1)))
  35. (package-initialize)
  36. (unless (package-installed-p 'use-package)
  37. (package-refresh-contents)
  38. (package-install 'use-package))
  39. (require 'use-package)
  40. (setq use-package-always-ensure t)
  41. ;; ---------- Use X11 clipboard -----------
  42. (use-package xclip
  43. :config
  44. (dolist (hook '(text-mode-hook prog-mode-hook)) (add-hook hook (lambda () (xclip-mode)))))
  45. ;; --------- Parentheses Matching ---------
  46. (use-package highlight-parentheses
  47. :config
  48. (define-globalized-minor-mode global-highlight-parentheses-mode
  49. highlight-parentheses-mode
  50. (lambda ()
  51. (highlight-parentheses-mode t)))
  52. (global-highlight-parentheses-mode t)
  53. )
  54. (use-package autopair
  55. :config
  56. (autopair-global-mode))
  57. ;; ----------- Ensime -----------
  58. ;; Java/Scala featues. Includes:
  59. ;; * Inferred types
  60. ;; * Autocomplete
  61. ;; * Syntax highlighting
  62. ;; * Jump to source/docs
  63. ;; * Refactoring
  64. ;; * Error detection
  65. (use-package ensime
  66. :pin melpa-stable)
  67. ; --------- C Syntax checker ---------
  68. (use-package flycheck-irony)
  69. ;; xTerm mouse support
  70. ;; Disable because it became annoying, sounds cool though.
  71. ;;
  72. ;;(require 'mouse)
  73. ;;(xterm-mouse-mode t)
  74. ;; ---------- Color Themes ----------
  75. (use-package color-theme
  76. ;; TODO: Fixes error about missing directory. Don't know why.
  77. :init
  78. (unless (file-exists-p "~/.emacs.d/elpa/color-theme-20070910.1007/themes")
  79. (make-directory "~/.emacs.d/elpa/color-theme-20070910.1007/themes"))
  80. :config
  81. (color-theme-initialize))
  82. (use-package base16-theme
  83. :requires color-theme
  84. :config (load-theme 'base16-tomorrow-night t))
  85. ;; ------------ Web Mode ------------
  86. (use-package multi-web-mode
  87. :config
  88. (setq mweb-default-major-mode 'html-mode)
  89. (setq mweb-tags
  90. '((php-mode "<\\?php\\|<\\? \\|<\\?=" "\\?>")
  91. (js-mode "<script[^>]*>" "</script>")
  92. (css-mode "<style[^>]*>" "</style>")))
  93. (setq mweb-filename-extensions '("php" "htm" "html" "ctp" "phtml" "php4" "php5"))
  94. (multi-web-global-mode 1))
  95. ;; ------------ Git Mode ------------
  96. (use-package magit)
  97. ;; ----------- Rust Mode ------------
  98. (use-package rust-mode)
  99. (use-package rust-playground
  100. :requires rust-mode)
  101. (use-package cargo
  102. :requires rust-mode)
  103. (use-package flycheck-rust
  104. :requires rust-mode)
  105. ;; ----------- i3 Support ----------
  106. ;(if (equal (getenv "DESKTOP_SESSION") "i3")
  107. ; (use-package i3wm))
  108. ;; --------- Racket Mode ----------
  109. (use-package racket-mode)
  110. ;; --------- Scala Mode -----------
  111. (use-package scala-mode)
  112. ;; ---------- C# Mode -------------
  113. (use-package csharp-mode)
  114. ;; ------- Markdown Mode ----------
  115. (use-package markdown-mode)
  116. ;; ---- StackOverflow Client ------
  117. ;(use-package sx)
  118. ;; -------- Spellcheck ------------
  119. (defun flyspell-detect-ispell-args (&optional run-together)
  120. (cond ((string-match "aspell$" ispell-program-name)
  121. (append (list "--sug-mode=ultra" "--lang=en_US") (if run-together '("--run-together" "--run-together-limit=5" "--run-together-min=2"))))
  122. ((string-match "hunspell$" ispell-program-name)
  123. "-d en_US")))
  124. (use-package flyspell-correct-popup
  125. :config
  126. (cond
  127. ((executable-find "aspell")
  128. (setq ispell-program-name "aspell"))
  129. ((executable-find "hunspell")
  130. (setq ispell-program-name "hunspell")
  131. (setq ispell-local-dictionary "en_US")
  132. (setq ispell-local-dictionary-alist '(("en_US" "[[:alpha:]]" "[^[:alpha:]]" "[']" nil ("-d" "en_US") nil utf-8))))
  133. (t
  134. (setq ispell-program-name nil)))
  135. (setq-default ispell-extra-args (flyspell-detect-ispell-args t))
  136. (global-set-key (kbd "M-s") 'ispell-word)
  137. (setq-default flyspell-issue-message-flag nil)
  138. (dolist (hook '(text-mode-hook magit-mode-hook)) (add-hook hook (lambda () (flyspell-mode))))
  139. (add-hook 'prog-mode-hook (lambda () (flyspell-prog-mode))))
  140. ;; -------- REST Client ---------
  141. (use-package restclient)
  142. ;; ------- Highlight TODO -------
  143. (use-package hl-todo
  144. :config
  145. (add-hook 'prog-mode-hook (lambda () (hl-todo-mode))))
  146. ;; ---- Printer Integration -----
  147. (use-package printing
  148. :config
  149. (pr-update-menus t))
  150. (custom-set-variables
  151. ;; custom-set-variables was added by Custom.
  152. ;; If you edit it by hand, you could mess it up, so be careful.
  153. ;; Your init file should contain only one such instance.
  154. ;; If there is more than one, they won't work right.
  155. '(package-selected-packages
  156. (quote
  157. (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))))
  158. (custom-set-faces
  159. ;; custom-set-faces was added by Custom.
  160. ;; If you edit it by hand, you could mess it up, so be careful.
  161. ;; Your init file should contain only one such instance.
  162. ;; If there is more than one, they won't work right.
  163. )