Support autoimport keywords in completion · leon-github/python-mode@886d08b · GitHub
Skip to content

Commit 886d08b

Browse files
committed
Support autoimport keywords in completion
1 parent 16c0a71 commit 886d08b

5 files changed

Lines changed: 131 additions & 56 deletions

File tree

after/ftplugin/python.vim

Lines changed: 2 additions & 2 deletions

autoload/pymode/rope.vim

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,15 @@ fun! pymode#rope#completions(findstart, base)
77
PymodePython rope.completions()
88
endfunction
99

10-
fun! pymode#rope#complete()
10+
fun! pymode#rope#complete(dot)
1111
if pumvisible()
1212
return "\<C-n>"
1313
end
14-
PymodePython rope.complete()
14+
if a:dot
15+
PymodePython rope.complete(True)
16+
else
17+
PymodePython rope.complete()
18+
end
1519
return pumvisible() ? "\<C-p>\<Down>" : ""
1620
endfunction
1721

@@ -26,7 +30,7 @@ fun! pymode#rope#complete_on_dot() "{{{
2630
endif
2731
endfor
2832
endfor
29-
return pymode#rope#complete()
33+
return pymode#rope#complete(1)
3034
endfunction "}}}
3135

3236
fun! pymode#rope#goto_definition()
@@ -121,6 +125,13 @@ fun! pymode#rope#inline() "{{{
121125
PymodePython rope.InlineRefactoring().run()
122126
endfunction "}}}
123127

128+
fun! pymode#rope#move() "{{{
129+
if !pymode#save()
130+
return 0
131+
endif
132+
PymodePython rope.MoveRefactoring().run()
133+
endfunction "}}}
134+
124135
fun! pymode#rope#use_function() "{{{
125136
if !pymode#save()
126137
return 0

ftplugin/python/pymode.vim

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ if g:pymode_lint
7676
endif
7777

7878
if g:pymode_lint_async
79-
let &l:updatetime = g:pymode_lint_async_updatetime
80-
au! pymode BufEnter <buffer> call pymode#lint#start()
81-
au! pymode BufLeave <buffer> call pymode#lint#stop()
79+
" let &l:updatetime = g:pymode_lint_async_updatetime
80+
" au! pymode BufEnter <buffer> call pymode#lint#start()
81+
" au! pymode BufLeave <buffer> call pymode#lint#stop()
8282
end
8383

8484
endif
@@ -131,6 +131,10 @@ if g:pymode_rope
131131
exe "noremap <silent> <buffer> " . g:pymode_rope_inline_bind . " :call pymode#rope#inline()<CR>"
132132
end
133133

134+
if g:pymode_rope_move_bind != ""
135+
exe "noremap <silent> <buffer> " . g:pymode_rope_move_bind . " :call pymode#rope#move()<CR>"
136+
end
137+
134138
if g:pymode_rope_use_function_bind != ""
135139
exe "noremap <silent> <buffer> " . g:pymode_rope_use_function_bind . " :call pymode#rope#use_function()<CR>"
136140
end

plugin/pymode.vim

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,12 @@ call pymode#default('g:pymode_rope', 1)
170170
" Enable Rope completion
171171
call pymode#default('g:pymode_rope_completion', 1)
172172

173+
" Complete keywords from not imported modules (could make completion slower)
174+
call pymode#default('g:pymode_rope_autoimport', 1)
175+
176+
" Autoimported modules
177+
call pymode#default('g:pymode_rope_autoimport_modules', ['os', 'shutil', 'datetime'])
178+
173179
" Automatic completion on dot
174180
call pymode#default('g:pymode_rope_complete_on_dot', 1)
175181

@@ -209,6 +215,9 @@ call pymode#default('g:pymode_rope_extract_variable_bind', '<C-c>rl')
209215
" Inline refactoring
210216
call pymode#default('g:pymode_rope_inline_bind', '<C-c>ri')
211217

218+
" Move refactoring
219+
call pymode#default('g:pymode_rope_move_bind', '<C-c>rv')
220+
212221
" Tries to find the places in which a function can be used and changes the
213222
" code to call it instead
214223
call pymode#default('g:pymode_rope_use_function_bind', '<C-c>ru')

pymode/rope.py

Lines changed: 99 additions & 48 deletions

0 commit comments

Comments
 (0)