mirror of
https://github.com/gryf/tagbar.git
synced 2025-12-17 19:40:27 +01:00
Merge pull request #610 from majutsushi/no-cache
This commit is contained in:
@@ -1182,29 +1182,34 @@ function! s:ProcessFile(fname, ftype) abort
|
||||
|
||||
call tagbar#debug#log('typeinfo for file to process: ' . string(typeinfo))
|
||||
|
||||
" Use a temporary files for ctags processing instead of the original one.
|
||||
" This allows using Tagbar for files accessed with netrw, and also doesn't
|
||||
" slow down Tagbar for files that sit on slow network drives.
|
||||
let tempfile = tempname()
|
||||
let ext = fnamemodify(fileinfo.fpath, ':e')
|
||||
if ext !=# ''
|
||||
let tempfile .= '.' . ext
|
||||
endif
|
||||
if g:tagbar_use_cache
|
||||
" Use a temporary files for ctags processing instead of the original one.
|
||||
" This allows using Tagbar for files accessed with netrw, and also doesn't
|
||||
" slow down Tagbar for files that sit on slow network drives.
|
||||
let tempfile = tempname()
|
||||
let ext = fnamemodify(fileinfo.fpath, ':e')
|
||||
if ext !=# ''
|
||||
let tempfile .= '.' . ext
|
||||
endif
|
||||
|
||||
call tagbar#debug#log('Caching file into: ' . tempfile)
|
||||
let templines = getbufline(fileinfo.bufnr, 1, '$')
|
||||
let res = writefile(templines, tempfile)
|
||||
call tagbar#debug#log('Caching file into: ' . tempfile)
|
||||
let templines = getbufline(fileinfo.bufnr, 1, '$')
|
||||
let res = writefile(templines, tempfile)
|
||||
|
||||
if res != 0
|
||||
call tagbar#debug#log('Could not create copy '.tempfile)
|
||||
return
|
||||
endif
|
||||
let fileinfo.mtime = getftime(tempfile)
|
||||
if res != 0
|
||||
call tagbar#debug#log('Could not create copy '.tempfile)
|
||||
return
|
||||
endif
|
||||
let fileinfo.mtime = getftime(tempfile)
|
||||
|
||||
let ctags_output = s:ExecuteCtagsOnFile(tempfile, a:fname, typeinfo)
|
||||
let ctags_output = s:ExecuteCtagsOnFile(tempfile, a:fname, typeinfo)
|
||||
|
||||
if !tagbar#debug#enabled()
|
||||
call delete(tempfile)
|
||||
if !tagbar#debug#enabled()
|
||||
call delete(tempfile)
|
||||
endif
|
||||
else
|
||||
call tagbar#debug#log('File caching disabled')
|
||||
let ctags_output = s:ExecuteCtagsOnFile(a:fname, a:fname, typeinfo)
|
||||
endif
|
||||
|
||||
if ctags_output == -1
|
||||
@@ -1362,7 +1367,7 @@ function! s:ExecuteCtagsOnFile(fname, realfname, typeinfo) abort
|
||||
|
||||
let ctags_output = s:ExecuteCtags(ctags_cmd)
|
||||
|
||||
if v:shell_error || ctags_output =~? 'Warning: cannot open source file'
|
||||
if v:shell_error || ctags_output =~? 'Warning: cannot open \(source\|input\) file'
|
||||
call tagbar#debug#log('Command output:')
|
||||
call tagbar#debug#log(ctags_output)
|
||||
call tagbar#debug#log('Exit code: ' . v:shell_error)
|
||||
|
||||
@@ -784,6 +784,24 @@ about the tag is echoed out. Set this option to disable that behavior.
|
||||
Example:
|
||||
>
|
||||
let g:tagbar_silent = 1
|
||||
*g:tagbar_use_cache*
|
||||
g:tagbar_use_cache~
|
||||
Default: 1
|
||||
|
||||
By default the file contents are passed to ctags by writing them to
|
||||
a temporary file and invoking ctags on that file. This greatly speeds up tag
|
||||
generation in the event of slow file systems such as network shares and
|
||||
enables tagbar to run even on netrw virtual files that ctags would otherwise
|
||||
not be able to find at all. However it does incure the cost of an extra write
|
||||
operation. Additionally not all sysems are able to let programs share access
|
||||
to temporary file space (for example Snap packages cannot read from the host
|
||||
system's temp file space). This setting can disable the cache mechanism
|
||||
entriely forcing the tags to be generated from the existing copy of the file
|
||||
on disk rather than the current buffer written to a temporary file.
|
||||
|
||||
Example:
|
||||
>
|
||||
let g:tagbar_use_cache = 0
|
||||
<
|
||||
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
@@ -77,6 +77,7 @@ function! s:setup_options() abort
|
||||
\ ['width', 40],
|
||||
\ ['zoomwidth', 1],
|
||||
\ ['silent', 0],
|
||||
\ ['use_cache', 1],
|
||||
\ ]
|
||||
|
||||
for [opt, val] in options
|
||||
|
||||
Reference in New Issue
Block a user