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.

74 lines
3.0 KiB

  1. (use-package python
  2. :mode ("\\.py\\'" . python-mode))
  3. ;; ##############
  4. ;; damit der EPC-Server funktioniert,
  5. ;; muss in /etc/hosts der Eintrag
  6. ;; 127.0.0.1 localhost
  7. ;; enthalten sein!
  8. ;; ##############
  9. ;; Python-Code ausführen:
  10. ;; C-C C-z open python shell
  11. ;; C-C C-c run content of buffer in opened shell
  12. ;; C-C C-r run selected region in python shell
  13. ;; virtualenv für python muss installiert sein
  14. ;; Fedora: # dnf install python3-virtualenv
  15. ;;
  16. ;; Benutzung
  17. ;; venv-workon: virtualenv aussuchen und setzen
  18. ;; venv-deactivate: deaktiviert virtualenv
  19. ;; venv-mkvirtualenv: erstellt neue virtualenv in venv-location
  20. ;; venv-lsvirtualenv: listet alle virtualenvs auf
  21. ;; venv-cdvirtualenv: wechselt default-Verzeichnis zum momentanen virtualenv-Verzeichnis
  22. ;; venv-cpvirtualenv: erstellt neue virtualenv aus einem exisiterenden.
  23. ;; fragt nach beiden Namen
  24. (use-package virtualenvwrapper
  25. :ensure t
  26. :init
  27. (venv-initialize-interactive-shells) ;;interactive shell support
  28. (venv-initialize-eshell) ;;eshell support
  29. (setq venv-location "~/Archiv/Programmierprojekte/Python/virtualenv/")
  30. (setq python-environment-directory venv-location)
  31. (add-hook 'venv-postmkvirtualenv-hook
  32. (lambda () (shell-command "pip install epc jedi")))
  33. ;; (add-hook 'venv-postactivate-hook 'jedi:stop-server) ;;server-neustart, wenn neue virtualenv
  34. ;; (add-hook 'venv-postdeactivate-hook 'jedi:stop-server) ;;server-neustart, wenn neue virtualenv
  35. )
  36. ;; sucht und aktiviert die virtualenv nach folgenden Aspekten:
  37. ;; .python-version im project-root (ethält absoluten Pfad zur virtualenv
  38. ;; .venv oder venv Verzeichnis im project-root
  39. ;; eine virtualenv mit dem selben Namen wie project-root
  40. ;; - project-root ist definiert als Verzeichnis, dass "auto-virtualenvwapper-project-root-files" enthält,
  41. ;; die da wären: .python-version, .dir-locals.el, .projectile, .emacs-project, .manage.py, .git
  42. ;; für mich zuverlässig funktioiert nur absoluter Pfadin .python-version
  43. (use-package auto-virtualenvwrapper
  44. :ensure t
  45. :config
  46. (add-hook 'python-mode-hook #'auto-virtualenvwrapper-activate))
  47. ;;activate on changing buffers
  48. ;; (add-hook 'window-configuration-change-hook #'auto-virtualenvwrapper-activate)
  49. ;;activate on focus in
  50. ;; (add-hook 'focus-in-hook #'auto-virtualenvwrapper-activate))
  51. (use-package py-autopep8
  52. :ensure t
  53. :config
  54. (add-hook 'python-mode-hook 'py-autopep8-enable-on-save))
  55. ;; benötigt pip install jedi / emerge dev-python/jedi
  56. (use-package company-jedi ;; company-mode completion backend for python jedi
  57. ;; :defer t
  58. :ensure t
  59. :config
  60. (defun my/python-mode-hook()
  61. (add-to-list 'company-backends 'company-jedi))
  62. (add-hook 'python-mode-hook 'my/python-mode-hook)
  63. )
  64. (provide 'lang-python)