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.

124 lines
4.0 KiB

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" . "http://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. elpy
  14. flycheck
  15. magit
  16. ; material-theme
  17. dracula-theme
  18. yaml-mode
  19. py-autopep8
  20. apache-mode
  21. visual-regexp-steroids))
  22. (mapc #'(lambda (package)
  23. (unless (package-installed-p package)
  24. (package-install package)))
  25. myPackages)
  26. ;; BASIC
  27. (require 'yaml-mode)
  28. (add-to-list 'auto-mode-alist '("\\.yml\\'" . yaml-mode))
  29. (global-set-key (kbd "C-c <left>") 'windmove-left)
  30. (global-set-key (kbd "C-c <right>") 'windmove-right)
  31. (global-set-key (kbd "C-c <up>") 'windmove-up)
  32. (global-set-key (kbd "C-c <down>") 'windmove-down)
  33. (require 'recentf)
  34. (recentf-mode 1)
  35. (global-set-key (kbd "C-<tab>") 'recentf-open-files)
  36. (global-set-key (kbd "C-x g") 'magit-status)
  37. (setq inhibit-startup-screen t)
  38. (setq ls-lisp-use-insert-directory-program t) ;; use external ls
  39. (cond
  40. ;; Windows fixes
  41. ((string-equal system-type "windows-nt")
  42. (progn
  43. (defun quote-exe (path)
  44. (w32-short-file-name path))
  45. (setq insert-directory-program "C:/Program Files/git/usr/bin/ls.exe")
  46. (setq find-program (quote-exe "C:/Program Files/git/usr/bin/find.exe"))
  47. (setq python-shell-interpreter (quote-exe (executable-find "python")))
  48. (setq python-check-command (quote-exe (executable-find "flake8")))
  49. ))
  50. ;; Linux-specific
  51. ((string-equal system-type "gnu/linux")
  52. (progn
  53. (setq python-shell-interpreter "python3")
  54. (setq elpy-rpc-python-command python-shell-interpreter)
  55. )))
  56. (add-hook 'git-commit-setup-hook 'git-commit-turn-on-flyspell)
  57. (add-hook 'before-save-hook 'delete-trailing-whitespace)
  58. ;; --------------------------------------
  59. ; (setq inhibit-startup-message t) ;; hide the startup message
  60. ; (load-theme 'material t) ;; load material theme
  61. (load-theme 'dracula t)
  62. (global-linum-mode t) ;; enable line numbers globally
  63. ;; PYTHON CONFIGURATION
  64. ;; --------------------------------------
  65. (elpy-enable)
  66. ;(debug-on-variable-change 'python-check-command)
  67. ; (elpy-use-ipython)
  68. ;; use flycheck not flymake with elpy
  69. (when (require 'flycheck nil t)
  70. (setq elpy-modules (delq 'elpy-module-flymake elpy-modules))
  71. (add-hook 'elpy-mode-hook 'flycheck-mode))
  72. ;; enable py-autopep8 formatting on save
  73. (require 'py-autopep8)
  74. (defun python-mode-keys ()
  75. "Modify python-mode local key map"
  76. (local-set-key (kbd "C-c C-p") 'py-autopep8))
  77. (add-hook 'python-mode-hook 'python-mode-keys)
  78. (add-hook 'elpy-mode-hook 'py-autopep8-enable-on-save)
  79. ;(setq python-flymake-command "\"c:/Program Files/Python37/Scripts/flake8.exe\"")
  80. ;(setq python-check-command "\"c:/Program Files/Python37/Scripts/flake8.exe\"")
  81. ; (setq elpy-rpc-python-command "\"c:/Program Files/Python37/pythonw.exe\" ")
  82. (setq elpy-syntax-check-command python-check-command)
  83. ;; init.el ends here
  84. (custom-set-variables
  85. ;; custom-set-variables was added by Custom.
  86. ;; If you edit it by hand, you could mess it up, so be careful.
  87. ;; Your init file should contain only one such instance.
  88. ;; If there is more than one, they won't work right.
  89. '(custom-safe-themes
  90. (quote
  91. ("274fa62b00d732d093fc3f120aca1b31a6bb484492f31081c1814a858e25c72e" default)))
  92. '(package-selected-packages
  93. (quote
  94. (python-django django-mode visual-regexp-steroids pcre2el vimrc-mode iedit transient magit dracula-theme py-autopep8 flycheck elpy ein better-defaults))))
  95. (custom-set-faces
  96. ;; custom-set-faces was added by Custom.
  97. ;; If you edit it by hand, you could mess it up, so be careful.
  98. ;; Your init file should contain only one such instance.
  99. ;; If there is more than one, they won't work right.
  100. )
  101. ;; Monkey patch
  102. ;(defun quote-exe (path)
  103. ; (if (string-match-p (regexp-quote " ") path)
  104. ; (shell-quote-argument path)
  105. ; path))
  106. ;(defun quote-exe (path)
  107. ; (replace-regexp-in-string " " "\\ " path)
  108. ;
  109. ;(advice-add 'executable-find :filter-return #'quote-exe)