Personal emacs config
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

178 lines
5.5 KiB

7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
  1. ;; init.el --- Emacs configuration
  2. ;; INSTALL PACKAGES
  3. ;; --------------------------------------
  4. (require 'package)
  5. (add-to-list 'package-archives
  6. '("melpa" . "https://melpa.org/packages/") t)
  7. (package-initialize)
  8. (when (not package-archive-contents)
  9. (package-refresh-contents))
  10. (defvar myPackages
  11. '(better-defaults
  12. ein
  13. iedit
  14. elpy
  15. flycheck
  16. magit
  17. ssh-config-mode
  18. web-mode
  19. ; material-theme
  20. dracula-theme
  21. yaml-mode
  22. py-autopep8
  23. apache-mode
  24. visual-regexp-steroids))
  25. (mapc #'(lambda (package)
  26. (unless (package-installed-p package)
  27. (package-install package)))
  28. myPackages)
  29. ;; BASIC
  30. (require 'ssh-config-mode)
  31. (add-to-list 'auto-mode-alist '("~/.ssh/config\\'" . ssh-config-mode))
  32. (require 'yaml-mode)
  33. (add-to-list 'auto-mode-alist '("\\.yml\\'" . yaml-mode))
  34. ;; Window movement
  35. (global-set-key (kbd "C-c <left>") 'windmove-left)
  36. (global-set-key (kbd "C-c <right>") 'windmove-right)
  37. (global-set-key (kbd "C-c <up>") 'windmove-up)
  38. (global-set-key (kbd "C-c <down>") 'windmove-down)
  39. (global-set-key (kbd "C-;") 'iedit-mode)
  40. ;; Web-mode
  41. (require 'web-mode)
  42. (add-to-list 'auto-mode-alist '("\\.phtml\\'" . web-mode))
  43. (add-to-list 'auto-mode-alist '("\\.tpl\\.php\\'" . web-mode))
  44. (add-to-list 'auto-mode-alist '("\\.[agj]sp\\'" . web-mode))
  45. (add-to-list 'auto-mode-alist '("\\.as[cp]x\\'" . web-mode))
  46. (add-to-list 'auto-mode-alist '("\\.erb\\'" . web-mode))
  47. (add-to-list 'auto-mode-alist '("\\.mustache\\'" . web-mode))
  48. (add-to-list 'auto-mode-alist '("\\.djhtml\\'" . web-mode))
  49. (add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode))
  50. ;; Custom
  51. (setq dired-listing-switches "-alh")
  52. (defun duplicate-line()
  53. (interactive)
  54. (move-beginning-of-line 1)
  55. (kill-line)
  56. (yank)
  57. (open-line 1)
  58. (next-line 1)
  59. (yank)
  60. )
  61. (global-set-key (kbd "C-c C-d") 'duplicate-line)
  62. (require 'recentf)
  63. (recentf-mode 1)
  64. (global-set-key (kbd "C-<tab>") 'recentf-open-files)
  65. (global-set-key (kbd "C-x g") 'magit-status)
  66. (setq inhibit-startup-screen t)
  67. ;; use external ls
  68. (setq ls-lisp-use-insert-directory-program t)
  69. (cond
  70. ;; Windows fixes
  71. ((string-equal system-type "windows-nt")
  72. (progn
  73. (defun quote-exe (path)
  74. (w32-short-file-name path))
  75. (defun start-external-shell ()
  76. (interactive)
  77. (start-process-shell-command (format "cmd(%s)" default-directory) nil "start default.bat"))
  78. (global-set-key (kbd "C-S-C") 'start-external-shell)
  79. (setq insert-directory-program "C:/Program Files/git/usr/bin/ls.exe")
  80. (setq find-program (quote-exe "C:/Program Files/git/usr/bin/find.exe"))
  81. (setq grep-program (quote-exe "C:/Program Files/git/usr/bin/grep.exe"))
  82. (setq python-shell-interpreter (quote-exe (executable-find "python")))
  83. (setq python-check-command (quote-exe (executable-find "flake8")))
  84. ))
  85. ;; Linux-specific
  86. ((string-equal system-type "gnu/linux")
  87. (progn
  88. (setq python-shell-interpreter "python3")
  89. (setq elpy-rpc-python-command python-shell-interpreter)
  90. )))
  91. (add-hook 'git-commit-setup-hook 'git-commit-turn-on-flyspell)
  92. (add-hook 'before-save-hook 'delete-trailing-whitespace)
  93. ;; --------------------------------------
  94. ; (setq inhibit-startup-message t) ;; hide the startup message
  95. ; (load-theme 'material t) ;; load material theme
  96. (load-theme 'dracula t)
  97. (global-linum-mode t) ;; enable line numbers globally
  98. ;; PYTHON CONFIGURATION
  99. ;; --------------------------------------
  100. (elpy-enable)
  101. ;(debug-on-variable-change 'python-check-command)
  102. ; (elpy-use-ipython)
  103. ;; use flycheck not flymake with elpy
  104. (when (require 'flycheck nil t)
  105. (setq elpy-modules (delq 'elpy-module-flymake elpy-modules))
  106. (add-hook 'elpy-mode-hook 'flycheck-mode))
  107. ;; enable py-autopep8 formatting on save
  108. (require 'py-autopep8)
  109. (defun python-mode-keys ()
  110. "Modify python-mode local key map"
  111. (local-set-key (kbd "C-c C-p") 'py-autopep8))
  112. (add-hook 'python-mode-hook 'python-mode-keys)
  113. (add-hook 'elpy-mode-hook 'py-autopep8-enable-on-save)
  114. ;(setq python-flymake-command "\"c:/Program Files/Python37/Scripts/flake8.exe\"")
  115. ;(setq python-check-command "\"c:/Program Files/Python37/Scripts/flake8.exe\"")
  116. ; (setq elpy-rpc-python-command "\"c:/Program Files/Python37/pythonw.exe\" ")
  117. (setq elpy-syntax-check-command python-check-command)
  118. ;; init.el ends here
  119. (custom-set-variables
  120. ;; custom-set-variables was added by Custom.
  121. ;; If you edit it by hand, you could mess it up, so be careful.
  122. ;; Your init file should contain only one such instance.
  123. ;; If there is more than one, they won't work right.
  124. '(custom-safe-themes
  125. (quote
  126. ("274fa62b00d732d093fc3f120aca1b31a6bb484492f31081c1814a858e25c72e" default)))
  127. '(package-selected-packages
  128. (quote
  129. (
  130. python-django
  131. django-mode
  132. visual-regexp-steroids
  133. pcre2el vimrc-mode
  134. iedit
  135. transient
  136. magit
  137. dracula-theme
  138. py-autopep8
  139. flycheck
  140. elpy
  141. ein
  142. better-defaults
  143. ssh-config-mode
  144. yaml-mode
  145. apache-mode
  146. web-mode
  147. ))))
  148. (custom-set-faces
  149. ;; custom-set-faces was added by Custom.
  150. ;; If you edit it by hand, you could mess it up, so be careful.
  151. ;; Your init file should contain only one such instance.
  152. ;; If there is more than one, they won't work right.
  153. '(default ((t (:family "Roboto Mono" :foundry "outline" :slant normal :weight normal :height 113 :width normal)))))
  154. ;; Monkey patch
  155. ;(defun quote-exe (path)
  156. ; (if (string-match-p (regexp-quote " ") path)
  157. ; (shell-quote-argument path)
  158. ; path))
  159. ;(defun quote-exe (path)
  160. ; (replace-regexp-in-string " " "\\ " path)
  161. ;
  162. ;(advice-add 'executable-find :filter-return #'quote-exe)