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.

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