view release on metacpan or search on metacpan
contrib/vim/taglist.vim view on Meta::CPAN
113114115116117118119120121122123124125126127128129130131132133134" taglist window
if
!
exists
(
'Tlist_GainFocus_On_ToggleOpen'
)
let Tlist_GainFocus_On_ToggleOpen = 0
endif
" Process files even
when
the taglist window is not
open
if
!
exists
(
'Tlist_Process_File_Always'
)
let Tlist_Process_File_Always = 0
endif
if
!
exists
(
'Tlist_Show_Menu'
)
let Tlist_Show_Menu = 0
endif
" Tag listing
sort
type -
'name'
or
'order'
if
!
exists
(
'Tlist_Sort_Type'
)
let Tlist_Sort_Type =
'order'
endif
" Tag listing window
split
(horizontal/vertical) control
if
!
exists
(
'Tlist_Use_Horiz_Window'
)
let Tlist_Use_Horiz_Window = 0
contrib/vim/taglist.vim view on Meta::CPAN
248249250251252253254255256257258259260261262263264265266267268269" on Vim startup
if
g:Tlist_Auto_Open
autocmd VimEnter * nested call s:Tlist_Window_Check_Auto_Open()
endif
" Refresh the taglist
if
g:Tlist_Process_File_Always
autocmd BufEnter * call s:Tlist_Refresh()
endif
if
g:Tlist_Show_Menu
autocmd GUIEnter * call s:Tlist_Menu_Init()
endif
" When the taglist buffer is created
when
loading a Vim session file,
" the taglist buffer needs to be initialized. The BufFilePost event
" is used to handle this case.
autocmd BufFilePost __Tag_List__ call s:Tlist_Vim_Session_Load()
" Define the user commands to manage the taglist window
command! -nargs=0 -bar TlistToggle call s:Tlist_Window_Toggle()
command! -nargs=0 -bar TlistOpen call s:Tlist_Window_Open()
contrib/vim/taglist.vim view on Meta::CPAN
301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
" Trick to get the current script ID
map
<SID>xx <SID>xx
let s:tlist_sid = substitute(maparg(
'<SID>xx'
),
'<SNR>\(\d\+_\)xx$'
,
\
'\1'
,
''
)
unmap <SID>xx
exe
'autocmd FuncUndefined *'
. s:tlist_sid .
'Tlist_* source '
.
\ escape(expand(
'<sfile>'
),
' '
)
exe
'autocmd FuncUndefined *'
. s:tlist_sid .
'Tlist_Window_* source '
.
\ escape(expand(
'<sfile>'
),
' '
)
exe
'autocmd FuncUndefined *'
. s:tlist_sid .
'Tlist_Menu_* source '
.
\ escape(expand(
'<sfile>'
),
' '
)
exe
'autocmd FuncUndefined Tlist_* source '
.
\ escape(expand(
'<sfile>'
),
' '
)
exe
'autocmd FuncUndefined TagList_* source '
.
\ escape(expand(
'<sfile>'
),
' '
)
let loaded_taglist =
'fast_load_done'
if
g:Tlist_Show_Menu &&
has
(
'gui_running'
)
call s:Tlist_Menu_Init()
endif
" restore
'cpo'
let
&cpo
= s:cpo_save
finish
endif
if
!
exists
(
's:tlist_sid'
)
" Two or more versions of taglist plugin are installed. Don't
" load this version of the plugin.
contrib/vim/taglist.vim view on Meta::CPAN
166416651666166716681669167016711672167316741675167616771678167916801681168216831684
autocmd BufEnter * silent
\ call s:Tlist_Window_Open_File_Fold(expand(
'<abuf>'
))
endif
" Exit Vim itself
if
only the taglist window is present (optional)
if
g:Tlist_Exit_OnlyWindow
autocmd BufEnter __Tag_List__ nested
\ call s:Tlist_Window_Exit_Only_Window()
endif
if
s:tlist_app_name !=
"winmanager"
&&
\ !g:Tlist_Process_File_Always &&
\ (!
has
(
'gui_running'
) || !g:Tlist_Show_Menu)
" Auto refresh the taglist window
autocmd BufEnter * call s:Tlist_Refresh()
endif
if
!g:Tlist_Use_Horiz_Window
if
v:version < 700
autocmd WinEnter * call s:Tlist_Window_Check_Width()
endif
endif
augroup end
contrib/vim/taglist.vim view on Meta::CPAN
1997199819992000200120022003200420052006200720082009201020112012201320142015201620172018
" include the empty line
after
the
last
line
if
g:Tlist_Compact_Format
let end = s:tlist_{fidx}_end
else
let end = s:tlist_{fidx}_end + 1
endif
call s:Tlist_Window_Update_Line_Offsets(fidx + 1, 1, end - start + 1)
" Now that we have updated the taglist window, update the tags
" menu (
if
present)
if
g:Tlist_Show_Menu
call s:Tlist_Menu_Update_File(1)
endif
endfunction
" Tlist_Init_File
" Initialize the variables
for
a new file
function! s:Tlist_Init_File(filename, ftype)
call s:Tlist_Log_Msg(
'Tlist_Init_File ('
. a:filename .
')'
)
" Add new files at the end of the list
let fidx = s:tlist_file_count
let s:tlist_file_count = s:tlist_file_count + 1
contrib/vim/taglist.vim view on Meta::CPAN
2488248924902491249224932494249524962497249824992500250125022503250425052506250725082509
exe
'normal! '
. save_col .
'|'
endif
if
winnr() != save_winnr
" Go back to the original window
call s:Tlist_Exe_Cmd_No_Acmds(save_winnr .
'wincmd w'
)
endif
endif
" Update the taglist menu
if
g:Tlist_Show_Menu
call s:Tlist_Menu_Update_File(1)
endif
endfunction
" Tlist_Window_Close
" Close the taglist window
function! s:Tlist_Window_Close()
call s:Tlist_Log_Msg(
'Tlist_Window_Close()'
)
" Make sure the taglist window
exists
let winnum = bufwinnr(g:TagList_title)
if
winnum == -1
contrib/vim/taglist.vim view on Meta::CPAN
2612261326142615261626172618261926202621262226232624262526262627262826292630263126322633
call s:Tlist_Window_Open()
" Go back to the original window,
if
Tlist_GainFocus_On_ToggleOpen is not
" set
if
!g:Tlist_GainFocus_On_ToggleOpen
call s:Tlist_Exe_Cmd_No_Acmds(
'wincmd p'
)
endif
" Update the taglist menu
if
g:Tlist_Show_Menu
call s:Tlist_Menu_Update_File(0)
endif
endfunction
" Tlist_Process_Filelist
" Process multiple files. Each filename is separated by "
\n"
" Returns the number of processed files
function! s:Tlist_Process_Filelist(file_names)
let flist = a:file_names
" Enable lazy screen updates
contrib/vim/taglist.vim view on Meta::CPAN
278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835" Tlist_Refresh()
" Refresh the taglist
function! s:Tlist_Refresh()
call s:Tlist_Log_Msg(
'Tlist_Refresh (Skip_Refresh = '
.
\ s:Tlist_Skip_Refresh .
', '
. bufname(
'%'
) .
')'
)
" If we are entering the buffer from one of the taglist functions, then
"
no
need to refresh the taglist window again.
if
s:Tlist_Skip_Refresh
" We still need to update the taglist menu
if
g:Tlist_Show_Menu
call s:Tlist_Menu_Update_File(0)
endif
return
endif
" If part of the winmanager plugin and not configured to process
" tags always and not configured to display the tags menu, then
return
if
(s:tlist_app_name ==
'winmanager'
) && !g:Tlist_Process_File_Always
\ && !g:Tlist_Show_Menu
return
endif
" Skip buffers
with
'https://metacpan.org/pod/buftype">buftype'
set to nofile, nowrite, quickfix or help
if
&buftype
!=
''
return
endif
let filename = fnamemodify(bufname(
'%'
),
':p'
)
let ftype =
&filetype
" If the file doesn't support tag listing, skip it
if
s:Tlist_Skip_File(filename, ftype)
return
endif
let tlist_win = bufwinnr(g:TagList_title)
" If the taglist window is not opened and not configured to process
" tags always and not displaying the tags menu, then
return
if
tlist_win == -1 && !g:Tlist_Process_File_Always && !g:Tlist_Show_Menu
return
endif
let fidx = s:Tlist_Get_File_Index(filename)
if
fidx == -1
" Check whether this file is removed based on user request
" If it is, then don't display the tags
for
this file
if
s:Tlist_User_Removed_File(filename)
return
endif
contrib/vim/taglist.vim view on Meta::CPAN
2909291029112912291329142915291629172918291929202921292229232924292529262927292829292930
" Jump back to the original window
if
save_winnr != winnr()
call s:Tlist_Exe_Cmd_No_Acmds(save_winnr .
'wincmd w'
)
endif
" Restore screen updates
let
&lazyredraw
= old_lazyredraw
endif
" Update the taglist menu
if
g:Tlist_Show_Menu
call s:Tlist_Menu_Update_File(0)
endif
endfunction
" Tlist_Change_Sort()
" Change the
sort
order of the tag listing
"
caller
==
'cmd'
, command used in the taglist window
"
caller
==
'menu'
, taglist menu
" action ==
'toggle'
, toggle
sort
from name to order and vice versa
" action ==
'set'
, set the
sort
order to sort_type
function! s:Tlist_Change_Sort(
caller
, action, sort_type)
contrib/vim/taglist.vim view on Meta::CPAN
29662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988
let curline =
'\V\^'
. getline(
'.'
) .
'\$'
call s:Tlist_Window_Refresh_File(s:tlist_{fidx}_filename,
\ s:tlist_{fidx}_filetype)
exe s:tlist_{fidx}_start .
','
. s:tlist_{fidx}_end .
'foldopen!'
" Go back to the cursor line
before
the tag list is sorted
call search(curline,
'w'
)
call s:Tlist_Menu_Update_File(1)
else
call s:Tlist_Menu_Remove_File()
call s:Tlist_Refresh()
endif
endfunction
" Tlist_Update_Current_File()
" Update taglist
for
the current buffer by regenerating the tag list
" Contributed by WEN Guopeng.
function! s:Tlist_Update_Current_File()
call s:Tlist_Log_Msg(
'Tlist_Update_Current_File()'
)
contrib/vim/taglist.vim view on Meta::CPAN
407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127
endif
let i = i + 1
let buf_num = winbufnr(i)
endwhile
if
open_window
call s:Tlist_Window_Toggle()
endif
endfunction
function! s:Tlist_Menu_Add_Base_Menu()
call s:Tlist_Log_Msg(
'Adding the base menu'
)
" Add the menu
anoremenu <silent> T
&ags
.Refresh\ menu :call <SID>Tlist_Menu_Refresh()<CR>
anoremenu <silent> T
&ags
.Sort\ menu\ by.Name
\ :call <SID>Tlist_Change_Sort(
'menu'
,
'set'
,
'name'
)<CR>
anoremenu <silent> T
&ags
.Sort\ menu\ by.Order
\ :call <SID>Tlist_Change_Sort(
'menu'
,
'set'
,
'order'
)<CR>
anoremenu T
&ags
.-SEP1- :
if
&mousemodel
=~
'popup'
anoremenu <silent> PopUp.T
&ags
.Refresh\ menu
\ :call <SID>Tlist_Menu_Refresh()<CR>
anoremenu <silent> PopUp.T
&ags
.Sort\ menu\ by.Name
\ :call <SID>Tlist_Change_Sort(
'menu'
,
'set'
,
'name'
)<CR>
anoremenu <silent> PopUp.T
&ags
.Sort\ menu\ by.Order
\ :call <SID>Tlist_Change_Sort(
'menu'
,
'set'
,
'order'
)<CR>
anoremenu PopUp.T
&ags
.-SEP1- :
endif
endfunction
let s:menu_char_prefix =
\
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
" Tlist_Menu_Get_Tag_Type_Cmd
" Get the menu command
for
the specified tag type
" fidx - File type
index
" ftype - File Type
" add_ttype_name - To add or not to add the tag type name to the menu entries
" ttype_idx - Tag type
index
function! s:Tlist_Menu_Get_Tag_Type_Cmd(fidx, ftype, add_ttype_name, ttype_idx)
" Curly brace variable name optimization
let ftype_ttype_idx = a:ftype .
'_'
. a:ttype_idx
let ttype = s:tlist_{ftype_ttype_idx}_name
if
a:add_ttype_name
" If the tag type name contains space characters, escape it. This
" will be used to create the menu entries.
let ttype_fullname = escape(s:tlist_{ftype_ttype_idx}_fullname,
' '
)
endif
contrib/vim/taglist.vim view on Meta::CPAN
41714172417341744175417641774178417941804181418241834184418541864187418841894190
" Character prefix used to number the menu items (hotkey)
let m_prefix_idx = 0
while
j <= final_index
let tidx = s:tlist_{fidx_ttype}_{j}
let tname = s:tlist_{a:fidx}_{tidx}_tag_name
let mcmd = mcmd . m_prefix .
'\&'
.
\ s:menu_char_prefix[m_prefix_idx] .
'\.'
.
\ tname .
' :call <SID>Tlist_Menu_Jump_To_Tag('
.
\ tidx .
')<CR>|'
let m_prefix_idx = m_prefix_idx + 1
let j = j + 1
endwhile
endwhile
else
" Character prefix used to number the menu items (hotkey)
let m_prefix_idx = 0
contrib/vim/taglist.vim view on Meta::CPAN
419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226
let m_prefix = m_prefix . ttype_fullname .
'.'
endif
let j = 1
while
j <= tcnt
let tidx = s:tlist_{fidx_ttype}_{j}
let tname = s:tlist_{a:fidx}_{tidx}_tag_name
let mcmd = mcmd . m_prefix .
'\&'
.
\ s:menu_char_prefix[m_prefix_idx] .
'\.'
.
\ tname .
' :call <SID>Tlist_Menu_Jump_To_Tag('
. tidx
\ .
')<CR>|'
let m_prefix_idx = m_prefix_idx + 1
let j = j + 1
endwhile
endif
return
mcmd
endfunction
" Update the taglist menu
with
the tags
for
the specified file
function! s:Tlist_Menu_File_Refresh(fidx)
call s:Tlist_Log_Msg(
'Refreshing the tag menu for '
. s:tlist_{a:fidx}_filename)
" The
'B'
flag is needed in the
'cpoptions'
option
let old_cpoptions =
&cpoptions
set cpoptions
&vim
exe s:tlist_{a:fidx}_menu_cmd
" Update the popup menu (
if
enabled)
if
&mousemodel
=~
'popup'
let cmd = substitute(s:tlist_{a:fidx}_menu_cmd,
' T\\&ags\.'
,
contrib/vim/taglist.vim view on Meta::CPAN
422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260
exe cmd
endif
" The taglist menu is not empty now
let s:tlist_menu_empty = 0
" Restore the
'cpoptions'
settings
let
&cpoptions
= old_cpoptions
endfunction
" Tlist_Menu_Update_File
" Add the taglist menu
function! s:Tlist_Menu_Update_File(clear_menu)
if
!
has
(
'gui_running'
)
" Not running in GUI mode
return
endif
call s:Tlist_Log_Msg(
'Updating the tag menu, clear_menu = '
. a:clear_menu)
" Remove the tags menu
if
a:clear_menu
call s:Tlist_Menu_Remove_File()
endif
" Skip buffers
with
'https://metacpan.org/pod/buftype">buftype'
set to nofile, nowrite, quickfix or help
if
&buftype
!=
''
return
endif
let filename = fnamemodify(bufname(
'%'
),
':p'
)
let ftype =
&filetype
contrib/vim/taglist.vim view on Meta::CPAN
42844285428642874288428942904291429242934294429542964297429842994300430143024303
exe
'anoremenu T&ags.'
. fname .
' <Nop>'
anoremenu T
&ags
.-SEP2- :
endif
if
!s:tlist_{fidx}_tag_count
return
endif
if
s:tlist_{fidx}_menu_cmd !=
''
" Update the menu
with
the cached command
call s:Tlist_Menu_File_Refresh(fidx)
return
endif
" We are going to add entries to the tags menu, so the menu won't be
" empty
let s:tlist_menu_empty = 0
let cmd =
''
contrib/vim/taglist.vim view on Meta::CPAN
4311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392
let ttype = s:tlist_{ftype}_{i}_name
if
s:tlist_{fidx}_{ttype}_count
let add_ttype_name = add_ttype_name + 1
endif
let i = i + 1
endwhile
" Process the tags by the tag type and get the menu command
let i = 1
while
i <= s:tlist_{ftype}_count
let mcmd = s:Tlist_Menu_Get_Tag_Type_Cmd(fidx, ftype, add_ttype_name, i)
if
mcmd !=
''
let cmd = cmd . mcmd
endif
let i = i + 1
endwhile
" Cache the menu command
for
reuse
let s:tlist_{fidx}_menu_cmd = cmd
" Update the menu
call s:Tlist_Menu_File_Refresh(fidx)
endfunction
" Tlist_Menu_Remove_File
" Remove the tags displayed in the tags menu
function! s:Tlist_Menu_Remove_File()
if
!
has
(
'gui_running'
) || s:tlist_menu_empty
return
endif
call s:Tlist_Log_Msg(
'Removing the tags menu for a file'
)
" Cleanup the Tags menu
silent! unmenu T
&ags
if
&mousemodel
=~
'popup'
silent! unmenu PopUp.T
&ags
endif
" Add a dummy menu item to retain teared off menu
noremenu T
&ags
.Dummy l
silent! unmenu! T
&ags
if
&mousemodel
=~
'popup'
silent! unmenu! PopUp.T
&ags
endif
call s:Tlist_Menu_Add_Base_Menu()
" Remove the dummy menu item
unmenu T
&ags
.Dummy
let s:tlist_menu_empty = 1
endfunction
" Tlist_Menu_Refresh
" Refresh the taglist menu
function! s:Tlist_Menu_Refresh()
call s:Tlist_Log_Msg(
'Refreshing the tags menu'
)
let fidx = s:Tlist_Get_File_Index(fnamemodify(bufname(
'%'
),
':p'
))
if
fidx != -1
" Invalidate the cached menu command
let s:tlist_{fidx}_menu_cmd =
''
endif
" Update the taglist, menu and window
call s:Tlist_Update_Current_File()
endfunction
" Tlist_Menu_Jump_To_Tag
" Jump to the selected tag
function! s:Tlist_Menu_Jump_To_Tag(tidx)
let fidx = s:Tlist_Get_File_Index(fnamemodify(bufname(
'%'
),
':p'
))
if
fidx == -1
return
endif
let tagpat = s:Tlist_Get_Tag_SearchPat(fidx, a:tidx)
if
tagpat ==
''
return
endif
contrib/vim/taglist.vim view on Meta::CPAN
439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434
" Bring the line to the middle of the window
normal! z.
" If the line is inside a fold,
open
the fold
if
foldclosed(
'.'
) != -1
.foldopen
endif
endfunction
" Tlist_Menu_Init
" Initialize the taglist menu
function! s:Tlist_Menu_Init()
call s:Tlist_Menu_Add_Base_Menu()
" Automatically add the tags
defined
in the current file to the menu
augroup TagListMenuCmds
autocmd!
if
!g:Tlist_Process_File_Always
autocmd BufEnter * call s:Tlist_Refresh()
endif
autocmd BufLeave * call s:Tlist_Menu_Remove_File()
augroup end
call s:Tlist_Menu_Update_File(0)
endfunction
" Tlist_Vim_Session_Load
" Initialize the taglist window/buffer, which is created
when
loading
" a Vim session file.
function! s:Tlist_Vim_Session_Load()
call s:Tlist_Log_Msg(
'Tlist_Vim_Session_Load'
)
" Initialize the taglist window
call s:Tlist_Window_Init()