" File: cscope_quickfix.vim " Author: kino " Version: 0.1 " Last Modified: Dec. 18, 2003 " " Overview " -------- " " Usage " ----- " " Configuration " ------------- " if !exists("Cscope_OpenQuickfixWindow") let Cscope_OpenQuickfixWindow = 1 endif if !exists("Cscope_JumpError") let Cscope_JumpError = 1 endif " RunCscope() " Run the cscope command using the supplied option and pattern function! s:RunCscope(...) let usage = "Usage: Cscope {type} {pattern} [{file}]." let usage = usage . " {type} is [sgdctefi01234678]." if !exists("a:1") || !exists("a:2") echohl WarningMsg | echomsg usage | echohl None return endif let cscope_opt = a:1 let pattern = a:2 if cscope_opt == '0' || cscope_opt == 's' let cmd = "cscope -L -0 " . pattern elseif cscope_opt == '1' || cscope_opt == 'g' let cmd = "cscope -L -1 " . pattern elseif cscope_opt == '2' || cscope_opt == 'd' let cmd = "cscope -L -2 " . pattern elseif cscope_opt == '3' || cscope_opt == 'c' let cmd = "cscope -L -3 " . pattern elseif cscope_opt == '4' || cscope_opt == 't' let cmd = "cscope -L -4 " . pattern elseif cscope_opt == '6' || cscope_opt == 'e' let cmd = "cscope -L -6 " . pattern elseif cscope_opt == '7' || cscope_opt == 'f' let cmd = "cscope -L -7 " . pattern elseif cscope_opt == '8' || cscope_opt == 'i' let cmd = "cscope -L -8 " . pattern else echohl WarningMsg | echomsg usage | echohl None return endif if exists("a:3") let cmd = cmd . " " . a:3 endif let cmd_output = system(cmd) if cmd_output == "" echohl WarningMsg | \ echomsg "Error: Pattern " . pattern . " not found" | \ echohl None return endif let tmpfile = tempname() exe "redir! > " . tmpfile silent echon cmd_output redir END let old_efm = &efm set efm=%f\ %*[^\ ]\ %l\ %m exe "silent! cfile " . tmpfile let &efm = old_efm " Open the cscope output window if g:Cscope_OpenQuickfixWindow == 1 botright cwin endif " Jump to the first error if g:Cscope_JumpError == 1 cc endif call delete(tmpfile) endfunction " Define the set of Cscope commands command! -nargs=* Cscope call s:RunCscope() nmap s :Cscope s =expand("") nmap g :Cscope g =expand("") nmap d :Cscope d =expand("") =expand("%") nmap c :Cscope c =expand("") nmap t :Cscope t =expand("") nmap e :Cscope e =expand("") nmap f :Cscope f =expand("") nmap i :Cscope i ^=expand("")$ nmap s :split:Cscope s =expand("") nmap g :split:Cscope g =expand("") nmap d :split:Cscope d =expand("") =expand("%") nmap c :split:Cscope c =expand("") nmap t :split:Cscope t =expand("") nmap e :split:Cscope e =expand("") nmap f :split:Cscope f =expand("") nmap i :split:Cscope i ^=expand("")$ nmap s :vert split:Cscope s =expand("") nmap g :vert split:Cscope g =expand("") nmap d :vert split:Cscope d =expand("") =expand("%") nmap c :vert split:Cscope c =expand("") nmap t :vert split:Cscope t =expand("") nmap e :vert split:Cscope e =expand("") nmap f :vert split:Cscope f =expand("") nmap i :vert split:Cscope i ^=expand("")$