Merge pull request #143 from return42/emacs

[emacs] clean up .dir-locals.el file
dependabot/pip/master/sphinx-6.1.3
Markus Heiser 3 years ago committed by GitHub
commit 7a436a5060
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,13 +1,22 @@
;;; .dir-locals.el ;;; .dir-locals.el
;; ;;
;; If you get ``*** EPC Error ***`` (even after a jedi:install-server) in your ;; Per-Directory Local Variables:
;; emacs session, mostly you have jedi-mode enabled but the python enviroment is ;; https://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.html
;; missed. The python environment has to be next to the
;; ``<repo>/.dir-locals.el`` in::
;; ;;
;; ./local/py3 ;; .. hint::
;; ;;
;; In Emacs, some buffer locals are referencing the project environment: ;; 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:
;; ;;
;; - prj-root --> <repo>/ ;; - prj-root --> <repo>/
;; - python-environment-directory --> <repo>/local ;; - python-environment-directory --> <repo>/local
@ -17,22 +26,12 @@
;; `process-environment' and `exec-path' get proper values in order to run ;; `process-environment' and `exec-path' get proper values in order to run
;; shells inside the specified virtualenv, example:: ;; shells inside the specified virtualenv, example::
;; (setq python-shell-virtualenv-root "/path/to/env/") ;; (setq python-shell-virtualenv-root "/path/to/env/")
;; - python-shell-interpreter --> <repo>/local/py3/bin/python
;; ;;
;; To setup such an environment build target 'pyenv' or 'pyenvinstall':: ;; Jedi, flycheck & other python stuff should use the 'python-shell-interpreter'
;; ;; from the local py3 environment.
;; $ make pyenvinstall
;;
;; Alternatively create the virtualenv, source it and install jedi + epc
;; (required by `emacs-jedi <https://tkf.github.io/emacs-jedi>`_)::
;; ;;
;; $ python -m venv ./local/py3 ;; Other useful jedi stuff you might add to your ~/.emacs::
;; ...
;; $ source ./local/py3/bin/activate
;; (py3)$ # now install into the activated 'py3' environment ..
;; (py3)$ pip install jedi epc
;; ...
;;
;; Here is what also I found useful to add to my .emacs::
;; ;;
;; (global-set-key [f6] 'flycheck-mode) ;; (global-set-key [f6] 'flycheck-mode)
;; (add-hook 'python-mode-hook 'my:python-mode-hook) ;; (add-hook 'python-mode-hook 'my:python-mode-hook)
@ -45,97 +44,91 @@
;; (define-key python-mode-map (kbd "M-.") 'jedi:goto-definition) ;; (define-key python-mode-map (kbd "M-.") 'jedi:goto-definition)
;; (define-key python-mode-map (kbd "M-,") 'jedi:goto-definition-pop-marker) ;; (define-key python-mode-map (kbd "M-,") 'jedi:goto-definition-pop-marker)
;; ) ;; )
;;
((nil ((nil
. ((fill-column . 80) . ((fill-column . 80)
(indent-tabs-mode . nil) (indent-tabs-mode . nil)
;; project root folder is where the `.dir-locals.el' is located (eval . (progn
(eval . (setq-local
prj-root (locate-dominating-file default-directory ".dir-locals.el"))) ;; project root folder is where the `.dir-locals.el' is located
(eval . (setq-local (setq-local prj-root
python-environment-directory (expand-file-name "./local" prj-root))) (locate-dominating-file default-directory ".dir-locals.el"))
;; use 'py3' enviroment as default
(eval . (setq-local (setq-local python-environment-directory
python-environment-default-root-name "py3")) (expand-file-name "./local" prj-root))
(eval . (setq-local
python-shell-virtualenv-root ;; use 'py3' enviroment as default
(expand-file-name python-environment-default-root-name python-environment-directory) (setq-local python-environment-default-root-name
)) "py3")
(eval . (setq-local
python-shell-interpreter
(expand-file-name "bin/python" python-shell-virtualenv-root)))
))
(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))))))
(makefile-gmake-mode (makefile-gmake-mode
. ((indent-tabs-mode . t) . ((indent-tabs-mode . t)))
))
(yaml-mode (yaml-mode
. ( . ((eval . (progn
;; flycheck should use the local py3 environment
(eval . (setq-local ;; flycheck should use the local py3 environment
flycheck-yaml-yamllint-executable (setq-local flycheck-yaml-yamllint-executable
(expand-file-name "bin/yamllint" python-shell-virtualenv-root))) (expand-file-name "bin/yamllint" python-shell-virtualenv-root))
(eval . (setq-local
flycheck-yamllintrc (setq-local flycheck-yamllintrc
(expand-file-name ".yamllint.yml" prj-root))) (expand-file-name ".yamllint.yml" prj-root))
(flycheck-checker . yaml-yamllint)
)) (flycheck-checker . yaml-yamllint)))))
(python-mode (python-mode
. ((indent-tabs-mode . nil) . ((eval . (progn
(eval . (setq-local (setq-local python-environment-virtualenv
python-environment-virtualenv (list (expand-file-name "bin/virtualenv" python-shell-virtualenv-root)
(list (expand-file-name "bin/virtualenv" python-shell-virtualenv-root) ;;"--system-site-packages"
;;"--system-site-packages" "--quiet"))
"--quiet")))
(setq-local pylint-command
(eval . (setq-local (expand-file-name "bin/pylint" python-shell-virtualenv-root))
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
;; pylint will find the '.pylintrc' file next to the CWD (setq-local flycheck-pylintrc
;; https://pylint.readthedocs.io/en/latest/user_guide/run.html#command-line-options ".pylintrc")
(eval . (setq-local
flycheck-pylintrc ".pylintrc")) ;; flycheck & other python stuff should use the local py3 environment
(setq-local flycheck-python-pylint-executable
;; flycheck & other python stuff should use the local py3 environment python-shell-interpreter)
(eval . (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
;; use 'M-x jedi:show-setup-info' and 'M-x epc:controller' to inspect jedi server ;; can specify a full path instead of a name (relative path). In that case,
;; python-environment-directory is ignored and Python virtual environment
;; https://tkf.github.io/emacs-jedi/latest/#jedi:environment-root -- You ;; is created at the specified path.
;; can specify a full path instead of a name (relative path). In that case, (setq-local jedi:environment-root
;; python-environment-directory is ignored and Python virtual environment python-shell-virtualenv-root)
;; is created at the specified path.
(eval . (setq-local jedi:environment-root python-shell-virtualenv-root)) ;; https://tkf.github.io/emacs-jedi/latest/#jedi:server-command
(setq-local jedi:server-command
;; https://tkf.github.io/emacs-jedi/latest/#jedi:server-command (list python-shell-interpreter
(eval .(setq-local jedi:server-script))
jedi:server-command
(list python-shell-interpreter ;; jedi:environment-virtualenv --> see above 'python-environment-virtualenv'
jedi:server-script) ;; is set buffer local! No need to setup jedi:environment-virtualenv:
)) ;;
;; Virtualenv command to use. A list of string. If it is nil,
;; jedi:environment-virtualenv --> see above 'python-environment-virtualenv' ;; python-environment-virtualenv is used instead. You must set non-nil
;; is set buffer local! No need to setup jedi:environment-virtualenv: ;; value to jedi:environment-root in order to make this setting work.
;; ;;
;; Virtualenv command to use. A list of string. If it is nil, ;; https://tkf.github.io/emacs-jedi/latest/#jedi:environment-virtualenv
;; python-environment-virtualenv is used instead. You must set non-nil ;;
;; value to jedi:environment-root in order to make this setting work. ;; (setq-local jedi:environment-virtualenv
;; ;; (list (expand-file-name "bin/virtualenv" python-shell-virtualenv-root)
;; https://tkf.github.io/emacs-jedi/latest/#jedi:environment-virtualenv ;; "--python"
;; ;; "/usr/bin/python3.4"
;; (eval . (setq-local ;; ))
;; jedi:environment-virtualenv ))))
;; (list (expand-file-name "bin/virtualenv" python-shell-virtualenv-root) )
;; ;;"--python"
;; ;;"/usr/bin/python3.4"
;; )))
;; jedi:server-args
)))

Loading…
Cancel
Save