pymode.vim 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. if pymode#Default('b:pymode', 1)
  2. finish
  3. endif
  4. " Parse pymode modeline
  5. call pymode#Modeline()
  6. " Syntax highlight
  7. if pymode#Option('syntax')
  8. let python_highlight_all=1
  9. endif
  10. " Options {{{
  11. " Python other options
  12. if pymode#Option('options')
  13. setlocal complete+=t
  14. setlocal formatoptions-=t
  15. if v:version > 702 && !&relativenumber
  16. setlocal number
  17. endif
  18. setlocal nowrap
  19. setlocal textwidth=79
  20. endif
  21. " }}}
  22. " Documentation {{{
  23. if pymode#Option('doc')
  24. " DESC: Set commands
  25. command! -buffer -nargs=1 Pydoc call pymode#doc#Show("<args>")
  26. " DESC: Set keys
  27. exe "nnoremap <silent> <buffer> " g:pymode_doc_key ":call pymode#doc#Show(expand('<cword>'))<CR>"
  28. exe "vnoremap <silent> <buffer> " g:pymode_doc_key ":<C-U>call pymode#doc#Show(@*)<CR>"
  29. endif
  30. " }}}
  31. " Lint {{{
  32. if pymode#Option('lint')
  33. " DESC: Set commands
  34. command! -buffer -nargs=0 PyLintToggle :call pymode#lint#Toggle()
  35. command! -buffer -nargs=0 PyLintWindowToggle :call pymode#lint#ToggleWindow()
  36. command! -buffer -nargs=0 PyLintCheckerToggle :call pymode#lint#ToggleChecker()
  37. command! -buffer -nargs=0 PyLint :call pymode#lint#Check()
  38. command! -buffer -nargs=0 PyLintAuto :call pymode#lint#Auto()
  39. " DESC: Set autocommands
  40. if pymode#Option('lint_write')
  41. au BufWritePost <buffer> PyLint
  42. endif
  43. if pymode#Option('lint_onfly')
  44. au InsertLeave <buffer> PyLint
  45. endif
  46. if pymode#Option('lint_message')
  47. au CursorHold <buffer> call pymode#lint#show_errormessage()
  48. au CursorMoved <buffer> call pymode#lint#show_errormessage()
  49. endif
  50. " DESC: Run queue
  51. let &l:updatetime = g:pymode_updatetime
  52. au CursorHold <buffer> call pymode#queue#Poll()
  53. au BufLeave <buffer> py queue.stop_queue()
  54. endif
  55. " }}}
  56. " Rope {{{
  57. if pymode#Option('rope')
  58. " DESC: Set keys
  59. exe "noremap <silent> <buffer> " . g:pymode_rope_short_prefix . "g :RopeGotoDefinition<CR>"
  60. exe "noremap <silent> <buffer> " . g:pymode_rope_short_prefix . "d :RopeShowDoc<CR>"
  61. exe "noremap <silent> <buffer> " . g:pymode_rope_short_prefix . "f :RopeFindOccurrences<CR>"
  62. exe "noremap <silent> <buffer> " . g:pymode_rope_short_prefix . "m :emenu Rope . <TAB>"
  63. inoremap <silent> <buffer> <S-TAB> <C-R>=RopeLuckyAssistInsertMode()<CR>
  64. if g:pymode_rope_map_space
  65. let s:prascm = g:pymode_rope_always_show_complete_menu ? "<C-P>" : ""
  66. exe "inoremap <silent> <buffer> <Nul> <C-R>=RopeCodeAssistInsertMode()<CR>" . s:prascm
  67. exe "inoremap <silent> <buffer> <c-space> <C-R>=RopeCodeAssistInsertMode()<CR>" . s:prascm
  68. endif
  69. endif
  70. " }}}
  71. " Execution {{{
  72. if pymode#Option('run')
  73. " DESC: Set commands
  74. command! -buffer -nargs=0 -range=% Pyrun call pymode#run#Run(<f-line1>, <f-line2>)
  75. " DESC: Set keys
  76. exe "nnoremap <silent> <buffer> " g:pymode_run_key ":Pyrun<CR>"
  77. exe "vnoremap <silent> <buffer> " g:pymode_run_key ":Pyrun<CR>"
  78. endif
  79. " }}}
  80. " Breakpoints {{{
  81. if pymode#Option('breakpoint')
  82. " DESC: Set keys
  83. exe "nnoremap <silent> <buffer> " g:pymode_breakpoint_key ":call pymode#breakpoint#Set(line('.'))<CR>"
  84. endif
  85. " }}}
  86. " Utils {{{
  87. if pymode#Option('utils_whitespaces')
  88. au BufWritePre <buffer> call pymode#TrimWhiteSpace()
  89. endif
  90. " }}}
  91. " Folding {{{
  92. if pymode#Option('folding')
  93. setlocal foldmethod=expr
  94. setlocal foldexpr=pymode#folding#expr(v:lnum)
  95. setlocal foldtext=pymode#folding#text()
  96. endif
  97. " }}}
  98. " vim: fdm=marker:fdl=0