diff --git a/ftplugin/python/pymode.vim b/ftplugin/python/pymode.vim index e18d9445..c842964b 100644 --- a/ftplugin/python/pymode.vim +++ b/ftplugin/python/pymode.vim @@ -1,3 +1,276 @@ +let g:pymode_version = "0.6.3" + +com! PymodeVersion echomsg "Current python-mode version: " . g:pymode_version + +" OPTION: g:pymode -- bool. Run pymode. +if pymode#Default('g:pymode', 1) || !g:pymode + " DESC: Disable script loading + finish +endif + +" DESC: Check python support +if !has('python') + echoerr expand(":t") . " required vim compiled with +python." + let g:pymode_lint = 0 + let g:pymode_rope = 0 + let g:pymode_path = 0 + let g:pymode_doc = 0 + let g:pymode_run = 0 + let g:pymode_virtualenv = 0 +endif + + +" Virtualenv {{{ + +if !pymode#Default("g:pymode_virtualenv", 1) || g:pymode_virtualenv + + call pymode#Default("g:pymode_virtualenv_enabled", []) + + " Add virtualenv paths + call pymode#virtualenv#Activate() + +endif + +" }}} + + +" DESC: Fix python path +if !pymode#Default('g:pymode_path', 1) || g:pymode_path +python << EOF +import sys, vim, os + +curpath = vim.eval("getcwd()") +libpath = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname( + vim.eval("expand(':p')")))), 'pylibs') + +sys.path = [libpath, curpath] + sys.path +EOF +endif + + +" Lint {{{ + +if !pymode#Default("g:pymode_lint", 1) || g:pymode_lint + + let g:qf_list = [] + + " OPTION: g:pymode_lint_write -- bool. Check code every save. + call pymode#Default("g:pymode_lint_write", 1) + + " OPTION: g:pymode_lint_onfly -- bool. Check code every save. + call pymode#Default("g:pymode_lint_onfly", 0) + + " OPTION: g:pymode_lint_message -- bool. Show current line error message + call pymode#Default("g:pymode_lint_message", 1) + + " OPTION: g:pymode_lint_checker -- str. Choices are: pylint, pyflakes, pep8, mccabe + call pymode#Default("g:pymode_lint_checker", "pyflakes,pep8,mccabe") + + " OPTION: g:pymode_lint_config -- str. Path to pylint config file + call pymode#Default("g:pymode_lint_config", $HOME . "/.pylintrc") + + " OPTION: g:pymode_lint_cwindow -- bool. Auto open cwindow if errors find + call pymode#Default("g:pymode_lint_cwindow", 1) + + " OPTION: g:pymode_lint_jump -- int. Jump on first error. + call pymode#Default("g:pymode_lint_jump", 0) + + " OPTION: g:pymode_lint_hold -- int. Hold cursor on current window when + " quickfix open + call pymode#Default("g:pymode_lint_hold", 0) + + " OPTION: g:pymode_lint_minheight -- int. Minimal height of pymode lint window + call pymode#Default("g:pymode_lint_minheight", 3) + + " OPTION: g:pymode_lint_maxheight -- int. Maximal height of pymode lint window + call pymode#Default("g:pymode_lint_maxheight", 6) + + " OPTION: g:pymode_lint_ignore -- string. Skip errors and warnings (e.g. E4,W) + call pymode#Default("g:pymode_lint_ignore", "E501") + + " OPTION: g:pymode_lint_select -- string. Select errors and warnings (e.g. E4,W) + call pymode#Default("g:pymode_lint_select", "") + + " OPTION: g:pymode_lint_mccabe_complexity -- int. Maximum allowed complexity + call pymode#Default("g:pymode_lint_mccabe_complexity", 8) + + " OPTION: g:pymode_lint_signs -- bool. Place error signs + if !pymode#Default("g:pymode_lint_signs", 1) || g:pymode_lint_signs + + " DESC: Signs definition + sign define W text=WW texthl=Todo + sign define C text=CC texthl=Comment + sign define R text=RR texthl=Visual + sign define E text=EE texthl=Error + sign define I text=II texthl=Info + + endif + + " DESC: Set default pylint configuration + if !filereadable(g:pymode_lint_config) + let g:pymode_lint_config = expand(":p:h:h") . "/pylint.ini" + endif + + py from pymode import check_file + +endif + +" }}} + + +" Documentation {{{ + +if !pymode#Default("g:pymode_doc", 1) || g:pymode_doc + + " OPTION: g:pymode_doc_key -- string. Key for show python documantation. + call pymode#Default("g:pymode_doc_key", "K") + +endif + +" }}} + + +" Breakpoints {{{ + +if !pymode#Default("g:pymode_breakpoint", 1) || g:pymode_breakpoint + + if !pymode#Default("g:pymode_breakpoint_cmd", "import ipdb; ipdb.set_trace() ### XXX BREAKPOINT") && has("python") +python << EOF +from imp import find_module +try: + find_module('ipdb') +except ImportError: + vim.command('let g:pymode_breakpoint_cmd = "import pdb; pdb.set_trace() ### XXX BREAKPOINT"') +EOF + endif + + " OPTION: g:pymode_breakpoint_key -- string. Key for set/unset breakpoint. + call pymode#Default("g:pymode_breakpoint_key", "b") + +endif + +" }}} + + +" Execution {{{ + +if !pymode#Default("g:pymode_run", 1) || g:pymode_run + + " OPTION: g:pymode_doc_key -- string. Key for show python documentation. + call pymode#Default("g:pymode_run_key", "r") + +endif + +" }}} + + +" Rope {{{ + +if !pymode#Default("g:pymode_rope", 1) || g:pymode_rope + + " OPTION: g:pymode_rope_auto_project -- bool. Auto open ropeproject + call pymode#Default("g:pymode_rope_auto_project", 1) + + " OPTION: g:pymode_rope_enable_autoimport -- bool. Enable autoimport + call pymode#Default("g:pymode_rope_enable_autoimport", 1) + + " OPTION: g:pymode_rope_autoimport_generate -- bool. + call pymode#Default("g:pymode_rope_autoimport_generate", 1) + + " OPTION: g:pymode_rope_autoimport_underlines -- bool. + call pymode#Default("g:pymode_rope_autoimport_underlineds", 0) + + " OPTION: g:pymode_rope_codeassist_maxfiles -- bool. + call pymode#Default("g:pymode_rope_codeassist_maxfixes", 10) + + " OPTION: g:pymode_rope_sorted_completions -- bool. + call pymode#Default("g:pymode_rope_sorted_completions", 1) + + " OPTION: g:pymode_rope_extended_complete -- bool. + call pymode#Default("g:pymode_rope_extended_complete", 1) + + " OPTION: g:pymode_rope_autoimport_modules -- array. + call pymode#Default("g:pymode_rope_autoimport_modules", ["os","shutil","datetime"]) + + " OPTION: g:pymode_rope_confirm_saving -- bool. + call pymode#Default("g:pymode_rope_confirm_saving", 1) + + " OPTION: g:pymode_rope_global_prefix -- string. + call pymode#Default("g:pymode_rope_global_prefix", "p") + + " OPTION: g:pymode_rope_local_prefix -- string. + call pymode#Default("g:pymode_rope_local_prefix", "r") + + " OPTION: g:pymode_rope_short_prefix -- string. + call pymode#Default("g:pymode_rope_short_prefix", "") + + " OPTION: g:pymode_rope_vim_completion -- bool. + call pymode#Default("g:pymode_rope_vim_completion", 1) + + " OPTION: g:pymode_rope_guess_project -- bool. + call pymode#Default("g:pymode_rope_guess_project", 1) + + " OPTION: g:pymode_rope_goto_def_newwin -- str ('new', 'vnew', ''). + call pymode#Default("g:pymode_rope_goto_def_newwin", "") + + " OPTION: g:pymode_rope_always_show_complete_menu -- bool. + call pymode#Default("g:pymode_rope_always_show_complete_menu", 0) + + " DESC: Init Rope + py import ropevim + + fun! RopeCodeAssistInsertMode() "{{{ + call RopeCodeAssist() + return "" + endfunction "}}} + + fun! RopeLuckyAssistInsertMode() "{{{ + call RopeLuckyAssist() + return "" + endfunction "}}} + + fun! RopeOmni(findstart, base) "{{{ + if a:findstart + py ropevim._interface._find_start() + return g:pymode_offset + else + call RopeOmniComplete() + return g:pythoncomplete_completions + endif + endfunction "}}} + + " Rope menu + menu Rope.Autoimport :RopeAutoImport + menu Rope.ChangeSignature :RopeChangeSignature + menu Rope.CloseProject :RopeCloseProject + menu Rope.GenerateAutoImportCache :RopeGenerateAutoimportCache + menu Rope.ExtractVariable :RopeExtractVariable + menu Rope.ExtractMethod :RopeExtractMethod + menu Rope.Inline :RopeInline + menu Rope.IntroduceFactory :RopeIntroduceFactory + menu Rope.FindFile :RopeFindFile + menu Rope.OpenProject :RopeOpenProject + menu Rope.Move :RopeMove + menu Rope.MoveCurrentModule :RopeMoveCurrentModule + menu Rope.ModuleToPackage :RopeModuleToPackage + menu Rope.Redo :RopeRedo + menu Rope.Rename :RopeRename + menu Rope.RenameCurrentModule :RopeRenameCurrentModule + menu Rope.Restructure :RopeRestructure + menu Rope.Undo :RopeUndo + menu Rope.UseFunction :RopeUseFunction + +endif + +" }}} + + +" OPTION: g:pymode_folding -- bool. Enable python-mode folding for pyfiles. +call pymode#Default("g:pymode_folding", 1) + +" OPTION: g:pymode_utils_whitespaces -- bool. Remove unused whitespaces on save +call pymode#Default("g:pymode_utils_whitespaces", 1) + if pymode#Default('b:pymode', 1) finish endif diff --git a/plugin/pymode.vim b/plugin/pymode.vim deleted file mode 100644 index 6bd21518..00000000 --- a/plugin/pymode.vim +++ /dev/null @@ -1,274 +0,0 @@ -let g:pymode_version = "0.6.3" - -com! PymodeVersion echomsg "Current python-mode version: " . g:pymode_version - -" OPTION: g:pymode -- bool. Run pymode. -if pymode#Default('g:pymode', 1) || !g:pymode - " DESC: Disable script loading - finish -endif - -" DESC: Check python support -if !has('python') - echoerr expand(":t") . " required vim compiled with +python." - let g:pymode_lint = 0 - let g:pymode_rope = 0 - let g:pymode_path = 0 - let g:pymode_doc = 0 - let g:pymode_run = 0 - let g:pymode_virtualenv = 0 -endif - - -" Virtualenv {{{ - -if !pymode#Default("g:pymode_virtualenv", 1) || g:pymode_virtualenv - - call pymode#Default("g:pymode_virtualenv_enabled", []) - - " Add virtualenv paths - call pymode#virtualenv#Activate() - -endif - -" }}} - - -" DESC: Fix python path -if !pymode#Default('g:pymode_path', 1) || g:pymode_path -python << EOF -import sys, vim, os - -curpath = vim.eval("getcwd()") -libpath = os.path.join(os.path.dirname(os.path.dirname( - vim.eval("expand(':p')"))), 'pylibs') - -sys.path = [libpath, curpath] + sys.path -EOF -endif - - -" Lint {{{ - -if !pymode#Default("g:pymode_lint", 1) || g:pymode_lint - - let g:qf_list = [] - - " OPTION: g:pymode_lint_write -- bool. Check code every save. - call pymode#Default("g:pymode_lint_write", 1) - - " OPTION: g:pymode_lint_onfly -- bool. Check code every save. - call pymode#Default("g:pymode_lint_onfly", 0) - - " OPTION: g:pymode_lint_message -- bool. Show current line error message - call pymode#Default("g:pymode_lint_message", 1) - - " OPTION: g:pymode_lint_checker -- str. Choices are: pylint, pyflakes, pep8, mccabe - call pymode#Default("g:pymode_lint_checker", "pyflakes,pep8,mccabe") - - " OPTION: g:pymode_lint_config -- str. Path to pylint config file - call pymode#Default("g:pymode_lint_config", $HOME . "/.pylintrc") - - " OPTION: g:pymode_lint_cwindow -- bool. Auto open cwindow if errors find - call pymode#Default("g:pymode_lint_cwindow", 1) - - " OPTION: g:pymode_lint_jump -- int. Jump on first error. - call pymode#Default("g:pymode_lint_jump", 0) - - " OPTION: g:pymode_lint_hold -- int. Hold cursor on current window when - " quickfix open - call pymode#Default("g:pymode_lint_hold", 0) - - " OPTION: g:pymode_lint_minheight -- int. Minimal height of pymode lint window - call pymode#Default("g:pymode_lint_minheight", 3) - - " OPTION: g:pymode_lint_maxheight -- int. Maximal height of pymode lint window - call pymode#Default("g:pymode_lint_maxheight", 6) - - " OPTION: g:pymode_lint_ignore -- string. Skip errors and warnings (e.g. E4,W) - call pymode#Default("g:pymode_lint_ignore", "E501") - - " OPTION: g:pymode_lint_select -- string. Select errors and warnings (e.g. E4,W) - call pymode#Default("g:pymode_lint_select", "") - - " OPTION: g:pymode_lint_mccabe_complexity -- int. Maximum allowed complexity - call pymode#Default("g:pymode_lint_mccabe_complexity", 8) - - " OPTION: g:pymode_lint_signs -- bool. Place error signs - if !pymode#Default("g:pymode_lint_signs", 1) || g:pymode_lint_signs - - " DESC: Signs definition - sign define W text=WW texthl=Todo - sign define C text=CC texthl=Comment - sign define R text=RR texthl=Visual - sign define E text=EE texthl=Error - sign define I text=II texthl=Info - - endif - - " DESC: Set default pylint configuration - if !filereadable(g:pymode_lint_config) - let g:pymode_lint_config = expand(":p:h:h") . "/pylint.ini" - endif - - py from pymode import check_file - -endif - -" }}} - - -" Documentation {{{ - -if !pymode#Default("g:pymode_doc", 1) || g:pymode_doc - - " OPTION: g:pymode_doc_key -- string. Key for show python documantation. - call pymode#Default("g:pymode_doc_key", "K") - -endif - -" }}} - - -" Breakpoints {{{ - -if !pymode#Default("g:pymode_breakpoint", 1) || g:pymode_breakpoint - - if !pymode#Default("g:pymode_breakpoint_cmd", "import ipdb; ipdb.set_trace() ### XXX BREAKPOINT") && has("python") -python << EOF -from imp import find_module -try: - find_module('ipdb') -except ImportError: - vim.command('let g:pymode_breakpoint_cmd = "import pdb; pdb.set_trace() ### XXX BREAKPOINT"') -EOF - endif - - " OPTION: g:pymode_breakpoint_key -- string. Key for set/unset breakpoint. - call pymode#Default("g:pymode_breakpoint_key", "b") - -endif - -" }}} - - -" Execution {{{ - -if !pymode#Default("g:pymode_run", 1) || g:pymode_run - - " OPTION: g:pymode_doc_key -- string. Key for show python documentation. - call pymode#Default("g:pymode_run_key", "r") - -endif - -" }}} - - -" Rope {{{ - -if !pymode#Default("g:pymode_rope", 1) || g:pymode_rope - - " OPTION: g:pymode_rope_auto_project -- bool. Auto open ropeproject - call pymode#Default("g:pymode_rope_auto_project", 1) - - " OPTION: g:pymode_rope_enable_autoimport -- bool. Enable autoimport - call pymode#Default("g:pymode_rope_enable_autoimport", 1) - - " OPTION: g:pymode_rope_autoimport_generate -- bool. - call pymode#Default("g:pymode_rope_autoimport_generate", 1) - - " OPTION: g:pymode_rope_autoimport_underlines -- bool. - call pymode#Default("g:pymode_rope_autoimport_underlineds", 0) - - " OPTION: g:pymode_rope_codeassist_maxfiles -- bool. - call pymode#Default("g:pymode_rope_codeassist_maxfixes", 10) - - " OPTION: g:pymode_rope_sorted_completions -- bool. - call pymode#Default("g:pymode_rope_sorted_completions", 1) - - " OPTION: g:pymode_rope_extended_complete -- bool. - call pymode#Default("g:pymode_rope_extended_complete", 1) - - " OPTION: g:pymode_rope_autoimport_modules -- array. - call pymode#Default("g:pymode_rope_autoimport_modules", ["os","shutil","datetime"]) - - " OPTION: g:pymode_rope_confirm_saving -- bool. - call pymode#Default("g:pymode_rope_confirm_saving", 1) - - " OPTION: g:pymode_rope_global_prefix -- string. - call pymode#Default("g:pymode_rope_global_prefix", "p") - - " OPTION: g:pymode_rope_local_prefix -- string. - call pymode#Default("g:pymode_rope_local_prefix", "r") - - " OPTION: g:pymode_rope_short_prefix -- string. - call pymode#Default("g:pymode_rope_short_prefix", "") - - " OPTION: g:pymode_rope_vim_completion -- bool. - call pymode#Default("g:pymode_rope_vim_completion", 1) - - " OPTION: g:pymode_rope_guess_project -- bool. - call pymode#Default("g:pymode_rope_guess_project", 1) - - " OPTION: g:pymode_rope_goto_def_newwin -- str ('new', 'vnew', ''). - call pymode#Default("g:pymode_rope_goto_def_newwin", "") - - " OPTION: g:pymode_rope_always_show_complete_menu -- bool. - call pymode#Default("g:pymode_rope_always_show_complete_menu", 0) - - " DESC: Init Rope - py import ropevim - - fun! RopeCodeAssistInsertMode() "{{{ - call RopeCodeAssist() - return "" - endfunction "}}} - - fun! RopeLuckyAssistInsertMode() "{{{ - call RopeLuckyAssist() - return "" - endfunction "}}} - - fun! RopeOmni(findstart, base) "{{{ - if a:findstart - py ropevim._interface._find_start() - return g:pymode_offset - else - call RopeOmniComplete() - return g:pythoncomplete_completions - endif - endfunction "}}} - - " Rope menu - menu Rope.Autoimport :RopeAutoImport - menu Rope.ChangeSignature :RopeChangeSignature - menu Rope.CloseProject :RopeCloseProject - menu Rope.GenerateAutoImportCache :RopeGenerateAutoimportCache - menu Rope.ExtractVariable :RopeExtractVariable - menu Rope.ExtractMethod :RopeExtractMethod - menu Rope.Inline :RopeInline - menu Rope.IntroduceFactory :RopeIntroduceFactory - menu Rope.FindFile :RopeFindFile - menu Rope.OpenProject :RopeOpenProject - menu Rope.Move :RopeMove - menu Rope.MoveCurrentModule :RopeMoveCurrentModule - menu Rope.ModuleToPackage :RopeModuleToPackage - menu Rope.Redo :RopeRedo - menu Rope.Rename :RopeRename - menu Rope.RenameCurrentModule :RopeRenameCurrentModule - menu Rope.Restructure :RopeRestructure - menu Rope.Undo :RopeUndo - menu Rope.UseFunction :RopeUseFunction - -endif - -" }}} - - -" OPTION: g:pymode_folding -- bool. Enable python-mode folding for pyfiles. -call pymode#Default("g:pymode_folding", 1) - -" OPTION: g:pymode_utils_whitespaces -- bool. Remove unused whitespaces on save -call pymode#Default("g:pymode_utils_whitespaces", 1) - -" vim: fdm=marker:fdl=0