Skip to content

Commit f1b6d7b

Browse files
committed
Convert to Markdown
1 parent 9258efa commit f1b6d7b

File tree

2 files changed

+106
-115
lines changed

2 files changed

+106
-115
lines changed

plugins/README.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# IDE Plugins
2+
3+
## Emacs
4+
5+
The `Emacs` plugin is maintained separately. Installation directions can be
6+
found here: https://github.com/paetzke/py-yapf.el
7+
8+
9+
## Vim
10+
11+
The `vim` plugin allows you to reformat a range of code. Copy `plugin` and
12+
`autoload` directories into your `~/.vim` or use `:packadd` in Vim 8. Or use
13+
a plugin manager like Plug or Vundle:
14+
15+
```vim
16+
" Plug
17+
Plug 'google/yapf', { 'rtp': 'plugins/vim', 'for': 'python' }
18+
19+
" Vundle
20+
Plugin 'google/yapf', { 'rtp': 'plugins/vim' }
21+
```
22+
23+
You can add key bindings in the `.vimrc` file:
24+
25+
```vim
26+
map <C-Y> :call yapf#YAPF()<cr>
27+
imap <C-Y> <c-o>:call yapf#YAPF()<cr>
28+
```
29+
30+
Alternatively, you can call the command `YAPF`. If you omit the range, it will
31+
reformat the whole buffer.
32+
33+
example:
34+
35+
```vim
36+
:YAPF " formats whole buffer
37+
:'<,'>YAPF " formats lines selected in visual mode
38+
```
39+
40+
41+
## Sublime Text
42+
43+
The `Sublime Text` plugin is also maintained separately. It is compatible with
44+
both Sublime Text 2 and 3.
45+
46+
The plugin can be easily installed by using *Sublime Package Control*. Check
47+
the project page of the plugin for more information: https://github.com/jason-kane/PyYapf
48+
49+
50+
## git Pre-Commit Hook
51+
52+
The `git` pre-commit hook automatically formats your Python files before they
53+
are committed to your local repository. Any changes `yapf` makes to the files
54+
will stay unstaged so that you can diff them manually.
55+
56+
To install, simply download the raw file and copy it into your git hooks
57+
directory:
58+
59+
```bash
60+
# From the root of your git project.
61+
$ curl -o pre-commit.sh https://raw.githubusercontent.com/google/yapf/main/plugins/pre-commit.sh
62+
$ chmod a+x pre-commit.sh
63+
$ mv pre-commit.sh .git/hooks/pre-commit
64+
```
65+
66+
67+
## Textmate 2
68+
69+
Plugin for `Textmate 2` requires `yapf` Python package installed on your
70+
system:
71+
72+
```bash
73+
$ pip install yapf
74+
```
75+
76+
Also, you will need to activate `Python` bundle from `Preferences > Bundles`.
77+
78+
Finally, create a `~/Library/Application Support/TextMate/Bundles/Python.tmbundle/Commands/YAPF.tmCommand`
79+
file with the following content:
80+
81+
```xml
82+
<?xml version="1.0" encoding="UTF-8"?>
83+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
84+
<plist version="1.0">
85+
<dict>
86+
<key>beforeRunningCommand</key>
87+
<string>saveActiveFile</string>
88+
<key>command</key>
89+
<string>#!/bin/bash
90+
91+
TPY=${TM_PYTHON:-python}
92+
93+
"$TPY" "/usr/local/bin/yapf" "$TM_FILEPATH"</string>
94+
<key>input</key>
95+
<string>document</string>
96+
<key>name</key>
97+
<string>YAPF</string>
98+
<key>scope</key>
99+
<string>source.python</string>
100+
<key>uuid</key>
101+
<string>297D5A82-2616-4950-9905-BD2D1C94D2D4</string>
102+
</dict>
103+
</plist>
104+
```
105+
106+
You will see a new menu item `Bundles > Python > YAPF`.

plugins/README.rst

Lines changed: 0 additions & 115 deletions
This file was deleted.

0 commit comments

Comments
 (0)