2019-11-28 19:08:44 +00:00
|
|
|
;;; .dir-locals.el
|
|
|
|
;;
|
2021-06-11 14:50:53 +00:00
|
|
|
;; Per-Directory Local Variables:
|
|
|
|
;; https://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.html
|
2019-11-28 19:08:44 +00:00
|
|
|
;;
|
2021-06-11 14:50:53 +00:00
|
|
|
;; .. hint::
|
2019-11-28 19:08:44 +00:00
|
|
|
;;
|
2021-06-11 14:50:53 +00:00
|
|
|
;; If you get ``*** EPC Error ***`` (even after a jedi:install-server) in
|
|
|
|
;; your emacs session, mostly you have jedi-mode enabled but the python
|
|
|
|
;; enviroment is missed. The python environment has to be next to the
|
|
|
|
;; ``<repo>/.dir-locals.el`` in::
|
|
|
|
;;
|
|
|
|
;; ./local/py3
|
|
|
|
;;
|
|
|
|
;; To setup such an environment, build target::
|
|
|
|
;;
|
|
|
|
;; $ make pyenv.install
|
|
|
|
;;
|
|
|
|
;; Some buffer locals are referencing the project environment:
|
2019-11-28 19:08:44 +00:00
|
|
|
;;
|
|
|
|
;; - prj-root --> <repo>/
|
|
|
|
;; - python-environment-directory --> <repo>/local
|
|
|
|
;; - python-environment-default-root-name --> py3
|
|
|
|
;; - python-shell-virtualenv-root --> <repo>/local/py3
|
|
|
|
;; When this variable is set with the path of the virtualenv to use,
|
|
|
|
;; `process-environment' and `exec-path' get proper values in order to run
|
|
|
|
;; shells inside the specified virtualenv, example::
|
|
|
|
;; (setq python-shell-virtualenv-root "/path/to/env/")
|
2021-06-11 14:50:53 +00:00
|
|
|
;; - python-shell-interpreter --> <repo>/local/py3/bin/python
|
2019-11-28 19:08:44 +00:00
|
|
|
;;
|
2021-06-11 14:50:53 +00:00
|
|
|
;; Jedi, flycheck & other python stuff should use the 'python-shell-interpreter'
|
|
|
|
;; from the local py3 environment.
|
2019-11-28 19:08:44 +00:00
|
|
|
;;
|
2021-06-11 14:50:53 +00:00
|
|
|
;; Other useful jedi stuff you might add to your ~/.emacs::
|
2019-11-29 12:15:15 +00:00
|
|
|
;;
|
|
|
|
;; (global-set-key [f6] 'flycheck-mode)
|
|
|
|
;; (add-hook 'python-mode-hook 'my:python-mode-hook)
|
|
|
|
;;
|
|
|
|
;; (defun my:python-mode-hook ()
|
|
|
|
;; (add-to-list 'company-backends 'company-jedi)
|
|
|
|
;; (require 'jedi-core)
|
|
|
|
;; (jedi:setup)
|
|
|
|
;; (define-key python-mode-map (kbd "C-c C-d") 'jedi:show-doc)
|
|
|
|
;; (define-key python-mode-map (kbd "M-.") 'jedi:goto-definition)
|
|
|
|
;; (define-key python-mode-map (kbd "M-,") 'jedi:goto-definition-pop-marker)
|
|
|
|
;; )
|
2019-11-28 19:08:44 +00:00
|
|
|
|
|
|
|
((nil
|
|
|
|
. ((fill-column . 80)
|
2021-05-17 18:13:16 +00:00
|
|
|
(indent-tabs-mode . nil)
|
2021-06-11 14:50:53 +00:00
|
|
|
(eval . (progn
|
|
|
|
|
|
|
|
;; project root folder is where the `.dir-locals.el' is located
|
|
|
|
(setq-local prj-root
|
|
|
|
(locate-dominating-file default-directory ".dir-locals.el"))
|
|
|
|
|
|
|
|
(setq-local python-environment-directory
|
|
|
|
(expand-file-name "./local" prj-root))
|
|
|
|
|
|
|
|
;; use 'py3' enviroment as default
|
|
|
|
(setq-local python-environment-default-root-name
|
|
|
|
"py3")
|
2021-06-05 15:42:06 +00:00
|
|
|
|
2021-06-11 14:50:53 +00:00
|
|
|
(setq-local python-shell-virtualenv-root
|
|
|
|
(expand-file-name
|
|
|
|
python-environment-default-root-name python-environment-directory))
|
|
|
|
|
|
|
|
(setq-local python-shell-interpreter
|
|
|
|
(expand-file-name
|
|
|
|
"bin/python" python-shell-virtualenv-root))))))
|
2021-06-05 15:42:06 +00:00
|
|
|
(makefile-gmake-mode
|
2021-06-11 14:50:53 +00:00
|
|
|
. ((indent-tabs-mode . t)))
|
2021-06-05 15:42:06 +00:00
|
|
|
|
|
|
|
(yaml-mode
|
2021-06-11 14:50:53 +00:00
|
|
|
. ((eval . (progn
|
|
|
|
|
|
|
|
;; flycheck should use the local py3 environment
|
|
|
|
(setq-local flycheck-yaml-yamllint-executable
|
|
|
|
(expand-file-name "bin/yamllint" python-shell-virtualenv-root))
|
|
|
|
|
|
|
|
(setq-local flycheck-yamllintrc
|
|
|
|
(expand-file-name ".yamllint.yml" prj-root))
|
|
|
|
|
|
|
|
(flycheck-checker . yaml-yamllint)))))
|
2021-06-05 15:42:06 +00:00
|
|
|
|
2021-06-22 15:46:46 +00:00
|
|
|
(json-mode
|
|
|
|
. ((eval . (progn
|
|
|
|
(setq-local js-indent-level 2)
|
|
|
|
(flycheck-checker . json-python-json)))))
|
|
|
|
|
2021-06-05 15:42:06 +00:00
|
|
|
(python-mode
|
2021-06-11 14:50:53 +00:00
|
|
|
. ((eval . (progn
|
|
|
|
|
|
|
|
(setq-local python-environment-virtualenv
|
|
|
|
(list (expand-file-name "bin/virtualenv" python-shell-virtualenv-root)
|
|
|
|
;;"--system-site-packages"
|
|
|
|
"--quiet"))
|
|
|
|
|
|
|
|
(setq-local pylint-command
|
|
|
|
(expand-file-name "bin/pylint" python-shell-virtualenv-root))
|
|
|
|
|
|
|
|
;; pylint will find the '.pylintrc' file next to the CWD
|
|
|
|
;; https://pylint.readthedocs.io/en/latest/user_guide/run.html#command-line-options
|
|
|
|
(setq-local flycheck-pylintrc
|
|
|
|
".pylintrc")
|
|
|
|
|
|
|
|
;; flycheck & other python stuff should use the local py3 environment
|
|
|
|
(setq-local flycheck-python-pylint-executable
|
|
|
|
python-shell-interpreter)
|
|
|
|
|
|
|
|
;; use 'M-x jedi:show-setup-info' and 'M-x epc:controller' to inspect jedi server
|
|
|
|
;; https://tkf.github.io/emacs-jedi/latest/#jedi:environment-root -- You
|
|
|
|
;; can specify a full path instead of a name (relative path). In that case,
|
|
|
|
;; python-environment-directory is ignored and Python virtual environment
|
|
|
|
;; is created at the specified path.
|
|
|
|
(setq-local jedi:environment-root
|
|
|
|
python-shell-virtualenv-root)
|
|
|
|
|
|
|
|
;; https://tkf.github.io/emacs-jedi/latest/#jedi:server-command
|
|
|
|
(setq-local jedi:server-command
|
|
|
|
(list python-shell-interpreter
|
|
|
|
jedi:server-script))
|
|
|
|
|
|
|
|
;; jedi:environment-virtualenv --> see above 'python-environment-virtualenv'
|
|
|
|
;; is set buffer local! No need to setup jedi:environment-virtualenv:
|
|
|
|
;;
|
|
|
|
;; Virtualenv command to use. A list of string. If it is nil,
|
|
|
|
;; python-environment-virtualenv is used instead. You must set non-nil
|
|
|
|
;; value to jedi:environment-root in order to make this setting work.
|
|
|
|
;;
|
|
|
|
;; https://tkf.github.io/emacs-jedi/latest/#jedi:environment-virtualenv
|
|
|
|
;;
|
|
|
|
;; (setq-local jedi:environment-virtualenv
|
|
|
|
;; (list (expand-file-name "bin/virtualenv" python-shell-virtualenv-root)
|
|
|
|
;; "--python"
|
|
|
|
;; "/usr/bin/python3.4"
|
|
|
|
;; ))
|
|
|
|
))))
|
|
|
|
)
|