ADD pyenv mode

COM rearranged python config and documentation
ENH make ipython quieter
This commit is contained in:
ndwarshuis 2019-05-23 19:05:47 -04:00
parent 4ab9a1c098
commit c745ea8dc6
1 changed files with 32 additions and 8 deletions

View File

@ -734,14 +734,15 @@ Flycheck syntax checkers
(advice-add #'run-ess-r :around #'nd/ess-r-start-env) (advice-add #'run-ess-r :around #'nd/ess-r-start-env)
#+END_SRC #+END_SRC
*** Python *** Python
Flycheck syntax checkers to install (either globally or using =pip=) **** inferior shell
- flake8 I don't really use elpy, but it has really nice inferior process commands, so import but don't call =elpy-enable=.
- python-pylint
- python-black
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package elpy (use-package elpy
:straight t) :straight t)
#+END_SRC
**** anaconda and ipython
Anaconda (not related to the Python/R distribution?) is much lighter and easier than elpy. Also use ipython instead of the built-in shell. (Note this requires ipython to be installed externally).
#+BEGIN_SRC emacs-lisp
(defun nd/init-anaconda-company () (defun nd/init-anaconda-company ()
"Set the company backends for anaconda mode." "Set the company backends for anaconda mode."
(setq-local company-backends '(company-anaconda))) (setq-local company-backends '(company-anaconda)))
@ -753,12 +754,12 @@ Flycheck syntax checkers to install (either globally or using =pip=)
(python-mode . company-mode) (python-mode . company-mode)
(python-mode . nd/init-anaconda-company) (python-mode . nd/init-anaconda-company)
(python-mode . blacken-mode) (python-mode . blacken-mode)
(python-mode . pyenv-mode)
(inferior-python-mode . company-mode) (inferior-python-mode . company-mode)
(inferior-python-mode . nd/init-anaconda-company)) (inferior-python-mode . nd/init-anaconda-company))
:config (setq indent-tabs-mode nil :config (setq indent-tabs-mode nil
tab-width 4
python-shell-interpreter "ipython" python-shell-interpreter "ipython"
python-shell-interpreter-args "-i --simple-prompt")) python-shell-interpreter-args "-i --simple-prompt --quiet --no-banner"))
(use-package anaconda-mode (use-package anaconda-mode
:straight t :straight t
@ -767,10 +768,33 @@ Flycheck syntax checkers to install (either globally or using =pip=)
(use-package company-anaconda (use-package company-anaconda
:straight t :straight t
:after (python company anaconda)) :after (python company anaconda))
#+END_SRC
**** syntax checking
=Flycheck= has built in support for syntax checking and can be additionally enhanced by installing the following:
- flake8
- pylint
**** formatting
[[https://github.com/python/black][Black]] is a really nice syntax formatter. It must be externally installed to work.
#+BEGIN_SRC emacs-lisp
(use-package blacken (use-package blacken
:straight t) :straight t)
#+END_SRC #+END_SRC
**** pyenv
For isolation I use [[https://github.com/pyenv/pyenv][pyenv]] and [[https://github.com/pyenv/pyenv-virtualenv][pyenv-virtualenv]]. The only external addition needed to make this work is to add =${PYENV_ROOT}/shims= to PATH as well as adding a =.pythong-version= file in the project root specifying the desired version/environment.
Note this also requires all external packages to be installed in each environement (eg ipython, black, flake8, and pylint).
#+BEGIN_SRC emacs-lisp
(use-package pyenv-mode
:straight t
:after python
:init (-some--> (getenv "PYENV_ROOT")
(f-join it "versions")
(add-to-list 'exec-path it)))
;; resolve symlinks when setting the pyenv, otherwise we get some
;; strange errors when activating a symlinked env
(advice-add #'pyenv-mode-full-path :filter-return #'file-truename)
#+END_SRC
*** Ruby *** Ruby
#+BEGIN_SRC emacs-lisp #+BEGIN_SRC emacs-lisp
(use-package inf-ruby (use-package inf-ruby