Skip to content

Commit a9c5bb5

Browse files
committed
Refactor pymode.
1 parent d33704a commit a9c5bb5

File tree

12 files changed

+229
-190
lines changed

12 files changed

+229
-190
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
1-
" DESC: Set scriptname
2-
let g:scriptname = expand("<sfile>:t")
3-
41
" OPTION: g:pymode_breakpoint -- bool. Breakpoints enabled
52
call helpers#SafeVar("g:pymode_breakpoint", 1)
63

7-
" OPTION: g:pymode_breakpoint_key -- string. Key for set/unset breakpoint.
8-
call helpers#SafeVar("g:pymode_breakpoint_key", "<leader>b")
9-
104
" DESC: Disable script loading
11-
if helpers#SafeVar("b:breakpoint", 1) || g:pymode_breakpoint == 0
5+
if ! g:pymode_breakpoint
126
finish
137
endif
148

9+
" OPTION: g:pymode_breakpoint_key -- string. Key for set/unset breakpoint.
10+
call helpers#SafeVar("g:pymode_breakpoint_key", "<leader>b")
11+
1512
" DESC: Set or unset breakpoint
1613
" ARGS: lnum -- int, number of current line
17-
fun! <SID>:BreakPoint(lnum) "{{{
14+
fun! pymode_breakpoint#Set(lnum) "{{{
1815
let import = "import ipdb; ipdb.set_trace() ### XXX BREAKPOINT"
1916
let line = getline(a:lnum)
2017

@@ -30,6 +27,3 @@ fun! <SID>:BreakPoint(lnum) "{{{
3027
normal k
3128

3229
endfunction "}}}
33-
34-
" DESC: Set keys
35-
exe "nnoremap <silent> <buffer> " g:pymode_breakpoint_key ":call <SID>:BreakPoint(line('.'))<CR>"
Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,26 @@ let g:scriptname = expand("<sfile>:t")
44
" OPTION: g:pymode_doc -- bool. Show documentation enabled
55
call helpers#SafeVar("g:pymode_doc", 1)
66

7-
" OPTION: g:pymode_doc_key -- string. Key for show python documantation.
8-
call helpers#SafeVar("g:pymode_doc_key", "K")
9-
107
" DESC: Disable script loading
11-
if helpers#SafeVar("b:doc", 1) || g:pymode_doc == 0
8+
if g:pymode_doc == 0
129
finish
1310
endif
1411

1512
" DESC: Check pydoc installed
1613
if !helpers#CheckProgramm("pydoc")
14+
let g:pymode_doc = 0
1715
finish
1816
endif
1917

18+
" OPTION: g:pymode_doc_key -- string. Key for show python documantation.
19+
call helpers#SafeVar("g:pymode_doc_key", "K")
20+
2021
" DESC: Show python documentation
2122
" ARGS: word -- string, word for search
22-
fun! <SID>:PydocLoad(word) "{{{
23+
fun! pymode_doc#Show(word) "{{{
2324
if a:word == ''
2425
echoerr "no name/symbol under cursor!"
2526
return 0
2627
endif
2728
call helpers#ShowPreviewCmd(g:pydoc . " " . escape(a:word, " "))
2829
endfunction "}}}
29-
30-
" DESC: Set commands
31-
command! -buffer -nargs=+ Pydoc call <SID>:PydocLoad("<args>")
32-
33-
" DESC: Set keys
34-
exe "nnoremap <silent> <buffer> " g:pymode_doc_key ":call <SID>:PydocLoad(expand('<cword>'))<CR>"
Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,41 @@
1-
" DESC: Set scriptname
2-
let g:scriptname = expand("<sfile>:t")
3-
41
" OPTION: g:pymode_lint -- bool. Load pylint plugin
52
call helpers#SafeVar("g:pymode_lint", 1)
63

7-
" OPTION: g:pymode_lint_write -- bool. Check code every save.
8-
call helpers#SafeVar("g:pymode_lint_write", 1)
9-
10-
" OPTION: g:pymode_lint_cwindow -- bool. Auto open cwindow if errors find
11-
call helpers#SafeVar("g:pymode_lint_cwindow", 1)
12-
13-
" OPTION: g:pymode_lint_signs -- bool. Place error signs
14-
call helpers#SafeVar("g:pymode_lint_signs", 1)
15-
16-
" OPTION: g:pymode_lint_config -- str. Path to pylint config file
17-
call helpers#SafeVar("g:pymode_lint_config", string($HOME . "/.pylintrc"))
18-
194
" DESC: Disable script loading
20-
if helpers#SafeVar("b:lint", 1) || g:pymode_lint == 0
5+
if g:pymode_lint == 0
216
finish
227
endif
238

