init.el 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. ;; Requires:
  2. ;; aspell - Spell checking
  3. ;; xclip - Copy/Paste
  4. ;; Optional:
  5. ;; gocode - Go auto complete
  6. ;; Enable loading my custom config files
  7. ;; Added by Package.el. This must come before configurations of
  8. ;; installed packages. Don't delete this line. If you don't want it,
  9. ;; just comment it out by adding a semicolon to the start of the line.
  10. ;; You may delete these explanatory comments.
  11. (package-initialize)
  12. (add-to-list 'load-path "~/.emacs.d/configs/")
  13. ;; ----------- Default Variables -----------
  14. ;; Global variables
  15. (defvar backup-directory (concat user-emacs-directory "backups"))
  16. (unless (file-exists-p backup-directory)
  17. (make-directory backup-directory))
  18. (setq-default inhibit-startup-screen t
  19. column-number-mode t
  20. scroll-error-top-bottom t
  21. show-paren-delay 0.25
  22. tab-width 4
  23. indent-tabs-mode nil
  24. backup-directory-alist `(("." . ,backup-directory))
  25. delete-old-versions t)
  26. ;; (global-linum-mode)
  27. ;; Delete selected text when typing (normal editor behavior)
  28. (delete-selection-mode t)
  29. ;; ------------- Keybindings -------------
  30. (require 'smart-home)
  31. (global-set-key (kbd "C-c /") 'comment-or-uncomment-region)
  32. (global-set-key (kbd "C-c C-k") 'compile)
  33. (global-set-key (kbd "M-<left>") 'backward-list)
  34. (global-set-key (kbd "M-<right>") 'forward-list)
  35. (global-set-key (kbd "M-<up>") 'racket-backward-up-list)
  36. ;; Can't seem to find forward-down-list.
  37. ;; Not very important since I would rarely use it anyway
  38. ;;(global-set-key (kbd "M-<down>") '?)
  39. (global-set-key (kbd "M-<delete>") 'kill-sexp)
  40. (defun revert-buffer-no-confirm ()
  41. "Revert buffer without confirmation."
  42. (interactive)
  43. (revert-buffer :ignore-auto :noconfirm))
  44. (global-set-key (kbd "M-f") 'revert-buffer)
  45. (global-set-key (kbd "M-F") 'revert-buffer-no-confirm)
  46. ;; ----------- Package Managing -----------
  47. (require 'package-loader)
  48. ;; ---------- Color Themes ----------
  49. ;; TODO: Fix warning underline to always be orange/yellow
  50. ;; Update: Seems it always takes the color of the foreground.
  51. ;; Also seems to ignore most properties. (e.g. overline, underline,
  52. ;; strike-though, etc.) Maybe it's an xterm problem?
  53. (use-package color-theme
  54. :config
  55. (color-theme-initialize)
  56. (load-theme 'Thomas-Experiement t))
  57. ;; ---------- Use X11 clipboard -----------
  58. (use-package xclip
  59. :if (executable-find "xclip")
  60. :init
  61. (add-to-list 'load-path "~/.emacs.d/elpa/xclip-1.4/")
  62. :config
  63. (xclip-mode 1))
  64. ;; --------- Parentheses Matching ---------
  65. (show-paren-mode)
  66. (use-package highlight-parentheses
  67. :init
  68. (define-globalized-minor-mode global-highlight-parentheses-mode
  69. highlight-parentheses-mode
  70. (lambda ()
  71. (highlight-parentheses-mode t)))
  72. :config
  73. (global-highlight-parentheses-mode t))
  74. ;; Use built-in pairing if available.
  75. ;; Otherwise install substitute
  76. (if (version<= "24.4" emacs-version)
  77. (electric-pair-mode)
  78. (use-package autopair
  79. :config
  80. (autopair-global-mode)))
  81. ;; ------------ xTerm Mouse ------------
  82. ;; Disable because it became annoying, sounds cool though.
  83. (use-package mouse
  84. :disabled
  85. :config
  86. (xterm-mouse-mode t))
  87. ;; ---------- Auto-complete -----------
  88. (use-package company
  89. :init
  90. (add-hook 'after-init-hook 'global-company-mode)
  91. :config
  92. (setq
  93. company-minimum-prefix-length 2
  94. ;; company-idle-delay nil
  95. ;; company-show-numbers t
  96. ;; company-tooltip-limit 20
  97. ;; company-dabbrev-downcase nil
  98. )
  99. ;; :bind ("C-;" . company-complete-common)
  100. )
  101. ;; ---------- Syntax Checking -----------
  102. (use-package flycheck
  103. :config
  104. (setq flycheck-check-syntax-automatically '(mode-enabled idle-change save)))
  105. ;; ----------- Scala Mode -----------
  106. (require 'scala)
  107. ;; ------------ Web Mode ------------
  108. (require 'web)
  109. ;; ------------ Git Mode ------------
  110. ;; TODO: make resolving merge conflicts hotkeys not use "^"
  111. ;; TODO: Conflict resolution theme is unreadable
  112. (when (version<= "24.4" emacs-version)
  113. (use-package magit
  114. :bind ("C-x g" . magit-status)))
  115. ;; ----------- Rust Mode ------------
  116. (require 'rust)
  117. ;; ----------- Go Mode -------------
  118. (require 'go)
  119. ;; ----------- i3 Support ----------
  120. (use-package i3wm
  121. :disabled
  122. :if (equal (getenv "DESKTOP_SESSION") "i3"))
  123. ;; --------- Racket Mode ----------
  124. (use-package racket-mode)
  125. ;; ---------- Tex Mode ------------
  126. (require 'my-tex)
  127. ;; ---------- C# Mode -------------
  128. (use-package csharp-mode
  129. :if (version<= "24.4" emacs-version))
  130. ;; ------- Markdown Mode ----------
  131. (when (version<= "24.4" emacs-version)
  132. (use-package markdown-mode))
  133. ;; ---- StackOverflow Client ------
  134. (require 'stackoverflow)
  135. ;; -------- Spellcheck ------------
  136. (require 'spellcheck)
  137. ;; -------- REST Client ---------
  138. (require 'rest-client)
  139. ;; ------- Highlight TODO -------
  140. (require 'todo)
  141. ;; ---- Printer Integration -----
  142. (require 'printer)
  143. (set-frame-font "DejaVu Sans Mono-10" nil t)
  144. (custom-set-variables
  145. ;; custom-set-variables was added by Custom.
  146. ;; If you edit it by hand, you could mess it up, so be careful.
  147. ;; Your init file should contain only one such instance.
  148. ;; If there is more than one, they won't work right.
  149. '(package-selected-packages
  150. (quote
  151. (hl-todo restclient flyspell-correct-popup sx csharp-mode auctex racket-mode company-go go-mode flycheck-rust cargo rust-playground rust-mode magit multi-web-mode ensime flycheck company highlight-parentheses xclip color-theme auto-package-update use-package))))
  152. (custom-set-faces
  153. ;; custom-set-faces was added by Custom.
  154. ;; If you edit it by hand, you could mess it up, so be careful.
  155. ;; Your init file should contain only one such instance.
  156. ;; If there is more than one, they won't work right.
  157. )