view release on metacpan or search on metacpan
contrib/vim/taglist.vim view on Meta::CPAN
" 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
" 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
" 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
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
" 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
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
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
" 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 '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
" 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
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
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
" 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
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
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 '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
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
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
" 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()