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.

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