Motore di metasearch che rispetta la privacy, hackerabile / pronuncia səːks. https://devol.it/it/searx
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.
 
 
 
 
 
 

134 lines
4.8 KiB

  1. ;;; .dir-locals.el
  2. ;;
  3. ;; If you get ``*** EPC Error ***`` (even after a jedi:install-server) in your
  4. ;; emacs session, mostly you have jedi-mode enabled but the python enviroment is
  5. ;; missed. The python environment has to be next to the
  6. ;; ``<repo>/.dir-locals.el`` in::
  7. ;;
  8. ;; ./local/py3
  9. ;;
  10. ;; In Emacs, some buffer locals are referencing the project environment:
  11. ;;
  12. ;; - prj-root --> <repo>/
  13. ;; - python-environment-directory --> <repo>/local
  14. ;; - python-environment-default-root-name --> py3
  15. ;; - python-shell-virtualenv-root --> <repo>/local/py3
  16. ;; When this variable is set with the path of the virtualenv to use,
  17. ;; `process-environment' and `exec-path' get proper values in order to run
  18. ;; shells inside the specified virtualenv, example::
  19. ;; (setq python-shell-virtualenv-root "/path/to/env/")
  20. ;;
  21. ;; To setup such an environment build target 'pyenv' or 'pyenvinstall'::
  22. ;;
  23. ;; $ make pyenvinstall
  24. ;;
  25. ;; Alternatively create the virtualenv, source it and install jedi + epc
  26. ;; (required by `emacs-jedi <https://tkf.github.io/emacs-jedi>`_)::
  27. ;;
  28. ;; $ python -m venv ./local/py3
  29. ;; ...
  30. ;; $ source ./local/py3/bin/activate
  31. ;; (py3)$ # now install into the activated 'py3' environment ..
  32. ;; (py3)$ pip install jedi epc
  33. ;; ...
  34. ;;
  35. ;; Here is what also I found useful to add to my .emacs::
  36. ;;
  37. ;; (global-set-key [f6] 'flycheck-mode)
  38. ;; (add-hook 'python-mode-hook 'my:python-mode-hook)
  39. ;;
  40. ;; (defun my:python-mode-hook ()
  41. ;; (add-to-list 'company-backends 'company-jedi)
  42. ;; (require 'jedi-core)
  43. ;; (jedi:setup)
  44. ;; (define-key python-mode-map (kbd "C-c C-d") 'jedi:show-doc)
  45. ;; (define-key python-mode-map (kbd "M-.") 'jedi:goto-definition)
  46. ;; (define-key python-mode-map (kbd "M-,") 'jedi:goto-definition-pop-marker)
  47. ;; )
  48. ;;
  49. ((nil
  50. . ((fill-column . 80)
  51. ))
  52. (python-mode
  53. . ((indent-tabs-mode . nil)
  54. ;; project root folder is where the `.dir-locals.el' is located
  55. (eval . (setq-local
  56. prj-root (locate-dominating-file default-directory ".dir-locals.el")))
  57. (eval . (setq-local
  58. python-environment-directory (expand-file-name "./local" prj-root)))
  59. ;; use 'py3' enviroment as default
  60. (eval . (setq-local
  61. python-environment-default-root-name "py3"))
  62. (eval . (setq-local
  63. python-shell-virtualenv-root
  64. (concat python-environment-directory
  65. "/"
  66. python-environment-default-root-name)))
  67. ;; python-shell-virtualenv-path is obsolete, use python-shell-virtualenv-root!
  68. ;; (eval . (setq-local
  69. ;; python-shell-virtualenv-path python-shell-virtualenv-root))
  70. (eval . (setq-local
  71. python-shell-interpreter
  72. (expand-file-name "bin/python" python-shell-virtualenv-root)))
  73. (eval . (setq-local
  74. python-environment-virtualenv
  75. (list (expand-file-name "bin/virtualenv" python-shell-virtualenv-root)
  76. ;;"--system-site-packages"
  77. "--quiet")))
  78. (eval . (setq-local
  79. pylint-command
  80. (expand-file-name "bin/pylint" python-shell-virtualenv-root)))
  81. ;; pylint will find the '.pylintrc' file next to the CWD
  82. ;; https://pylint.readthedocs.io/en/latest/user_guide/run.html#command-line-options
  83. (eval . (setq-local
  84. flycheck-pylintrc ".pylintrc"))
  85. ;; flycheck & other python stuff should use the local py3 environment
  86. (eval . (setq-local
  87. flycheck-python-pylint-executable python-shell-interpreter))
  88. ;; use 'M-x jedi:show-setup-info' and 'M-x epc:controller' to inspect jedi server
  89. ;; https://tkf.github.io/emacs-jedi/latest/#jedi:environment-root -- You
  90. ;; can specify a full path instead of a name (relative path). In that case,
  91. ;; python-environment-directory is ignored and Python virtual environment
  92. ;; is created at the specified path.
  93. (eval . (setq-local jedi:environment-root python-shell-virtualenv-root))
  94. ;; https://tkf.github.io/emacs-jedi/latest/#jedi:server-command
  95. (eval .(setq-local
  96. jedi:server-command
  97. (list python-shell-interpreter
  98. jedi:server-script)
  99. ))
  100. ;; jedi:environment-virtualenv --> see above 'python-environment-virtualenv'
  101. ;; is set buffer local! No need to setup jedi:environment-virtualenv:
  102. ;;
  103. ;; Virtualenv command to use. A list of string. If it is nil,
  104. ;; python-environment-virtualenv is used instead. You must set non-nil
  105. ;; value to jedi:environment-root in order to make this setting work.
  106. ;;
  107. ;; https://tkf.github.io/emacs-jedi/latest/#jedi:environment-virtualenv
  108. ;;
  109. ;; (eval . (setq-local
  110. ;; jedi:environment-virtualenv
  111. ;; (list (expand-file-name "bin/virtualenv" python-shell-virtualenv-root)
  112. ;; ;;"--python"
  113. ;; ;;"/usr/bin/python3.4"
  114. ;; )))
  115. ;; jedi:server-args
  116. )))