forked from python-mode/python-mode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpymode.vim
More file actions
166 lines (107 loc) · 3.67 KB
/
pymode.vim
File metadata and controls
166 lines (107 loc) · 3.67 KB
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
if pymode#Default('b:pymode', 1)
finish
endif
" Syntax highlight
if !pymode#Default('g:pymode_syntax', 1) || g:pymode_syntax
let python_highlight_all=1
endif
" Options {{{
" Python indent options
if !pymode#Default('g:pymode_options_indent', 1) || g:pymode_options_indent
setlocal cinwords=if,elif,else,for,while,try,except,finally,def,class
setlocal cindent
setlocal tabstop=4
setlocal softtabstop=4
setlocal shiftwidth=4
setlocal shiftround
setlocal smartindent
setlocal smarttab
setlocal expandtab
setlocal autoindent
endif
" Python other options
if !pymode#Default('g:pymode_options_other', 1) || g:pymode_options_other
setlocal complete+=t
setlocal formatoptions-=t
if v:version > 702 && !&relativenumber
setlocal number
endif
setlocal nowrap
setlocal textwidth=79
endif
" }}}
" Documentation {{{
if g:pymode_doc
" DESC: Set commands
command! -buffer -nargs=1 Pydoc call pymode#doc#Show("<args>")
" DESC: Set keys
exe "nnoremap <silent> <buffer> " g:pymode_doc_key ":call pymode#doc#Show(expand('<cword>'))<CR>"
exe "vnoremap <silent> <buffer> " g:pymode_doc_key ":<C-U>call pymode#doc#Show(@*)<CR>"
endif
" }}}
" Lint {{{
if g:pymode_lint
let b:qf_list = []
" DESC: Set commands
command! -buffer -nargs=0 PyLintToggle :call pymode#lint#Toggle()
command! -buffer -nargs=0 PyLintWindowToggle :call pymode#lint#ToggleWindow()
command! -buffer -nargs=0 PyLintCheckerToggle :call pymode#lint#ToggleChecker()
command! -buffer -nargs=0 PyLint :call pymode#lint#Check()
" DESC: Set autocommands
if g:pymode_lint_write
au BufWritePost <buffer> PyLint
endif
if g:pymode_lint_onfly
au InsertLeave <buffer> PyLint
endif
if g:pymode_lint_message
" DESC: Show message flag
let b:show_message = 0
" DESC: Errors dict
let b:errors = {}
au CursorHold <buffer> call pymode#lint#show_errormessage()
au CursorMoved <buffer> call pymode#lint#show_errormessage()
endif
endif
" }}}
" Rope {{{
if g:pymode_rope
" DESC: Set keys
exe "noremap <silent> <buffer> " . g:pymode_rope_short_prefix . "g :RopeGotoDefinition<CR>"
exe "noremap <silent> <buffer> " . g:pymode_rope_short_prefix . "d :RopeShowDoc<CR>"
exe "noremap <silent> <buffer> " . g:pymode_rope_short_prefix . "f :RopeFindOccurrences<CR>"
exe "noremap <silent> <buffer> " . g:pymode_rope_short_prefix . "m :emenu Rope . <TAB>"
inoremap <silent> <buffer> <S-TAB> <C-R>=RopeLuckyAssistInsertMode()<CR>
let s:prascm = g:pymode_rope_always_show_complete_menu ? "<C-P>" : ""
exe "inoremap <silent> <buffer> <Nul> <C-R>=RopeCodeAssistInsertMode()<CR>" . s:prascm
exe "inoremap <silent> <buffer> <C-space> <C-R>=RopeCodeAssistInsertMode()<CR>" . s:prascm
endif
" }}}
" Execution {{{
if g:pymode_run
" DESC: Set commands
command! -buffer -nargs=0 -range=% Pyrun call pymode#run#Run(<f-line1>, <f-line2>)
" DESC: Set keys
exe "nnoremap <silent> <buffer> " g:pymode_run_key ":Pyrun<CR>"
exe "vnoremap <silent> <buffer> " g:pymode_run_key ":Pyrun<CR>"
endif
" }}}
" Breakpoints {{{
if g:pymode_breakpoint
" DESC: Set keys
exe "nnoremap <silent> <buffer> " g:pymode_breakpoint_key ":call pymode#breakpoint#Set(line('.'))<CR>"
endif
" }}}
" Utils {{{
if g:pymode_utils_whitespaces
au BufWritePre <buffer> :call setline(1,map(getline(1,"$"),'substitute(v:val,"\\s\\+$","","")'))
endif
" }}}
" Folding {{{
if g:pymode_folding
setlocal foldmethod=expr
setlocal foldexpr=pymode#folding#expr(v:lnum)
setlocal foldtext=pymode#folding#text()
endif
" }}}
" vim: fdm=marker:fdl=0