249
" DESC: Check python support
2510
if !has('python')
26-
echoerr s:scriptname . " required vim compiled with +python."
11+
echoerr expand("<sfile>:t") . " required vim compiled with +python."
12+
let g:pymode_lint = 0
2713
finish
2814
endif
2915

30-
" DESC: Set default pylint configuration
31-
if !filereadable(g:pymode_lint_config)
32-
let g:pymode_lint_config = expand("<sfile>:p:h:h:h") . "/.pylintrc"
33-
endif
16+
" OPTION: g:pymode_lint_write -- bool. Check code every save.
17+
call helpers#SafeVar("g:pymode_lint_write", 1)
3418

35-
" DESC: Set autocommands
36-
if g:pymode_lint_write
37-
au BufWritePost <buffer> call <SID>:PyLint()
38-
endif
19+
" OPTION: g:pymode_lint_cwindow -- bool. Auto open cwindow if errors find
20+
call helpers#SafeVar("g:pymode_lint_cwindow", 1)
21+
22+
" OPTION: g:pymode_lint_signs -- bool. Place error signs
23+
call helpers#SafeVar("g:pymode_lint_signs", 1)
3924

40-
" DESC: Set commands
41-
command! -buffer PyLintToggle :let g:pymode_lint = g:pymode_lint ? 0 : 1
42-
command! -buffer PyLint :call <SID>:PyLint()
25+
" OPTION: g:pymode_lint_config -- str. Path to pylint config file
26+
call helpers#SafeVar("g:pymode_lint_config", string($HOME . "/.pylintrc"))
4327

4428
" DESC: Signs definition
4529
sign define W text=WW texthl=Todo
4630
sign define C text=CC texthl=Comment
4731
sign define R text=RR texthl=Visual
4832
sign define E text=EE texthl=Error
4933

34+
" DESC: Set default pylint configuration
35+
if !filereadable(g:pymode_lint_config)
36+
let g:pymode_lint_config = expand("<sfile>:p:h:h:h") . "/.pylintrc"
37+
endif
38+
5039
python << EOF
5140
import os
5241
import StringIO
@@ -70,9 +59,8 @@ def check():
7059
vim.command('let pylint_output = "%s"' % pylint_output.replace('"', '\\"'))
7160
EOF
7261

73-
7462
" DESC: Check code
75-
function! <SID>:PyLint()
63+
function! pymode_lint#Lint()
7664

7765
if g:pymode_lint == 0 | return | endif
7866

