mirror of
https://github.com/gryf/python.vim.git
synced 2025-12-17 11:30:22 +01:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7a5bb2412f | - | |
|
|
dc9722e464 | - |
@@ -1,8 +1,8 @@
|
|||||||
" -*- vim -*-
|
" -*- vim -*-
|
||||||
" FILE: python.vim
|
" FILE: python.vim
|
||||||
" LAST MODIFICATION: 2003/01/16 10:30
|
" LAST MODIFICATION: 2003/07/25 19:00
|
||||||
" (C) Copyright 2001 Mikael Berthe <mikael.b@netcourrier.com>
|
" (C) Copyright 2001-2003 Mikael Berthe <mikael.b@netcourrier.com>
|
||||||
" Version: 1.5
|
" Version: 1.7
|
||||||
|
|
||||||
" USAGE:
|
" USAGE:
|
||||||
"
|
"
|
||||||
@@ -191,7 +191,7 @@ function! PythonCommentSelection() range
|
|||||||
if strlen(getline(cl))
|
if strlen(getline(cl))
|
||||||
execute "normal ".ind."|i".commentString
|
execute "normal ".ind."|i".commentString
|
||||||
endif
|
endif
|
||||||
execute "normal j"
|
execute "normal \<Down>"
|
||||||
let cl = cl + 1
|
let cl = cl + 1
|
||||||
endwhile
|
endwhile
|
||||||
endfunction
|
endfunction
|
||||||
@@ -247,7 +247,7 @@ function! PythonSelectObject(obj)
|
|||||||
execute "normal V".cl."G"
|
execute "normal V".cl."G"
|
||||||
else
|
else
|
||||||
" Select the whole block
|
" Select the whole block
|
||||||
normal j
|
execute "normal \<Down>"
|
||||||
let cl = line('.')
|
let cl = line('.')
|
||||||
execute ":".beg
|
execute ":".beg
|
||||||
execute "normal V".PythonBoB(cl, 1, 0)."G"
|
execute "normal V".PythonBoB(cl, 1, 0)."G"
|
||||||
@@ -280,22 +280,26 @@ function! PythonNextLine(direction)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
" update the IM-Python menu, that holds Classes and Functions
|
" Update the IM-Python menu, that holds Classes and Functions
|
||||||
function! UpdateMenu()
|
function! UpdateMenu()
|
||||||
|
let restore_fe = &foldenable
|
||||||
|
set nofoldenable
|
||||||
let cline=line('.')
|
let cline=line('.')
|
||||||
call MakeClassStructure ()
|
call MakeClassStructure ()
|
||||||
call MakeFuncStructure ()
|
call MakeFuncStructure ()
|
||||||
execute "normal ".cline."Gzz"
|
execute "normal ".cline."Gzz"
|
||||||
|
let &foldenable = restore_fe
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" make a menu that holds all of the classes
|
" Make a menu that holds all of the classes
|
||||||
function! MakeClassStructure ()
|
function! MakeClassStructure ()
|
||||||
norm mpgg0
|
norm mpgg0
|
||||||
while line(".") <= line("$")
|
while line(".") <= line("$")
|
||||||
if match ( getline("."), '^\s*class\s\+' ) != -1
|
if match ( getline("."), '^\s*class\s\+' ) != -1
|
||||||
norm ^w"nyw
|
norm ^w"nyw
|
||||||
let name=@n
|
let name=@n
|
||||||
exe 'menu IM-Python.classes.'.name.' '.line(".").'gg'
|
"exe 'menu IM-Python.classes.'.name.' '.line(".").'gg15zo'
|
||||||
|
exe 'menu IM-Python.classes.'.name.' :call <SID>JumpToAndUnfold('.line(".").')<CR>'
|
||||||
endif
|
endif
|
||||||
if line(".") == line("$")
|
if line(".") == line("$")
|
||||||
return
|
return
|
||||||
@@ -305,14 +309,15 @@ function! MakeClassStructure ()
|
|||||||
norm 'p
|
norm 'p
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" make a menu that holds all of the function definitions
|
" Make a menu that holds all of the function definitions
|
||||||
function! MakeFuncStructure ()
|
function! MakeFuncStructure ()
|
||||||
norm mpgg0
|
norm mpgg0
|
||||||
while line(".") <= line("$")
|
while line(".") <= line("$")
|
||||||
if match ( getline("."), '^\s*def\s\+' ) != -1
|
if match ( getline("."), '^\s*def\s\+' ) != -1
|
||||||
norm ^w"nyw
|
norm ^w"nyw
|
||||||
let name=@n
|
let name=@n
|
||||||
exe 'menu IM-Python.functions.'.name.' '.line(".").'gg'
|
"exe 'menu IM-Python.functions.'.name.' '.line(".").'gg15zo'
|
||||||
|
exe 'menu IM-Python.functions.'.name.' :call <SID>JumpToAndUnfold('.line(".").')<CR>'
|
||||||
endif
|
endif
|
||||||
if line(".") == line("$")
|
if line(".") == line("$")
|
||||||
return
|
return
|
||||||
@@ -322,6 +327,26 @@ function! MakeFuncStructure ()
|
|||||||
norm 'p
|
norm 'p
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:JumpToAndUnfold(line)
|
||||||
|
" Go to the right line
|
||||||
|
execute 'normal '.a:line.'gg'
|
||||||
|
" Check to see if we are in a fold
|
||||||
|
let lvl = foldlevel(a:line)
|
||||||
|
if lvl != 0
|
||||||
|
" and if so, then expand the fold out, other wise, ignore this part.
|
||||||
|
execute 'normal 15zo'
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
"" This one will work only on vim 6.2 because of the try/catch expressions.
|
||||||
|
" function! s:JumpToAndUnfoldWithExceptions(line)
|
||||||
|
" try
|
||||||
|
" execute 'normal '.a:line.'gg15zo'
|
||||||
|
" catch /^Vim\((\a\+)\)\=:E490:/
|
||||||
|
" " Do nothing, just consume the error
|
||||||
|
" endtry
|
||||||
|
"endfunction
|
||||||
|
|
||||||
|
|
||||||
" vim:set et sts=2 sw=2:
|
" vim:set et sts=2 sw=2:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user