-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTODO
107 lines (86 loc) · 3.11 KB
/
TODO
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
* Wrap import statement when it doesn't fit on a single line.
* Don't include hidden modules in import directives. For example, use
from zope.component import getUtility
instead of
from zope.component._api import getUtility
Here are some configs that look interesting but need to be tested and
documented further.
" Needs work. -EDG
" `gf` jumps to the filename under the cursor. Point at an import statement
" and jump to it!
"""python << EOF
"""import os
"""import sys
"""import vim
"""
"""cwd = os.getcwd()
"""while True:
""" site_dir = os.path.join(cwd, 'parts/scripts')
""" site_file = os.path.join(site_dir, 'site.py')
""" if os.path.isfile(site_file):
""" sys.path[0:0] = site_dir
""" vim.command('echo "parts/scripts/site.py FOUND"')
""" vim.command('echo "before length: %d"' % len(sys.path))
""" import site
""" vim.command('echo "after length: %d"' % len(sys.path))
""" break
""" if site_dir == os.path.dirname(site_dir):
""" vim.command('echo "parts/scripts/site.py not found"')
""" break
""" site_dir = os.path.dirname(site_dir)
"""for p in sys.path:
""" if os.path.isdir(p):
""" vim.command('echo %r' % p)
""" vim.command(r"set path+=%s" % (p.replace(" ", r"\ ")))
"""EOF
" Generate tags with: ctags -R -f ~/.vim/tags/python24.ctags /usr/lib/python2.4/
" ctrl-] to go to the tag under the cursor, ctrl-T to go back.
set tags+=$HOME/.vim/tags/python24.ctags
" Use :make to see syntax errors. (:cn and :cp to move around, :dist to see
" all errors)
set makeprg=python\ -c\ \"import\ py_compile,sys;\ sys.stderr=sys.stdout;\ py_compile.compile(r'%')\"
set efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%m
" Execute a selection of code (very cool!)
" Use VISUAL to select a range and then hit ctrl-h to execute it.
python << EOL
import vim
def EvaluateCurrentRange():
eval(compile('\n'.join(vim.current.range),'','exec'),globals())
EOL
map <C-h> :py EvaluateCurrentRange()
" Use F7/Shift-F7 to add/remove a breakpoint (pdb.set_trace)
" Totally cool.
python << EOF
def SetBreakpoint():
import re
nLine = int( vim.eval( 'line(".")'))
strLine = vim.current.line
strWhite = re.search( '^(\s*)', strLine).group(1)
vim.current.buffer.append(
"%(space)spdb.set_trace() %(mark)s Breakpoint %(mark)s" %
{'space':strWhite, 'mark': '#' * 30}, nLine - 1)
for strLine in vim.current.buffer:
if strLine == "import pdb":
break
else:
vim.current.buffer.append( 'import pdb', 0)
vim.command( 'normal j1')
vim.command( 'map <f7> :py SetBreakpoint()<cr>')
def RemoveBreakpoints():
import re
nCurrentLine = int( vim.eval( 'line(".")'))
nLines = []
nLine = 1
for strLine in vim.current.buffer:
if strLine == "import pdb" or strLine.lstrip()[:15] == "pdb.set_trace()":
nLines.append( nLine)
nLine += 1
nLines.reverse()
for nLine in nLines:
vim.command( "normal %dG" % nLine)
vim.command( "normal dd")
if nLine < nCurrentLine:
nCurrentLine -= 1
vim.command( "normal %dG" % nCurrentLine)
vim.command( "map <s-f7> :py RemoveBreakpoints()<cr>")
EOF