YAPF configuration edition and documentation
Rename `yapf-format-on-save` to `python-enable-yapf-format-on-save` to be more consistent with the other layer variables
This commit is contained in:
parent
5bbf2a84d6
commit
a4e47cfc6b
|
@ -10,6 +10,7 @@
|
|||
- [Install](#install)
|
||||
- [Layer](#layer)
|
||||
- [Anaconda dependencies](#anaconda-dependencies)
|
||||
- [Automatic buffer formatting on save](#automatic-buffer-formatting-on-save)
|
||||
- [Key Bindings](#key-bindings)
|
||||
- [Inferior REPL process](#inferior-repl-process)
|
||||
- [Running Python Script in shell](#running-python-script-in-shell)
|
||||
|
@ -37,6 +38,7 @@ Features:
|
|||
- Virtual Environment using [pyvenv][] and [pyenv][]
|
||||
- semantic mode is enabled
|
||||
- Django support via [pony-mode][]
|
||||
- PEP8 compliant formatting via [YAPF][]
|
||||
|
||||
## Install
|
||||
|
||||
|
@ -62,6 +64,16 @@ To fix this, install the `anaconda-mode` [dependencies][anaconda-deps] by hand:
|
|||
|
||||
Source: https://github.com/proofit404/anaconda-mode#issues
|
||||
|
||||
### Automatic buffer formatting on save
|
||||
|
||||
To enable automatic buffer formatting on save with [YAPF][] set the variable
|
||||
`python-enable-yapf-format-on-save` to `t`.
|
||||
|
||||
```elisp
|
||||
(setq-default dotspacemacs-configuration-layers '(
|
||||
(python :variables python-enable-yapf-format-on-save t)))
|
||||
```
|
||||
|
||||
## Key Bindings
|
||||
|
||||
### Inferior REPL process
|
||||
|
@ -132,6 +144,7 @@ Test commands (start with <kbd>m t</kbd> or <kbd>m T</kbd>):
|
|||
|
||||
Key Binding | Description
|
||||
----------------------|------------------------------------------------------------
|
||||
<kbd>SPC m =</kbd> | Reformat the buffer according to PEP8 using [YAPF][]
|
||||
<kbd>SPC m d b</kbd> | toggle a breakpoint
|
||||
<kbd>SPC m g g</kbd> | go to definition using `anaconda-mode-goto` (<kbd>C-o</kbd> to jump back)
|
||||
<kbd>SPC m h d</kbd> | look for documentation using `helm-pydoc`
|
||||
|
@ -212,3 +225,4 @@ Manage Django with <kbd>SPC m j m</kbd>.
|
|||
[nose.el]: https://github.com/syl20bnr/nose.el
|
||||
[pony-mode]: https://github.com/davidmiller/pony-mode
|
||||
[anaconda-deps]: https://github.com/proofit404/anaconda-mode/blob/master/requirements.txt
|
||||
[YAPF]: https://github.com/google/yapf
|
||||
|
|
|
@ -14,6 +14,9 @@
|
|||
|
||||
(spacemacs|defvar-company-backends python-mode)
|
||||
|
||||
(defvar python-enable-yapf-format-on-save nil
|
||||
"If non-nil, automatically format code with YAPF on save.")
|
||||
|
||||
;; Command prefixes
|
||||
|
||||
;; not supported for now
|
||||
|
@ -30,6 +33,3 @@
|
|||
;; ("mp" . "pyenv")))
|
||||
;; (mapc (lambda (x) (spacemacs/declare-prefix (car x) (cdr x)))
|
||||
;; python/key-binding-prefixes)
|
||||
|
||||
(defvar yapf-format-on-save nil
|
||||
"If non-nil, automatically format code with YAPF on save.")
|
||||
|
|
|
@ -11,9 +11,7 @@
|
|||
;;; License: GPLv3
|
||||
|
||||
;; Pre extensions are loaded *before* the packages
|
||||
(setq python-pre-extensions
|
||||
'(
|
||||
))
|
||||
(setq python-pre-extensions '())
|
||||
|
||||
;; Post extensions are loaded *after* the packages
|
||||
(setq python-post-extensions
|
||||
|
@ -72,9 +70,7 @@
|
|||
(defun python/init-py-yapf ()
|
||||
(use-package py-yapf
|
||||
:init
|
||||
(evil-leader/set-key-for-mode 'python-mode
|
||||
"m=" 'py-yapf-buffer)
|
||||
(evil-leader/set-key-for-mode 'python-mode "m=" 'py-yapf-buffer)
|
||||
:config
|
||||
(progn
|
||||
(if yapf-format-on-save
|
||||
(add-hook 'python-mode-hook 'py-yapf-enable-on-save)))))
|
||||
(if python-enable-yapf-format-on-save
|
||||
(add-hook 'python-mode-hook 'py-yapf-enable-on-save))))
|
||||
|
|
Loading…
Reference in a new issue