init.el 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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. ;; ----------- Package Managing -----------
  22. (require 'package-loader)
  23. ;; Delete selected text when typing (normal editor behavior)
  24. (delete-selection-mode t)
  25. ;; ------------- Keybindings -------------
  26. (require 'smart-home)
  27. (global-set-key (kbd "C-c /") 'comment-or-uncomment-region)
  28. (global-set-key (kbd "C-c C-k") 'compile)
  29. (global-set-key (kbd "M-<left>") 'backward-list)
  30. (global-set-key (kbd "M-<right>") 'forward-list)
  31. (global-set-key (kbd "M-<up>") 'racket-backward-up-list)
  32. ;; Can't seem to find forward-down-list.
  33. ;; Not very important since I would rarely use it anyway
  34. ;;(global-set-key (kbd "M-<down>") '?)
  35. (global-set-key (kbd "M-<delete>") 'kill-sexp)
  36. (defun revert-buffer-no-confirm ()
  37. "Revert buffer without confirmation."
  38. (interactive)
  39. (revert-buffer :ignore-auto :noconfirm))
  40. (global-set-key (kbd "M-f") 'revert-buffer)
  41. (global-set-key (kbd "M-F") 'revert-buffer-no-confirm)
  42. ;; ---------- Use X11 clipboard -----------
  43. (use-package xclip
  44. :if (executable-find "xclip")
  45. :init
  46. (add-to-list 'load-path "~/.emacs.d/elpa/xclip-1.4/")
  47. :config
  48. (xclip-mode 1))
  49. ;; --------- Parentheses Matching ---------
  50. (show-paren-mode)
  51. (use-package highlight-parentheses
  52. :init
  53. (define-globalized-minor-mode global-highlight-parentheses-mode
  54. highlight-parentheses-mode
  55. (lambda ()
  56. (highlight-parentheses-mode t)))
  57. :config
  58. (global-highlight-parentheses-mode t))
  59. ;; Use built-in pairing if available.
  60. ;; Otherwise install substitute
  61. (if (version<= "24.4" emacs-version)
  62. (electric-pair-mode)
  63. (use-package autopair
  64. :config
  65. (autopair-global-mode)))
  66. ;; ------------ xTerm Mouse ------------
  67. ;; Disable because it became annoying, sounds cool though.
  68. (use-package mouse
  69. :disabled
  70. :config
  71. (xterm-mouse-mode t))
  72. ;; ---------- Auto-complete -----------
  73. (use-package company
  74. :init
  75. (add-hook 'after-init-hook 'global-company-mode)
  76. :config
  77. (setq
  78. company-minimum-prefix-length 2
  79. ;; company-idle-delay nil
  80. ;; company-show-numbers t
  81. ;; company-tooltip-limit 20
  82. ;; company-dabbrev-downcase nil
  83. )
  84. ;; :bind ("C-;" . company-complete-common)
  85. )
  86. ;; ---------- Syntax Checking -----------
  87. (use-package flycheck
  88. :config
  89. (setq flycheck-check-syntax-automatically '(mode-enabled idle-change save)))
  90. ;; ----------- Scala Mode -----------
  91. (require 'scala)
  92. ;; ---------- Kotlin Mode -----------
  93. (require 'kotlin)
  94. ;; ------------ Web Mode ------------
  95. (require 'web)
  96. ;; ------------ Git Mode ------------
  97. ;; TODO: make resolving merge conflicts hotkeys not use "^"
  98. ;; TODO: Conflict resolution theme is unreadable
  99. (when (version<= "24.4" emacs-version)
  100. (use-package magit
  101. :bind ("C-x g" . magit-status)))
  102. ;; ----------- Rust Mode ------------
  103. (require 'rust)
  104. ;; ----------- Go Mode -------------
  105. (require 'go)
  106. ;; ----------- i3 Support ----------
  107. (use-package i3wm
  108. :disabled
  109. :if (equal (getenv "DESKTOP_SESSION") "i3"))
  110. ;; --------- Racket Mode ----------
  111. (use-package racket-mode)
  112. ;; ---------- Tex Mode ------------
  113. (require 'my-tex)
  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. (set-frame-font "DejaVu Sans Mono-10" nil t)
  131. (custom-set-variables
  132. ;; custom-set-variables was added by Custom.
  133. ;; If you edit it by hand, you could mess it up, so be careful.
  134. ;; Your init file should contain only one such instance.
  135. ;; If there is more than one, they won't work right.
  136. '(package-selected-packages
  137. (quote
  138. (gnu-elpa-keyring-update flycheck-kotlin kotlin-mode hl-todo restclient flyspell-correct-popup sx csharp-mode auctex company-go go-mode flycheck-rust cargo rust-playground rust-mode magit multi-web-mode ensime flycheck company highlight-parentheses xclip auto-package-update use-package))))
  139. (custom-set-faces
  140. ;; custom-set-faces was added by Custom.
  141. ;; If you edit it by hand, you could mess it up, so be careful.
  142. ;; Your init file should contain only one such instance.
  143. ;; If there is more than one, they won't work right.
  144. )
  145. (put 'downcase-region 'disabled nil)