dotfiles

Configuration for the software I use.
git clone https://git.jaderune.net/jbauer/dotfiles
Log | Files | Refs | README | LICENSE

pycscope.vim (2756B)


      1 " Pycscope module for Gutentags
      2 
      3 if !has('cscope')
      4     throw "Can't enable the pycscope module for Gutentags, this Vim has ".
      5                 \"no support for cscope files."
      6 endif
      7 
      8 " Global Options {{{
      9 
     10 if !exists('g:gutentags_pycscope_executable')
     11     let g:gutentags_pycscope_executable = 'pycscope'
     12 endif
     13 
     14 if !exists('g:gutentags_pyscopefile')
     15     let g:gutentags_pyscopefile = 'pycscope.out'
     16 endif
     17 
     18 if !exists('g:gutentags_auto_add_pycscope')
     19     let g:gutentags_auto_add_pycscope = 1
     20 endif
     21 
     22 " }}}
     23 
     24 " Gutentags Module Interface {{{
     25 
     26 let s:runner_exe = gutentags#get_plat_file('update_pyscopedb')
     27 let s:unix_redir = (&shellredir =~# '%s') ? &shellredir : &shellredir . ' %s'
     28 let s:added_dbs = []
     29 
     30 function! gutentags#pycscope#init(project_root) abort
     31     let l:dbfile_path = gutentags#get_cachefile(
     32                 \a:project_root, g:gutentags_pyscopefile)
     33     let b:gutentags_files['pycscope'] = l:dbfile_path
     34 
     35     if g:gutentags_auto_add_pycscope && filereadable(l:dbfile_path)
     36         if index(s:added_dbs, l:dbfile_path) < 0
     37             call add(s:added_dbs, l:dbfile_path)
     38             silent! execute 'cs add ' . fnameescape(l:dbfile_path)
     39         endif
     40     endif
     41 endfunction
     42 
     43 function! gutentags#pycscope#generate(proj_dir, tags_file, gen_opts) abort
     44     let l:cmd = [s:runner_exe]
     45     let l:cmd += ['-e', g:gutentags_pycscope_executable]
     46     let l:cmd += ['-p', a:proj_dir]
     47     let l:cmd += ['-f', a:tags_file]
     48     let l:file_list_cmd =
     49         \ gutentags#get_project_file_list_cmd(a:proj_dir)
     50     if !empty(l:file_list_cmd)
     51         let l:cmd += ['-L', '"' . l:file_list_cmd . '"']
     52     endif
     53     let l:cmd = gutentags#make_args(l:cmd)
     54 
     55     call gutentags#trace("Running: " . string(l:cmd))
     56     call gutentags#trace("In:      " . getcwd())
     57     if !g:gutentags_fake
     58 		let l:job_opts = gutentags#build_default_job_options('pycscope')
     59         let l:job = gutentags#start_job(l:cmd, l:job_opts)
     60         call gutentags#add_job('pycscope', a:tags_file, l:job)
     61     else
     62         call gutentags#trace("(fake... not actually running)")
     63     endif
     64 endfunction
     65 
     66 function! gutentags#pycscope#on_job_exit(job, exit_val) abort
     67     let l:job_idx = gutentags#find_job_index_by_data('pycscope', a:job)
     68     let l:dbfile_path = gutentags#get_job_tags_file('pycscope', l:job_idx)
     69     call gutentags#remove_job('pycscope', l:job_idx)
     70 
     71     if a:exit_val == 0
     72         if index(s:added_dbs, l:dbfile_path) < 0
     73             call add(s:added_dbs, l:dbfile_path)
     74             silent! execute 'cs add ' . fnameescape(l:dbfile_path)
     75         else
     76             silent! execute 'cs reset'
     77         endif
     78     else
     79         call gutentags#warning(
     80                     \"gutentags: pycscope job failed, returned: ".
     81                     \string(a:exit_val))
     82     endif
     83 endfunction
     84 
     85 " }}}
     86