after/plugin/pymode_rope.vim

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
" OPTION: g:pymode_rope -- bool. Load rope plugin
2+
call helpers#SafeVar("g:pymode_rope", 1)
3+
4+
" DESC: Disable script loading
5+
if g:pymode_rope == 0
6+
finish
7+
endif
8+
9+
" DESC: Check python support
10+
if !has('python')
11+
echoerr expand("<sfile>:t") . " required vim compiled with +python."
12+
let g:pymode_rope = 0
13+
finish
14+
endif
15+
16+
" OPTION: g:pymode_rope_auto_project -- bool. Auto open ropeproject
17+
call helpers#SafeVar("g:pymode_rope_auto_project", 1)
18+
19+
" OPTION: g:pymode_rope_enable_autoimport -- bool. Enable autoimport
20+
call helpers#SafeVar("g:pymode_rope_enable_autoimport", 1)
21+
22+
" OPTION: g:pymode_rope_autoimport_underlines -- bool.
23+
call helpers#SafeVar("g:pymode_rope_autoimport_underlineds", 0)
24+
25+
" OPTION: g:pymode_rope_codeassist_maxfiles -- bool.
26+
call helpers#SafeVar("g:pymode_rope_codeassist_maxfixes", 10)
27+
28+
" OPTION: g:pymode_rope_sorted_completions -- bool.
29+
call helpers#SafeVar("g:pymode_rope_sorted_completions", 1)
30+
31+
" OPTION: g:pymode_rope_extended_complete -- bool.
32+
call helpers#SafeVar("g:pymode_rope_extended_complete", 0)
33+
34+
" OPTION: g:pymode_rope_autoimport_modules -- array.
35+
call helpers#SafeVar("g:pymode_rope_autoimport_modules", ["os","shutil","datetime"])
36+
37+
" OPTION: g:pymode_rope_confirm_saving -- bool.
38+
call helpers#SafeVar("g:pymode_rope_confirm_saving", 1)
39+
40+
" OPTION: g:pymode_rope_global_prefix -- string.
41+
call helpers#SafeVar("g:pymode_rope_global_prefix", "<C-x>p")
42+
43+
" OPTION: g:pymode_rope_local_prefix -- string.
44+
call helpers#SafeVar("g:pymode_rope_local_prefix", "<C-c>r")
45+
46+
" OPTION: g:pymode_rope_vim_completion -- bool.
47+
call helpers#SafeVar("g:pymode_rope_vim_completion", 1)
48+
49+
" OPTION: g:pymode_rope_guess_project -- bool.
50+
call helpers#SafeVar("g:pymode_rope_guess_project", 1)
51+
52+
" OPTION: g:pymode_rope_goto_def_newwin -- bool.
53+
call helpers#SafeVar("g:pymode_rope_goto_def_newwin", 0)
54+
55+
" DESC: Init Rope
56+
py import ropevim
57+
58+
fun! RopeCodeAssistInsertMode() "{{{
59+
call RopeCodeAssist()
60+
return ""
61+
endfunction "}}}
62+
63+
fun! RopeLuckyAssistInsertMode() "{{{
64+
call RopeLuckyAssist()
65+
return ""
66+
endfunction "}}}
67+
68+
fun! RopeOmni(findstart, base) "{{{
69+
call RopeCodeAssist()
70+
endfunction "}}}
71+
72+
" Rope menu
73+
menu <silent> Rope.Autoimport :RopeAutoImport<CR>
74+
menu <silent> Rope.ChangeSignature :RopeChangeSignature<CR>
75+
menu <silent> Rope.CloseProject :RopeCloseProject<CR>
76+
menu <silent> Rope.GenerateAutoImportCache :RopeGenerateAutoimportCache<CR>
77+
menu <silent> Rope.ExtractVariable :RopeExtractVariable<CR>
78+
menu <silent> Rope.ExtractMethod :RopeExtractMethod<CR>
79+
menu <silent> Rope.Inline :RopeInline<CR>
80+
menu <silent> Rope.IntroduceFactory :RopeIntroduceFactory<CR>
81+
menu <silent> Rope.FindFile :RopeFindFile<CR>
82+
menu <silent> Rope.OpenProject :RopeOpenProject<CR>
83+
menu <silent> Rope.Move :RopeMove<CR>
84+
menu <silent> Rope.MoveCurrentModule :RopeMoveCurrentModule<CR>
85+
menu <silent> Rope.ModuleToPackage :RopeModuleToPackage<CR>
86+
menu <silent> Rope.Redo :RopeRedo<CR>
87+
menu <silent> Rope.Rename :RopeRename<CR>
88+
menu <silent> Rope.RenameCurrentModule :RopeRenameCurrentModule<CR>
89+
menu <silent> Rope.Restructure :RopeRestructure<CR>
90+
menu <silent> Rope.Undo :RopeUndo<CR>
91+
menu <silent> Rope.UseFunction :RopeUseFunction<CR>
Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,22 @@ let g:scriptname = expand("<sfile>:t")
44
" OPTION: g:pymode_doc -- bool. Show documentation enabled
55
call helpers#SafeVar("g:pymode_run", 1)
66

7-
" OPTION: g:pymode_doc_key -- string. Key for show python documantation.
8-
call helpers#SafeVar("g:pymode_run_key", "<leader>r")
9-
107
" DESC: Disable script loading
11-
if helpers#SafeVar("b:run", 1) || g:pymode_run == 0
8+
if g:pymode_run == 0
129
finish
1310
endif
1411

1512
" DESC: Check python
1613
if !helpers#CheckProgramm("python")
14+
let g:pymode_run = 0
1715
finish
1816
endif
1917

18+
" OPTION: g:pymode_doc_key -- string. Key for show python documantation.
19+
call helpers#SafeVar("g:pymode_run_key", "<leader>r")
20+
2021
" DESC: Save file if it modified and run python code
21-
fun! <SID>:RunPython() "{{{
22+
fun! pymode_run#Run() "{{{
2223
if &modifiable && &modified | write | endif
2324
call helpers#ShowPreviewCmd(g:python . " " . expand("%:p"))
2425
endfunction "}}}
25-
26-
" DESC: Set commands
27-
command! -buffer Pyrun call <SID>:RunPython()
28-
29-
" DESC: Set keys
30-
exe "nnoremap <silent> <buffer> " g:pymode_run_key ":call <SID>:RunPython()<CR>"

doc/ropevim.txt

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ file in the other window.
5151
*RopeCodeAssist*
5252
*:RopeCodeAssist*
5353
*:RopeLuckyAssist*
54-
*'ropevim_vim_completion'*
55-
*'ropevim_extended_complete'*
54+
*'pymode_rope_vim_completion'*
55+
*'pymode_rope_extended_complete'*
5656

