Is is possible to detect keywords in the path of the current file open in vim and add a particular tag
file?
My project is mainly organized in src
, test
and external
blocks, but each of these blocks appear anywhere in the path, not necessarily at the beginning or at the end (otherwise this solution could work). That is, my project has this structure:
feature1/src
feature1/test
feature2/src
feature2/test
external/feature3
I can generate a separate tag
file for each src
, test
and external
block and then detect these three keywords in the path in vim with match(expand('%:p:h'), ...)
.
But how can I only load src
tag if I am at any path containing src
, and so forth for test
and external
? Command set tags+=...
adds them for all windows (buffers) and mixing them causes many name collisions.
Thanks in advance
Kind of
augroup example | au!
autocmd BufRead,BufNewFile */myproject/*
\ let &l:tags = &g:tags . ',' . TagForFile(expand("<amatch>"))
augroup end
Where writing the function TagForFile()
is upon you.