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.

144 lines
4.7 KiB

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