on engine-data help sign in
searx/.dir-locals.el
133 lines 5.0 kB history raw
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;;
50((nil
51 . ((fill-column . 80)
52 ))
53 (python-mode
54 . ((indent-tabs-mode . nil)
56 ;; project root folder is where the `.dir-locals.el' is located
57 (eval . (setq-local
58 prj-root (locate-dominating-file default-directory ".dir-locals.el")))
60 (eval . (setq-local
61 python-environment-directory (expand-file-name "./local" prj-root)))
63 ;; use 'py3' enviroment as default
64 (eval . (setq-local
65 python-environment-default-root-name "py3"))
67 (eval . (setq-local
68 python-shell-virtualenv-root
69 (concat python-environment-directory
70 "/"
71 python-environment-default-root-name)))
73 ;; python-shell-virtualenv-path is obsolete, use python-shell-virtualenv-root!
74 ;; (eval . (setq-local
75 ;; python-shell-virtualenv-path python-shell-virtualenv-root))
77 (eval . (setq-local
78 python-shell-interpreter
79 (expand-file-name "bin/python" python-shell-virtualenv-root)))
81 (eval . (setq-local
82 python-environment-virtualenv
83 (list (expand-file-name "bin/virtualenv" python-shell-virtualenv-root)
84 ;;"--system-site-packages"
85 "--quiet")))
87 (eval . (setq-local
88 pylint-command
89 (expand-file-name "bin/pylint" python-shell-virtualenv-root)))
91 ;; pylint will find the '.pylintrc' file next to the CWD
92 ;; https://pylint.readthedocs.io/en/latest/user_guide/run.html#command-line-options
93 (eval . (setq-local
94 flycheck-pylintrc ".pylintrc"))
96 ;; flycheck & other python stuff should use the local py3 environment
97 (eval . (setq-local
98 flycheck-python-pylint-executable python-shell-interpreter))
100 ;; use 'M-x jedi:show-setup-info' and 'M-x epc:controller' to inspect jedi server
102 ;; https://tkf.github.io/emacs-jedi/latest/#jedi:environment-root -- You
103 ;; can specify a full path instead of a name (relative path). In that case,
104 ;; python-environment-directory is ignored and Python virtual environment
105 ;; is created at the specified path.
106 (eval . (setq-local jedi:environment-root python-shell-virtualenv-root))
108 ;; https://tkf.github.io/emacs-jedi/latest/#jedi:server-command
109 (eval .(setq-local
110 jedi:server-command
111 (list python-shell-interpreter
112 jedi:server-script)
113 ))
115 ;; jedi:environment-virtualenv --> see above 'python-environment-virtualenv'
116 ;; is set buffer local! No need to setup jedi:environment-virtualenv:
117 ;;
118 ;; Virtualenv command to use. A list of string. If it is nil,
119 ;; python-environment-virtualenv is used instead. You must set non-nil
120 ;; value to jedi:environment-root in order to make this setting work.
121 ;;
122 ;; https://tkf.github.io/emacs-jedi/latest/#jedi:environment-virtualenv
123 ;;
124 ;; (eval . (setq-local
125 ;; jedi:environment-virtualenv
126 ;; (list (expand-file-name "bin/virtualenv" python-shell-virtualenv-root)
127 ;; ;;"--python"
128 ;; ;;"/usr/bin/python3.4"
129 ;; )))
131 ;; jedi:server-args
133 )))