[vim] plugin for cscope in python

This commit is contained in:
Mathieu Maret 2013-03-04 17:07:26 +01:00
parent 292f741bb1
commit 1de0397c71
2 changed files with 39 additions and 4 deletions

View File

@ -1,4 +1,4 @@
" This script is a wrapper for ctags and cscope, so tags for all languages " autotags plugin: a wrapper for ctags and cscope, so tags for all languages
" supported by ctags can be build (cscope is additionally used for C/C++). " supported by ctags can be build (cscope is additionally used for C/C++).
" Tags are stored in a separate directory and don't clog you project tree " Tags are stored in a separate directory and don't clog you project tree
@ -183,6 +183,12 @@ fun! s:AutotagsInit()
let g:autotags_cscope_exe = "cscope" let g:autotags_cscope_exe = "cscope"
endif endif
if !exists("g:autotags_pycscope_cmd")
let g:autotags_pycscope_pyt = "/soft/Python-2.7.3.i686/bin/python"
let g:autotags_pycscope_scr = "~/.vim/plugin/pycscope.py"
let g:autotags_pycscope_cmd = g:autotags_pycscope_pyt . " " . g:autotags_pycscope_scr
endif
if !exists("g:autotags_cscope_file_extensions") if !exists("g:autotags_cscope_file_extensions")
let g:autotags_cscope_file_extensions = ".cpp .cc .cxx .m .hpp .hh .h .hxx .c .idl .java" let g:autotags_cscope_file_extensions = ".cpp .cc .cxx .m .hpp .hh .h .hxx .c .idl .java"
endif endif
@ -344,6 +350,16 @@ fun! s:AutotagsGenerate(sourcedir, tagsdir)
\ "nice -15 " . g:autotags_cscope_exe . " -b -q -k") \ "nice -15 " . g:autotags_cscope_exe . " -b -q -k")
endif endif
endif endif
echomsg system("cd " . shellescape(l:cscopedir) . " && " .
\ " nice -15 find " . shellescape(a:sourcedir) .
\ " -not -regex '.*/\\..*' " .
\ " -not -regex '.*/\\%.*' " .
\ " -name '*.py' " .
\ " -fprint cscope_py.files")
if getfsize(l:cscopedir . "/cscope_py.files") > 0
echomsg system("cd " . shellescape(l:cscopedir) . " && " .
\ "nice -15 " . g:autotags_pycscope_cmd . " -i cscope_py.files -f cscope_py.out" )
endif
endfun endfun
fun! s:AutotagsReload(tagsdir) fun! s:AutotagsReload(tagsdir)
@ -381,6 +397,11 @@ fun! s:AutotagsLoad(tagsdir)
if filereadable(l:cscopedb) if filereadable(l:cscopedb)
exe "cs add " . l:cscopedb exe "cs add " . l:cscopedb
endif endif
let l:cscopepydb = a:tagsdir . "/cscope_py.out"
if filereadable(l:cscopepydb)
exe "cs add " . l:cscopepydb
endif
endfun endfun
fun! s:AutotagsIsLoaded() fun! s:AutotagsIsLoaded()

View File

@ -1,5 +1,5 @@
" " cscope keymaping plugin
" cscope (a tool to browse through C source files ) keymaping " (a tool to browse through C source files)
" "
" if compiled with --enable-cscope " if compiled with --enable-cscope
@ -9,6 +9,19 @@ if has("cscope")
endif endif
let g:loaded_cscope = 1.0 let g:loaded_cscope = 1.0
function! GoToDefinition()
try
execute "cscope find g " . expand("<cword>")
catch /:E259:/
try
execute "tag " . expand("<cword>")
catch /:E257:/
execute "normal! gd"
execute "nohlsearch"
endtry
endtry
endfunction
" use both cscope and ctag for 'ctrl-]', ':ta', and 'vim -t' " use both cscope and ctag for 'ctrl-]', ':ta', and 'vim -t'
set cscopetag set cscopetag
" use ctags before cscope " use ctags before cscope
@ -34,7 +47,8 @@ if has("cscope")
nmap <F5> :cscope find s <C-R>=expand("<cword>")<CR><CR> nmap <F5> :cscope find s <C-R>=expand("<cword>")<CR><CR>
nmap <S-F5> :scscope find s <C-R>=expand("<cword>")<CR><CR> nmap <S-F5> :scscope find s <C-R>=expand("<cword>")<CR><CR>
" go to definition with F6 and split with shift+F6 and use ctags with alt+shift+F6 " go to definition with F6 and split with shift+F6 and use ctags with alt+shift+F6
nmap <F6> :cscope find g <C-R>=expand("<cword>")<CR><CR> "nmap <F6> :cscope find g <C-R>=expand("<cword>")<CR><CR>
nmap <F6> :call GoToDefinition()<CR>
nmap <S-F6> :scscope find g <C-R>=expand("<cword>")<CR><CR> nmap <S-F6> :scscope find g <C-R>=expand("<cword>")<CR><CR>
nmap <M-S-F6> :tag <C-R>=expand("<cword>")<CR><CR> nmap <M-S-F6> :tag <C-R>=expand("<cword>")<CR><CR>
" go to calls with F7 and split with shift+F7 " go to calls with F7 and split with shift+F7