5757
|:RopeCodeAssist| command (<M-/>) will let you select from a list
5858
of completions. |:RopeLuckyAssist| command (<M-?>) does not ask
@@ -61,7 +61,7 @@ anything; instead, it inserts the first proposal.
6161
You can tell ropevim to use vim's complete function in insert mode;
6262
Add: >
6363
64-
let ropevim_vim_completion=1
64+
let pymode_rope_vim_completion=1
6565
<
6666
to your '~/.vimrc' file.
6767

@@ -74,7 +74,7 @@ By default autocomplete feature will use plain list of proposed completion
7474
items. You can enable showing extended information about completion
7575
proposals by setting : >
7676
77-
let ropevim_extended_complete=1
77+
let pymode_rope_extended_complete=1
7878
<
7979
Completion menu list will show the proposed name itself, one letter which
8080
shows where this proposal came from (it can be "L" for locals, "G" for
@@ -96,10 +96,10 @@ modules. Rope maintains a cache of global names for each project. It
9696
updates the cache only when modules are changed; if you want to cache
9797
all your modules at once, use |:RopeGenerateAutoimportCache|. It
9898
will cache all of the modules inside the project plus those whose
99-
names are listed in |'ropevim_autoimport_modules'| list: >
99+
names are listed in |'pymode_rope_autoimport_modules'| list: >
100100
101101
" add the name of modules you want to autoimport
102-
let g:ropevim_autoimport_modules = ["os", "shutil"]
102+
let g:pymode_rope_autoimport_modules = ["os", "shutil"]
103103
<
104104
Now if you are in a buffer that contains: >
105105
@@ -221,34 +221,34 @@ restructuring can be: >
221221
8. Variables ~
222222
*RopeVariables*
223223

224-
*'ropevim_codeassist_maxfixes'* The maximum number of syntax errors
224+
*'pymode_rope_codeassist_maxfixes'* The maximum number of syntax errors
225225
to fix for code assists.
226226
The default value is `1`.
227227

228-
*'ropevim_local_prefix'* The prefix for ropevim refactorings.
228+
*'pymode_rope_local_prefix'* The prefix for ropevim refactorings.
229229
Defaults to `<C-c> r`.
230230

231-
*'ropevim_global_prefix'* The prefix for ropevim project commands
231+
*'pymode_rope_global_prefix'* The prefix for ropevim project commands
232232
Defaults to `<C-x> p`.
233233

234-
*'ropevim_enable_shortcuts'* Shows whether to bind ropevim shortcuts keys.
234+
*'pymode_rope_enable_shortcuts'* Shows whether to bind ropevim shortcuts keys.
235235
Defaults to `1`.
236236

237-
*'ropevim_guess_project'* If non-zero, ropevim tries to guess and
237+
*'pymode_rope_guess_project'* If non-zero, ropevim tries to guess and
238238
open the project that contains the file on which
239239
a ropevim command is performed when no project
240240
is already open.
241241

242-
*'ropevim_enable_autoimport'* Shows whether to enable autoimport.
242+
*'pymode_rope_enable_autoimport'* Shows whether to enable autoimport.
243243

244-
*'ropevim_autoimport_modules'* The name of modules whose global names should
244+
*'pymode_rope_autoimport_modules'* The name of modules whose global names should
245245
be cached. |:RopeGenerateAutoimportCache| reads
246246
this list and fills its cache.
247247

248-
*'ropevim_autoimport_underlineds'* If set, autoimport will cache names starting
248+
*'pymode_rope_autoimport_underlineds'* If set, autoimport will cache names starting
249249
with underlines, too.
250250

251-
*'ropevim_goto_def_newwin'* If set, ropevim will open a new buffer
251+
*'pymode_rope_goto_def_newwin'* If set, ropevim will open a new buffer
252252
for "go to definition" result if the definition
253253
found is located in another file. By default the
254254
file is open in the same buffer.
@@ -319,14 +319,11 @@ code-assist group. You can define your own shortcuts like this: >
319319
320320
<
321321

322-
Ropevim itself comes with a few shortcuts. These shortcuts will be
323-
used only when |'ropevim_enable_shortcuts'| is set.
324-
325322
================ ============================
326323
Key Command
327324
================ ============================
328-
M-/ |:RopeCodeAssist|
329-
M-? |:RopeLuckyAssist|
325+
<C-Space> |:RopeCodeAssist|
326+
<C-?> |:RopeLuckyAssist|
330327
<C-c> g |:RopeGotoDefinition|
331328
<C-c> d |:RopeShowDoc|
332329
<C-c> f |:RopeFindOccurrences|

ftplugin/python/options.vim

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

0 commit comments

Comments
 (0)