mirror of
https://github.com/gryf/pythonhelper.git
synced 2025-12-19 12:28:16 +01:00
Added the ability to separately access the tag name and tag type, via TagInStatusLineTag or TagInStatusLineType respectively.
This commit is contained in:
@@ -25,7 +25,9 @@
|
|||||||
" the configure script
|
" the configure script
|
||||||
" 2. Copy the pythonhelper.vim script to the $HOME/.vim/plugin directory, or
|
" 2. Copy the pythonhelper.vim script to the $HOME/.vim/plugin directory, or
|
||||||
" install it in some other way (vim-addon-manager, pathogen, ...)
|
" install it in some other way (vim-addon-manager, pathogen, ...)
|
||||||
" 3. Add '%{TagInStatusLine()}' to the statusline in your vimrc
|
" 3. Add '%{TagInStatusLine()}' to the statusline in your vimrc. You can also
|
||||||
|
" use %{TagInStatusLine()} or %{TagInStatusLine()} for just the tag name or
|
||||||
|
" type respectively.
|
||||||
" 4. Run Vim and open any Python file.
|
" 4. Run Vim and open any Python file.
|
||||||
"
|
"
|
||||||
python << EOS
|
python << EOS
|
||||||
@@ -543,16 +545,22 @@ def findTag(bufferNumber, changedTick):
|
|||||||
# describe the cursor position (what tag the cursor is on) {{{
|
# describe the cursor position (what tag the cursor is on) {{{
|
||||||
# reset the description
|
# reset the description
|
||||||
tagDescription = ""
|
tagDescription = ""
|
||||||
|
tagDescriptionTag = ""
|
||||||
|
tagDescriptionType = ""
|
||||||
|
|
||||||
# if an applicable tag has been found, set the description accordingly {{{
|
# if an applicable tag has been found, set the description accordingly {{{
|
||||||
if (nearestLineNumber > -1):
|
if (nearestLineNumber > -1):
|
||||||
tagInfo = tags[nearestLineNumber]
|
tagInfo = tags[nearestLineNumber]
|
||||||
tagDescription = "%s (%s)" % (tagInfo.fullName, PythonTag.TAG_TYPE_NAME[tagInfo.type],)
|
tagDescriptionTag = tagInfo.fullName
|
||||||
|
tagDescriptionType = PythonTag.TAG_TYPE_NAME[tagInfo.type]
|
||||||
|
tagDescription = "%s (%s)" % (tagDescriptionTag, tagDescriptionType)
|
||||||
# }}}
|
# }}}
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# update the variable for the status line so it get updated with the new description
|
# update the variable for the status line so it get updated with the new description
|
||||||
vim.command("let w:PHStatusLine=\"%s\"" % (tagDescription,))
|
vim.command("let w:PHStatusLine=\"%s\"" % (tagDescription,))
|
||||||
|
vim.command("let w:PHStatusLineTag=\"%s\"" % (tagDescriptionTag,))
|
||||||
|
vim.command("let w:PHStatusLineType=\"%s\"" % (tagDescriptionType,))
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
# handle possible exceptions {{{
|
# handle possible exceptions {{{
|
||||||
@@ -612,6 +620,8 @@ function! PHCursorHold()
|
|||||||
" only Python is supported {{{
|
" only Python is supported {{{
|
||||||
if (!exists('b:current_syntax') || (b:current_syntax != 'python'))
|
if (!exists('b:current_syntax') || (b:current_syntax != 'python'))
|
||||||
let w:PHStatusLine = ''
|
let w:PHStatusLine = ''
|
||||||
|
let w:PHStatusLineTag = ''
|
||||||
|
let w:PHStatusLineType = ''
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
" }}}
|
" }}}
|
||||||
@@ -622,8 +632,10 @@ endfunction
|
|||||||
|
|
||||||
|
|
||||||
function! PHBufferDelete()
|
function! PHBufferDelete()
|
||||||
" set the PHStatusLine for this window to an empty string
|
" set the PHStatusLine etc for this window to an empty string
|
||||||
let w:PHStatusLine = ""
|
let w:PHStatusLine = ""
|
||||||
|
let w:PHStatusLineTag = ''
|
||||||
|
let w:PHStatusLineType = ''
|
||||||
|
|
||||||
" call Python function deleteTags() with the current buffer number and change status indicator
|
" call Python function deleteTags() with the current buffer number and change status indicator
|
||||||
execute 'python deleteTags(' . expand("<abuf>") . ')'
|
execute 'python deleteTags(' . expand("<abuf>") . ')'
|
||||||
@@ -641,6 +653,28 @@ function! TagInStatusLine()
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
function! TagInStatusLineTag()
|
||||||
|
" return value of w:PHStatusLineTag in case it's set
|
||||||
|
if (exists("w:PHStatusLineTag"))
|
||||||
|
return w:PHStatusLineTag
|
||||||
|
" otherwise just return an empty string
|
||||||
|
else
|
||||||
|
return ""
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
function! TagInStatusLineType()
|
||||||
|
" return value of w:PHStatusLineType in case it's set
|
||||||
|
if (exists("w:PHStatusLineType"))
|
||||||
|
return w:PHStatusLineType
|
||||||
|
" otherwise just return an empty string
|
||||||
|
else
|
||||||
|
return ""
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
function! PHPreviousClassMethod()
|
function! PHPreviousClassMethod()
|
||||||
call search('^[ \t]*\(class\|def\)\>', 'bw')
|
call search('^[ \t]*\(class\|def\)\>', 'bw')
|
||||||
endfunction
|
endfunction
|
||||||
|
|||||||
Reference in New Issue
Block a user