0

I'm trying to run tags upon file save. But I can't get the current buffers name inside the function, I need this after the write, since I want ctags to process the new amendments. Ideally I want to pass the . argument into the function from the autocmd

 23 function! UpdateTagsIfHasTags()
 24     echom "adsfsdf"
 25     return
 26     let tagsPath = printf('%s/tags', expand("%:h"))
 27     if !empty(glob(tagsPath))
 28         system(printf('/usr/local/bin/phpctags %s', filepath))
 29     endif
 30 endfunction
 31 augroup tags
 32     autocmd!
 33     autocmd BufEnter *.tex silent! !start /min ctags *.tex
 34     autocmd BufEnter *.php :call UpdateTagsIfHasTags()
 35 augroup END

How can I pass the current file path to the function?

pepsi-maniac
  • 75
  • 1
  • 7

1 Answers1

0

You can get autocmd file name with special variables <afile> or <amatch>. See :h expand, :h <afile>, :h <amatch> for details.

function! Update()
  echom expand('<afile>')
  echom expand('<amatch>')
endfunction

autocmd BufEnter *.vim :call Update()
leaf
  • 1,624
  • 11
  • 16