if !g:pymode || pymode#default('b:pymode', 1)
finish
endif
let b:pymode_modified = &modified
" Init paths
if !pymode#default('g:pymode_init', 1)
call pymode#init(expand(':p:h:h:h'), g:pymode_paths)
call pymode#virtualenv#init()
call pymode#breakpoint#init()
PymodePython from pymode.utils import patch_paths
PymodePython patch_paths()
endif
command! -buffer -nargs=1 PymodeVirtualenv call pymode#virtualenv#activate()
" Setup events for pymode
au! pymode BufWritePre call pymode#buffer_pre_write()
au! pymode BufWritePost call pymode#buffer_post_write()
" Run python code
if g:pymode_run
command! -buffer -nargs=0 -range=% PymodeRun call pymode#run#code_run(, )
exe "nnoremap " g:pymode_run_bind ":PymodeRun"
exe "vnoremap " g:pymode_run_bind ":PymodeRun"
endif
" Add/remove breakpoints
if g:pymode_breakpoint
exe "nnoremap " g:pymode_breakpoint_bind ":call pymode#breakpoint#operate(line('.'))"
endif
" Python folding
if g:pymode_folding
setlocal foldmethod=expr
setlocal foldexpr=pymode#folding#expr(v:lnum)
setlocal foldtext=pymode#folding#text()
endif
" Remove unused whitespaces
if g:pymode_trim_whitespaces
au BufWritePre call pymode#trim_whitespaces()
endif
" Custom options
if g:pymode_options
setlocal complete+=t
setlocal formatoptions-=t
if v:version > 702 && !&relativenumber
setlocal number
endif
setlocal nowrap
exe "setlocal textwidth=" . g:pymode_options_max_line_length
if g:pymode_options_colorcolumn && exists('+colorcolumn')
setlocal colorcolumn=+1
endif
setlocal commentstring=#%s
setlocal define=^\s*\\(def\\\\|class\\)
endif
if g:pymode_lint
command! -buffer -nargs=0 PymodeLintAuto :call pymode#lint#auto()
command! -buffer -nargs=0 PymodeLintToggle :call pymode#lint#toggle()
command! -buffer -nargs=0 PymodeLint :call pymode#lint#check()
if v:version > 703 || (v:version == 703 && has('patch544'))
au! QuitPre call pymode#quit()
else
au! pymode BufWinLeave * silent! lclose
endif
let b:pymode_error_line = -1
if g:pymode_lint_on_fly
au! pymode InsertLeave PymodeLint
endif
if g:pymode_lint_message
au! pymode CursorMoved
au! pymode CursorMoved call pymode#lint#show_errormessage()
endif
" Disabled for current release
if g:pymode_lint_async
" let &l:updatetime = g:pymode_lint_async_updatetime
" au! BufEnter call pymode#lint#start()
" au! BufLeave call pymode#lint#stop()
end
endif
" Show python documentation
if g:pymode_doc
" Set commands
command! -buffer -nargs=1 PymodeDoc call pymode#doc#show("")
" Set keys
exe "nnoremap " g:pymode_doc_bind ":call pymode#doc#find()"
exe "vnoremap " g:pymode_doc_bind ":call pymode#doc#show(@*)"
end
" Rope support
if g:pymode_rope
if g:pymode_rope_goto_definition_bind != ""
exe "noremap " . g:pymode_rope_goto_definition_bind . " :call pymode#rope#goto_definition()"
endif
if g:pymode_rope_show_doc_bind != ""
exe "noremap " . g:pymode_rope_show_doc_bind . " :call pymode#rope#show_doc()"
end
if g:pymode_rope_find_it_bind != ""
exe "noremap " . g:pymode_rope_find_it_bind . " :call pymode#rope#find_it()"
end
if g:pymode_rope_organize_imports_bind != ""
exe "noremap " . g:pymode_rope_organize_imports_bind . " :call pymode#rope#organize_imports()"
end
if g:pymode_rope_rename_bind != ""
exe "noremap " . g:pymode_rope_rename_bind . " :call pymode#rope#rename()"
end
if g:pymode_rope_rename_module_bind != ""
exe "noremap " . g:pymode_rope_rename_module_bind . " :call pymode#rope#rename_module()"
end
if g:pymode_rope_extract_method_bind != ""
exe "vnoremap " . g:pymode_rope_extract_method_bind . " :call pymode#rope#extract_method()"
end
if g:pymode_rope_extract_variable_bind != ""
exe "vnoremap " . g:pymode_rope_extract_variable_bind . " :call pymode#rope#extract_variable()"
end
if g:pymode_rope_inline_bind != ""
exe "noremap " . g:pymode_rope_inline_bind . " :call pymode#rope#inline()"
end
if g:pymode_rope_move_bind != ""
exe "noremap " . g:pymode_rope_move_bind . " :call pymode#rope#move()"
end
if g:pymode_rope_change_signature_bind != ""
exe "noremap " . g:pymode_rope_change_signature_bind . " :call pymode#rope#signature()"
end
if g:pymode_rope_use_function_bind != ""
exe "noremap " . g:pymode_rope_use_function_bind . " :call pymode#rope#use_function()"
end
if g:pymode_rope_generate_function_bind != ""
exe "noremap " . g:pymode_rope_generate_function_bind . " :call pymode#rope#generate_function()"
end
if g:pymode_rope_generate_package_bind != ""
exe "noremap " . g:pymode_rope_generate_package_bind . " :call pymode#rope#generate_package()"
end
if g:pymode_rope_generate_class_bind != ""
exe "noremap " . g:pymode_rope_generate_class_bind . " :call pymode#rope#generate_class()"
end
if g:pymode_rope_module_to_package_bind != ""
exe "noremap " . g:pymode_rope_module_to_package_bind . " :call pymode#rope#module_to_package()"
end
if g:pymode_rope_autoimport_bind != ""
exe "noremap " . g:pymode_rope_autoimport_bind . " :PymodeRopeAutoImport"
end
if g:pymode_rope_completion && g:pymode_rope_complete_on_dot
inoremap . .=pymode#rope#complete_on_dot()
end
command! -buffer -nargs=? PymodeRopeNewProject call pymode#rope#new()
command! -buffer PymodeRopeUndo call pymode#rope#undo()
command! -buffer PymodeRopeRedo call pymode#rope#redo()
command! -buffer PymodeRopeRenameModule call pymode#rope#rename_module()
command! -buffer PymodeRopeModuleToPackage call pymode#rope#module_to_package()
command! -buffer PymodeRopeRegenerate call pymode#rope#regenerate()
if g:pymode_rope_autoimport
command! -buffer PymodeRopeAutoImport call pymode#rope#autoimport(expand(''))
end
end