?? taglist.vim
字號:
else " Do a binary search in the taglist let left = 0 let right = s:tlist_file_count - 1 while left < right let mid = (left + right) / 2 if a:lnum >= s:tlist_{mid}_start && a:lnum <= s:tlist_{mid}_end let s:tlist_file_lnum_idx_cache = mid return mid endif if a:lnum < s:tlist_{mid}_start let right = mid - 1 else let left = mid + 1 endif endwhile if left >= 0 && left < s:tlist_file_count \ && a:lnum >= s:tlist_{left}_start \ && a:lnum <= s:tlist_{left}_end let fidx = left endif endif let s:tlist_file_lnum_idx_cache = fidx return fidxendfunction" Tlist_Exe_Cmd_No_Acmds" Execute the specified Ex command after disabling autocommandsfunction! s:Tlist_Exe_Cmd_No_Acmds(cmd) let old_eventignore = &eventignore set eventignore=all exe a:cmd let &eventignore = old_eventignoreendfunction" Tlist_Skip_File()" Check whether tag listing is supported for the specified filefunction! s:Tlist_Skip_File(filename, ftype) " Skip buffers with no names and buffers with filetype not set if a:filename == '' || a:ftype == '' return 1 endif " Skip files which are not supported by exuberant ctags " First check whether default settings for this filetype are available. " If it is not available, then check whether user specified settings are " available. If both are not available, then don't list the tags for this " filetype let var = 's:tlist_def_' . a:ftype . '_settings' if !exists(var) let var = 'g:tlist_' . a:ftype . '_settings' if !exists(var) return 1 endif endif " Skip files which are not readable or files which are not yet stored " to the disk if !filereadable(a:filename) return 1 endif return 0endfunction" Tlist_User_Removed_File" Returns 1 if a file is removed by a user from the taglistfunction! s:Tlist_User_Removed_File(filename) return stridx(s:tlist_removed_flist, a:filename . "\n") != -1endfunction" Tlist_Update_Remove_List" Update the list of user removed files from the taglist" add == 1, add the file to the removed list" add == 0, delete the file from the removed listfunction! s:Tlist_Update_Remove_List(filename, add) if a:add let s:tlist_removed_flist = s:tlist_removed_flist . a:filename . "\n" else let idx = stridx(s:tlist_removed_flist, a:filename . "\n") let text_before = strpart(s:tlist_removed_flist, 0, idx) let rem_text = strpart(s:tlist_removed_flist, idx) let next_idx = stridx(rem_text, "\n") let text_after = strpart(rem_text, next_idx + 1) let s:tlist_removed_flist = text_before . text_after endifendfunction" Tlist_FileType_Init" Initialize the ctags arguments and tag variable for the specified" file typefunction! s:Tlist_FileType_Init(ftype) call s:Tlist_Log_Msg('Tlist_FileType_Init (' . a:ftype . ')') " If the user didn't specify any settings, then use the default " ctags args. Otherwise, use the settings specified by the user let var = 'g:tlist_' . a:ftype . '_settings' if exists(var) " User specified ctags arguments let settings = {var} . ';' else " Default ctags arguments let var = 's:tlist_def_' . a:ftype . '_settings' if !exists(var) " No default settings for this file type. This filetype is " not supported return 0 endif let settings = s:tlist_def_{a:ftype}_settings . ';' endif let msg = 'Taglist: Invalid ctags option setting - ' . settings " Format of the option that specifies the filetype and ctags arugments: " " <language_name>;flag1:name1;flag2:name2;flag3:name3 " " Extract the file type to pass to ctags. This may be different from the " file type detected by Vim let pos = stridx(settings, ';') if pos == -1 call s:Tlist_Warning_Msg(msg) return 0 endif let ctags_ftype = strpart(settings, 0, pos) if ctags_ftype == '' call s:Tlist_Warning_Msg(msg) return 0 endif " Make sure a valid filetype is supplied. If the user didn't specify a " valid filetype, then the ctags option settings may be treated as the " filetype if ctags_ftype =~ ':' call s:Tlist_Warning_Msg(msg) return 0 endif " Remove the file type from settings let settings = strpart(settings, pos + 1) if settings == '' call s:Tlist_Warning_Msg(msg) return 0 endif " Process all the specified ctags flags. The format is " flag1:name1;flag2:name2;flag3:name3 let ctags_flags = '' let cnt = 0 while settings != '' " Extract the flag let pos = stridx(settings, ':') if pos == -1 call s:Tlist_Warning_Msg(msg) return 0 endif let flag = strpart(settings, 0, pos) if flag == '' call s:Tlist_Warning_Msg(msg) return 0 endif " Remove the flag from settings let settings = strpart(settings, pos + 1) " Extract the tag type name let pos = stridx(settings, ';') if pos == -1 call s:Tlist_Warning_Msg(msg) return 0 endif let name = strpart(settings, 0, pos) if name == '' call s:Tlist_Warning_Msg(msg) return 0 endif let settings = strpart(settings, pos + 1) let cnt = cnt + 1 let s:tlist_{a:ftype}_{cnt}_name = flag let s:tlist_{a:ftype}_{cnt}_fullname = name let ctags_flags = ctags_flags . flag endwhile let s:tlist_{a:ftype}_ctags_args = '--language-force=' . ctags_ftype . \ ' --' . ctags_ftype . '-types=' . ctags_flags let s:tlist_{a:ftype}_count = cnt let s:tlist_{a:ftype}_ctags_flags = ctags_flags " Save the filetype name let s:tlist_ftype_{s:tlist_ftype_count}_name = a:ftype let s:tlist_ftype_count = s:tlist_ftype_count + 1 return 1endfunction" Tlist_Get_Filetype" Determine the filetype for the specified filefunction! s:Tlist_Get_Filetype(fname) " Ignore the filetype autocommands let old_eventignore = &eventignore set eventignore=FileType " Save the 'filetype', as this will be changed temporarily let old_filetype = &filetype " Run the filetypedetect group of autocommands to determine " the filetype exe 'doautocmd filetypedetect BufRead ' . a:fname " Save the detected filetype let ftype = &filetype " Restore the previous state let &filetype = old_filetype let &eventignore = old_eventignore return ftypeendfunction" Tlist_Get_Buffer_Filetype" Get the filetype for the specified bufferfunction! s:Tlist_Get_Buffer_Filetype(bnum) if bufloaded(a:bnum) " For loaded buffers, the 'filetype' is already determined return getbufvar(a:bnum, '&filetype') endif " For unloaded buffers, if the 'filetype' option is set, return it let ftype = getbufvar(a:bnum, '&filetype') if ftype != '' return ftype endif " Skip non-existent buffers if !bufexists(a:bnum) return '' endif " For buffers whose filetype is not yet determined, try to determine " the filetype let bname = bufname(a:bnum) return s:Tlist_Get_Filetype(bname)endfunction" Tlist_Discard_TagInfo" Discard the stored tag information for a filefunction! s:Tlist_Discard_TagInfo(fidx) call s:Tlist_Log_Msg('Tlist_Discard_TagInfo (' . \ s:tlist_{a:fidx}_filename . ')') let ftype = s:tlist_{a:fidx}_filetype " Discard information about the tags defined in the file let i = 1 while i <= s:tlist_{a:fidx}_tag_count let fidx_i = 's:tlist_' . a:fidx . '_' . i unlet! {fidx_i}_tag unlet! {fidx_i}_tag_name unlet! {fidx_i}_tag_type unlet! {fidx_i}_ttype_idx unlet! {fidx_i}_tag_proto unlet! {fidx_i}_tag_searchpat unlet! {fidx_i}_tag_linenum let i = i + 1 endwhile let s:tlist_{a:fidx}_tag_count = 0 " Discard information about tag type groups let i = 1 while i <= s:tlist_{ftype}_count let ttype = s:tlist_{ftype}_{i}_name if s:tlist_{a:fidx}_{ttype} != '' let fidx_ttype = 's:tlist_' . a:fidx . '_' . ttype let {fidx_ttype} = '' let {fidx_ttype}_offset = 0 let cnt = {fidx_ttype}_count let {fidx_ttype}_count = 0 let j = 1 while j <= cnt unlet! {fidx_ttype}_{j} let j = j + 1 endwhile endif let i = i + 1 endwhile " Discard the stored menu command also let s:tlist_{a:fidx}_menu_cmd = ''endfunction" Tlist_Window_Update_Line_Offsets" Update the line offsets for tags for files starting from start_idx" and displayed in the taglist window by the specified offsetfunction! s:Tlist_Window_Update_Line_Offsets(start_idx, increment, offset) let i = a:start_idx while i < s:tlist_file_count if s:tlist_{i}_visible " Update the start/end line number only if the file is visible if a:increment let s:tlist_{i}_start = s:tlist_{i}_start + a:offset let s:tlist_{i}_end = s:tlist_{i}_end + a:offset else let s:tlist_{i}_start = s:tlist_{i}_start - a:offset let s:tlist_{i}_end = s:tlist_{i}_end - a:offset endif endif let i = i + 1 endwhileendfunction" Tlist_Discard_FileInfo" Discard the stored information for a filefunction! s:Tlist_Discard_FileInfo(fidx) call s:Tlist_Log_Msg('Tlist_Discard_FileInfo (' . \ s:tlist_{a:fidx}_filename . ')') call s:Tlist_Discard_TagInfo(a:fidx) let ftype = s:tlist_{a:fidx}_filetype let i = 1 while i <= s:tlist_{ftype}_count let ttype = s:tlist_{ftype}_{i}_name unlet! s:tlist_{a:fidx}_{ttype} unlet! s:tlist_{a:fidx}_{ttype}_offset unlet! s:tlist_{a:fidx}_{ttype}_count let i = i + 1 endwhile unlet! s:tlist_{a:fidx}_filename unlet! s:tlist_{a:fidx}_sort_type unlet! s:tlist_{a:fidx}_filetype unlet! s:tlist_{a:fidx}_mtime unlet! s:tlist_{a:fidx}_start unlet! s:tlist_{a:fidx}_end unlet! s:tlist_{a:fidx}_valid unlet! s:tlist_{a:fidx}_visible unlet! s:tlist_{a:fidx}_tag_count unlet! s:tlist_{a:fidx}_menu_cmdendfunction" Tlist_Window_Remove_File_From_Display" Remove the specified file from displayfunction! s:Tlist_Window_Remove_File_From_Display(fidx) call s:Tlist_Log_Msg('Tlist_Window_Remove_File_From_Display (' . \ s:tlist_{a:fidx}_filename . ')') " If the file is not visible then no need to remove it if !s:tlist_{a:fidx}_visible return endif " Remove the tags displayed for the specified file from the window let start = s:tlist_{a:fidx}_start " Include the empty line after the last line also if g:Tlist_Compact_Format let end = s:tlist_{a:fidx}_end else let end = s:tlist_{a:fidx}_end + 1 endif setlocal modifiable exe 'silent! ' . start . ',' . end . 'delete _' setlocal nomodifiable " Correct the start and end line offsets for all the files following " this file, as the tags for this file are removed call s:Tlist_Window_Update_Line_Offsets(a:fidx + 1, 0, end - start + 1)endfunction" Tlist_Remove_File" Remove the file under the cursor or the specified file index
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -