init.el 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. (add-to-list 'load-path "~/.emacs.d/configs/")
  8. ;; ----------- Default Variables -----------
  9. ;; Global variables
  10. (defvar backup-directory (concat user-emacs-directory "backups"))
  11. (unless (file-exists-p backup-directory)
  12. (make-directory backup-directory))
  13. (setq-default inhibit-startup-screen t
  14. column-number-mode t
  15. scroll-error-top-bottom t
  16. show-paren-delay 0.25
  17. tab-width 4
  18. indent-tabs-mode nil
  19. backup-directory-alist `(("." . ,backup-directory))
  20. delete-old-versions t)
  21. ;; (global-linum-mode)
  22. ;; Delete selected text when typing (normal editor behavior)
  23. (delete-selection-mode t)
  24. ;; ------------- Keybindings -------------
  25. (require 'smart-home)
  26. (global-set-key (kbd "C-c /") 'comment-or-uncomment-region)
  27. (global-set-key (kbd "C-c C-k") 'compile)
  28. (global-set-key (kbd "M-<left>") 'backward-list)
  29. (global-set-key (kbd "M-<right>") 'forward-list)
  30. (global-set-key (kbd "M-<up>") 'racket-backward-up-list)
  31. ;; Can't seem to find forward-down-list.
  32. ;; Not very important since I would rarely use it anyway
  33. ;;(global-set-key (kbd "M-<down>") '?)
  34. (global-set-key (kbd "M-<delete>") 'kill-sexp)
  35. ;; ----------- Package Managing -----------
  36. (require 'package-loader)
  37. ;; ---------- Color Themes ----------
  38. ;; TODO: Fix warning underline to always be orange/yellow
  39. ;; Update: Seems it always takes the color of the foreground.
  40. ;; Also seems to ignore most properties. (e.g. overline, underline,
  41. ;; strike-though, etc.) Maybe it's an xterm problem?
  42. (use-package color-theme
  43. :config
  44. (color-theme-initialize)
  45. (load-theme 'Thomas-Experiement t))
  46. ;; ---------- Use X11 clipboard -----------
  47. (use-package xclip
  48. :if (executable-find "xclip")
  49. :init
  50. (add-to-list 'load-path "~/.emacs.d/elpa/xclip-1.4/")
  51. :config
  52. (xclip-mode 1))
  53. ;; --------- Parentheses Matching ---------
  54. (show-paren-mode)
  55. (use-package highlight-parentheses
  56. :init
  57. (define-globalized-minor-mode global-highlight-parentheses-mode
  58. highlight-parentheses-mode
  59. (lambda ()
  60. (highlight-parentheses-mode t)))
  61. :config
  62. (global-highlight-parentheses-mode t))
  63. ;; Use built-in pairing if available.
  64. ;; Otherwise install substitute
  65. (if (version<= "24.4" emacs-version)
  66. (electric-pair-mode)
  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. ;; ---------- Auto-complete -----------
  77. (use-package company
  78. :init
  79. (add-hook 'after-init-hook 'global-company-mode)
  80. :config
  81. (setq
  82. company-minimum-prefix-length 2
  83. ;; company-idle-delay nil
  84. ;; company-show-numbers t
  85. ;; company-tooltip-limit 20
  86. ;; company-dabbrev-downcase nil
  87. )
  88. ;; :bind ("C-;" . company-complete-common)
  89. )
  90. ;; ---------- Syntax Checking -----------
  91. (use-package flycheck
  92. :config
  93. (setq flycheck-check-syntax-automatically '(mode-enabled idle-change save)))
  94. ;; ----------- Scala Mode -----------
  95. (require 'scala)
  96. ;; ------------ Web Mode ------------
  97. (require 'web)
  98. ;; ------------ Git Mode ------------
  99. ;; TODO: make resolving merge conflicts hotkeys not use "^"
  100. ;; TODO: Conflict resolution theme is unreadable
  101. (when (version<= "24.4" emacs-version)
  102. (use-package magit
  103. :bind ("C-x g" . magit-status)))
  104. ;; ----------- Rust Mode ------------
  105. (require 'rust)
  106. ;; ----------- Go Mode -------------
  107. (require 'go)
  108. ;; ----------- i3 Support ----------
  109. (use-package i3wm
  110. :disabled
  111. :if (equal (getenv "DESKTOP_SESSION") "i3"))
  112. ;; --------- Racket Mode ----------
  113. (use-package racket-mode)
  114. ;; ---------- C# Mode -------------
  115. (use-package csharp-mode
  116. :if (version<= "24.4" emacs-version))
  117. ;; ------- Markdown Mode ----------
  118. (when (version<= "24.4" emacs-version)
  119. (use-package markdown-mode))
  120. ;; ---- StackOverflow Client ------
  121. (require 'stackoverflow)
  122. ;; -------- Spellcheck ------------
  123. (require 'spellcheck)
  124. ;; -------- REST Client ---------
  125. (require 'rest-client)
  126. ;; ------- Highlight TODO -------
  127. (require 'todo)
  128. ;; ---- Printer Integration -----
  129. (require 'printer)
  130. ;; Configure auto-complete if installed
  131. ;; Used in case something installs it as a dependency
  132. (when (package-installed 'auto-complete)
  133. (ac-config-default)
  134. ;; Fix conflict between flyspell and auto-complete
  135. (when (package-installed 'flyspell)
  136. (ac-flyspell-workaround)))