"==================================================================================== " Author: Evgeny V. Podjachev " " License: This program is free software: you can redistribute it and/or modify " it under the terms of the GNU General Public License as published by " the Free Software Foundation, either version 3 of the License, or " any later version. " " This program is distributed in the hope that it will be useful, " but WITHOUT ANY WARRANTY; without even the implied warranty of " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the " GNU General Public License for more details " (http://www.gnu.org/copyleft/gpl.txt). " " Description: This plugin is trying to make search in tags more convenient. " It holds query and search result in one buffer for faster jump to " desired tag. " " Installation: Just drop this file in your plugin directory. " " Usage: Command :YATE toggles visibility of search buffer. " Parameter g:YATE_window_height sets height of search buffer. " " To get list of matching tags set cursor on string containing expression " to search (in YATE buffer) then press or , never mind if " you are in normal or insert mode. " " To open tag location set cursor on string with desired tag and " press or double click left mouse button on this string, " never mind if you are in normal or insert nmode. " To open tag in new tab press , in new horizontal " splitted buffer , in new vertical splitted buffer " . " " Version: 0.9.1 " " ChangeLog: 0.9.1: Search string isn't cleared if there are no matched " tags. " Bug fixes. " " 0.9: First release " " TODO: Custom mapping; " Real-time autocomplit; "==================================================================================== if exists( "g:loaded_YATE" ) finish endif let g:loaded_YATE = 1 " Check to make sure the Vim version 700 or greater. if v:version < 700 echo "Sorry, YATE only runs with Vim 7.0 and greater" finish endif if !exists("g:YATE_window_height") let g:YATE_window_height = 15 endif command! -bang YATE :call ToggleTagExplorerBuffer() fun GotoTag(open_command) let str=getline(".") if !exists("s:tags_list") || !len(s:tags_list) || match(str,"^.*|.*|.*|.*$") call GenerateTagsList() return endif let index=str2nr(str) exe ':wincmd p' exe ':'.s:yate_winnr.'bd!' let s:yate_winnr=-1 if !&modified exe ':'.a:open_command.' '.s:tags_list[index]['filename'] exe substitute(s:tags_list[index]['cmd'],"\*","\\\\*","g") " Without it you should press Enter once again some times. exe 'normal Q' else throw "No write since last change." endif endfun fun AutoCompleteString(str) if !exists("s:tags_list") || !len(s:tags_list) return a:str endif let res=a:str " find shortest name let sname=9999 let shortestName="" for i in s:tags_list let l=strlen(i['name']) if lPrintTagsList() " clear buffer exe 'normal ggdG' if !exists("s:tags_list") return endif cal append(0,s:user_line) exe 'normal dd$' if !len(s:tags_list) return endif " find the longest names, kind, filename let lname=0 let lkind=0 for i in s:tags_list let lnm=strlen(i['name']) let lk=strlen(i['kind']) if lnm>lname let lname=lnm endif if lk>lkind let lkind=lk endif endfor let counter=0 for i in s:tags_list let str=counter."\t| ".i["name"] for j in range(strlen(i["name"]),lname) let str=str.' ' endfor let str=str.'| '.i["kind"] for j in range(strlen(i["kind"]),lkind) let str=str.' ' endfor let str=str.'| '.i["filename"] cal append(line("$"),str) let counter=counter+1 endfor endfun fun GenerateTagsList() " get tags list let s:user_line=getline('.') let s:tags_list=taglist(s:user_line) let s:user_line=AutoCompleteString(s:user_line) cal PrintTagsList() endfun fun! ToggleTagExplorerBuffer() if !exists("s:yate_winnr") || s:yate_winnr==-1 exe "bo".g:YATE_window_height."sp YATE" cal PrintTagsList() exe "verbose inoremap :cal GenerateTagsList()" exe "verbose inoremap :cal GotoTag('e')" exe "verbose noremap :cal GotoTag('e')" exe "verbose noremap <2-leftmouse> :cal GotoTag('e')" exe "verbose inoremap <2-leftmouse> :cal GotoTag('e')" exe "verbose inoremap :cal GotoTag('tabnew')" exe "verbose noremap :cal GotoTag('tabnew')" exe "verbose inoremap :cal GotoTag('sp')" exe "verbose noremap :cal GotoTag('sp')" exe "verbose inoremap :cal GotoTag('vs')" exe "verbose noremap :cal GotoTag('vs')" " color output syn match YATE_tag_kind # \w* # syn match YATE_tag_number #^\d*# syn region YATE_tag_name matchgroup=Macro start=/\t|/ end='|' syn region YATE_tag_filename matchgroup=Macro start='|' end=/$/ hi def link YATE_tag_name Identifier hi def link YATE_tag_number Number hi def link YATE_tag_kind Type hi def link YATE_tag_filename Directory let s:yate_winnr=bufnr("YATE") setlocal buftype=nofile else exe ':wincmd p' exe ':'.s:yate_winnr.'bd!' let s:yate_winnr=-1 endif endfun