⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 taglist.vim

📁 给vim增加函数列表。Author: Yegappan Lakshmanan (yegappan AT yahoo DOT com) For Vim version 6.0 and above L
💻 VIM
📖 第 1 页 / 共 5 页
字号:
" user_request - User requested to remove the file from taglistfunction! s:Tlist_Remove_File(file_idx, user_request)    let fidx = a:file_idx    if fidx == -1        let fidx = s:Tlist_Window_Get_File_Index_By_Linenum(line('.'))        if fidx == -1            return        endif    endif    call s:Tlist_Log_Msg('Tlist_Remove_File (' .                \ s:tlist_{fidx}_filename . ', ' . a:user_request . ')')    let save_winnr = winnr()    let winnum = bufwinnr(g:TagList_title)    if winnum != -1        " Taglist window is open, remove the file from display        if save_winnr != winnum            let old_eventignore = &eventignore            set eventignore=all            exe winnum . 'wincmd w'        endif        call s:Tlist_Window_Remove_File_From_Display(fidx)        if save_winnr != winnum            exe save_winnr . 'wincmd w'            let &eventignore = old_eventignore        endif    endif    let fname = s:tlist_{fidx}_filename    if a:user_request        " As the user requested to remove the file from taglist,        " add it to the removed list        call s:Tlist_Update_Remove_List(fname, 1)    endif    " Remove the file name from the taglist list of filenames    let idx = stridx(s:tlist_file_names, fname . "\n")    let text_before = strpart(s:tlist_file_names, 0, idx)    let rem_text = strpart(s:tlist_file_names, idx)    let next_idx = stridx(rem_text, "\n")    let text_after = strpart(rem_text, next_idx + 1)    let s:tlist_file_names = text_before . text_after    call s:Tlist_Discard_FileInfo(fidx)    " Shift all the file variables by one index    let i = fidx + 1    while i < s:tlist_file_count        let j = i - 1        let s:tlist_{j}_filename = s:tlist_{i}_filename        let s:tlist_{j}_sort_type = s:tlist_{i}_sort_type        let s:tlist_{j}_filetype = s:tlist_{i}_filetype        let s:tlist_{j}_mtime = s:tlist_{i}_mtime        let s:tlist_{j}_start = s:tlist_{i}_start        let s:tlist_{j}_end = s:tlist_{i}_end        let s:tlist_{j}_valid = s:tlist_{i}_valid        let s:tlist_{j}_visible = s:tlist_{i}_visible        let s:tlist_{j}_tag_count = s:tlist_{i}_tag_count        let s:tlist_{j}_menu_cmd = s:tlist_{i}_menu_cmd        let k = 1        while k <= s:tlist_{j}_tag_count            let s:tlist_{j}_{k}_tag = s:tlist_{i}_{k}_tag            let s:tlist_{j}_{k}_tag_name = s:tlist_{i}_{k}_tag_name            let s:tlist_{j}_{k}_tag_type = s:Tlist_Get_Tag_Type_By_Tag(i, k)            let s:tlist_{j}_{k}_ttype_idx = s:tlist_{i}_{k}_ttype_idx            let s:tlist_{j}_{k}_tag_proto = s:Tlist_Get_Tag_Prototype(i, k)            let s:tlist_{j}_{k}_tag_searchpat = s:Tlist_Get_Tag_SearchPat(i, k)            let s:tlist_{j}_{k}_tag_linenum = s:Tlist_Get_Tag_Linenum(i, k)            let k = k + 1        endwhile        let ftype = s:tlist_{i}_filetype        let k = 1        while k <= s:tlist_{ftype}_count            let ttype = s:tlist_{ftype}_{k}_name            let s:tlist_{j}_{ttype} = s:tlist_{i}_{ttype}            let s:tlist_{j}_{ttype}_offset = s:tlist_{i}_{ttype}_offset            let s:tlist_{j}_{ttype}_count = s:tlist_{i}_{ttype}_count            if s:tlist_{j}_{ttype} != ''                let l = 1                while l <= s:tlist_{j}_{ttype}_count                    let s:tlist_{j}_{ttype}_{l} = s:tlist_{i}_{ttype}_{l}                    let l = l + 1                endwhile            endif            let k = k + 1        endwhile        " As the file and tag information is copied to the new index,        " discard the previous information        call s:Tlist_Discard_FileInfo(i)        let i = i + 1    endwhile    " Reduce the number of files displayed    let s:tlist_file_count = s:tlist_file_count - 1    if g:Tlist_Show_One_File        " If the tags for only one file is displayed and if we just        " now removed that file, then invalidate the current file idx        if s:tlist_cur_file_idx == fidx            let s:tlist_cur_file_idx = -1        endif    endifendfunction" Tlist_Window_Goto_Window" Goto the taglist windowfunction! s:Tlist_Window_Goto_Window()    let winnum = bufwinnr(g:TagList_title)    if winnum != -1        if winnr() != winnum            call s:Tlist_Exe_Cmd_No_Acmds(winnum . 'wincmd w')        endif    endifendfunction" Tlist_Window_Create" Create a new taglist window. If it is already open, jump to itfunction! s:Tlist_Window_Create()    call s:Tlist_Log_Msg('Tlist_Window_Create()')    " If the window is open, jump to it    let winnum = bufwinnr(g:TagList_title)    if winnum != -1        " Jump to the existing window        if winnr() != winnum            exe winnum . 'wincmd w'        endif        return    endif    " If used with winmanager don't open windows. Winmanager will handle    " the window/buffer management    if s:tlist_app_name == "winmanager"        return    endif    " Create a new window. If user prefers a horizontal window, then open    " a horizontally split window. Otherwise open a vertically split    " window    if g:Tlist_Use_Horiz_Window        " Open a horizontally split window        let win_dir = 'botright'        " Horizontal window height        let win_size = g:Tlist_WinHeight    else        if s:tlist_winsize_chgd == -1            " Open a vertically split window. Increase the window size, if            " needed, to accomodate the new window            if g:Tlist_Inc_Winwidth &&                        \ &columns < (80 + g:Tlist_WinWidth)                " Save the original window position                let s:tlist_pre_winx = getwinposx()                let s:tlist_pre_winy = getwinposy()                " one extra column is needed to include the vertical split                let &columns= &columns + g:Tlist_WinWidth + 1                let s:tlist_winsize_chgd = 1            else                let s:tlist_winsize_chgd = 0            endif        endif        if g:Tlist_Use_Right_Window            " Open the window at the rightmost place            let win_dir = 'botright vertical'        else            " Open the window at the leftmost place            let win_dir = 'topleft vertical'        endif        let win_size = g:Tlist_WinWidth    endif    " If the tag listing temporary buffer already exists, then reuse it.    " Otherwise create a new buffer    let bufnum = bufnr(g:TagList_title)    if bufnum == -1        " Create a new buffer        let wcmd = g:TagList_title    else        " Edit the existing buffer        let wcmd = '+buffer' . bufnum    endif    " Create the taglist window    exe 'silent! ' . win_dir . ' ' . win_size . 'split ' . wcmd    " Save the new window position    let s:tlist_winx = getwinposx()    let s:tlist_winy = getwinposy()    " Initialize the taglist window    call s:Tlist_Window_Init()endfunction" Tlist_Window_Zoom" Zoom (maximize/minimize) the taglist windowfunction! s:Tlist_Window_Zoom()    if s:tlist_win_maximized        " Restore the window back to the previous size        if g:Tlist_Use_Horiz_Window            exe 'resize ' . g:Tlist_WinHeight        else            exe 'vert resize ' . g:Tlist_WinWidth        endif        let s:tlist_win_maximized = 0    else        " Set the window size to the maximum possible without closing other        " windows        if g:Tlist_Use_Horiz_Window            resize        else            vert resize        endif        let s:tlist_win_maximized = 1    endifendfunction" Tlist_Ballon_Expr" When the mouse cursor is over a tag in the taglist window, display the" tag prototype (balloon)function! Tlist_Ballon_Expr()    " Get the file index    let fidx = s:Tlist_Window_Get_File_Index_By_Linenum(v:beval_lnum)    if fidx == -1        return ''    endif    " Get the tag output line for the current tag    let tidx = s:Tlist_Window_Get_Tag_Index(fidx, v:beval_lnum)    if tidx == 0        return ''    endif    " Get the tag search pattern and display it    return s:Tlist_Get_Tag_Prototype(fidx, tidx)endfunction" Tlist_Window_Check_Width" Check the width of the taglist window. For horizontally split windows, the" 'winfixheight' option is used to fix the height of the window. For" vertically split windows, Vim doesn't support the 'winfixwidth' option. So" need to handle window width changes from this function.function! s:Tlist_Window_Check_Width()    let tlist_winnr = bufwinnr(g:TagList_title)    if tlist_winnr == -1        return    endif    let width = winwidth(tlist_winnr)    if width != g:Tlist_WinWidth        call s:Tlist_Log_Msg("Tlist_Window_Check_Width: Changing window " .                    \ "width from " . width . " to " . g:Tlist_WinWidth)        let save_winnr = winnr()        if save_winnr != tlist_winnr            call s:Tlist_Exe_Cmd_No_Acmds(tlist_winnr . 'wincmd w')        endif        exe 'vert resize ' . g:Tlist_WinWidth        if save_winnr != tlist_winnr            call s:Tlist_Exe_Cmd_No_Acmds('wincmd p')        endif    endifendfunction" Tlist_Window_Exit_Only_Window" If the 'Tlist_Exit_OnlyWindow' option is set, then exit Vim if only the" taglist window is present.function! s:Tlist_Window_Exit_Only_Window()    " Before quitting Vim, delete the taglist buffer so that    " the '0 mark is correctly set to the previous buffer.    if v:version < 700	if winbufnr(2) == -1	    bdelete	    quit	endif    else	if winbufnr(2) == -1	    if tabpagenr('$') == 1		" Only one tag page is present		bdelete		quit	    else		" More than one tab page is present. Close only the current		" tab page		close	    endif	endif    endifendfunction" Tlist_Window_Init" Set the default options for the taglist windowfunction! s:Tlist_Window_Init()    call s:Tlist_Log_Msg('Tlist_Window_Init()')    " The 'readonly' option should not be set for the taglist buffer.    " If Vim is started as "view/gview" or if the ":view" command is    " used, then the 'readonly' option is set for all the buffers.    " Unset it for the taglist buffer    setlocal noreadonly    " Set the taglist buffer filetype to taglist    setlocal filetype=taglist    " Define taglist window element highlighting    syntax match TagListComment '^" .*'    syntax match TagListFileName '^[^" ].*$'    syntax match TagListTitle '^  \S.*$'    syntax match TagListTagScope  '\s\[.\{-\}\]$'    " Define the highlighting only if colors are supported    if has('gui_running') || &t_Co > 2        " Colors to highlight various taglist window elements        " If user defined highlighting group exists, then use them.        " Otherwise, use default highlight groups.        if hlexists('MyTagListTagName')            highlight link TagListTagName MyTagListTagName        else            highlight default link TagListTagName Search        endif        " Colors to highlight comments and titles        if hlexists('MyTagListComment')            highlight link TagListComment MyTagListComment        else            highlight clear TagListComment            highlight default link TagListComment Comment        endif        if hlexists('MyTagListTitle')            highlight link TagListTitle MyTagListTitle        else            highlight clear TagListTitle            highlight default link TagListTitle Title        endif        if hlexists('MyTagListFileName')            highlight link TagListFileName MyTagListFileName        else            highlight clear TagListFileName            highlight default TagListFileName guibg=Grey ctermbg=darkgray                        \ guifg=white ctermfg=white        endif        if hlexists('MyTagListTagScope')            highlight link TagListTagScope MyTagListTagScope        else            highlight clear TagListTagScope            highlight default link TagListTagScope Identifier        endif    else        highlight default TagListTagName term=reverse cterm=reverse    endif    " Folding related settings    setlocal foldenable    setlocal foldminlines=0    setlocal foldmethod=manual    setlocal foldlevel=9999    if g:Tlist_Enable_Fold_Column        setlocal foldcolumn=3    else        setlocal foldcolumn=0    endif    setlocal foldtext=v:folddashes.getline(v:foldstart)    if s:tlist_app_name != "winmanager"        " Mark buffer as scratch        silent! setlocal buftype=nofile        if s:tlist_app_name == "none"            silent! setlocal bufhidden=delete        endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -