Exuberant Ctags with R

前端 未结 6 822
北荒
北荒 2021-02-05 07:54

Is there any documented use of ctags with R? Would this be useful? Would it be difficult to implement?

Specifically, I\'ve just started using Vim. It would be cool to be

6条回答
  •  野性不改
    2021-02-05 08:22

    As mentioned by other rtags() + etags2ctags() can generate a tagsfile for vim (see :h tags-and-searches). You can create a custom command for vim so that it run rtags() in R using Rscript. To do so put this in your .vimrc:

    :command! Rtags :!Rscript -e 'rtags(path="./", recursive=TRUE, ofile="RTAGS")' -e 'etags2ctags("RTAGS", "rtags")' -e 'unlink("RTAGS")'
    set tags+=rtags
    

    Now when you do :Rtags vim will run the external process Rscript (it has to be in the PATH of course) and evaluate rtags(path="./", recursive=TRUE, ofile="RTAGS");etags2ctags("RTAGS", "rtags");unlink("RTAGS"). rtags() will generate an RTAGS file in Emacs tags format then etags2ctags() will transform that into an rtags file which vim can read. unlink() deletes the RTAGS file since it's not needed for vim.

    The set tags+=rtags makes vim to search for an rtags file in addition to the usual tags file (See :h tags-and-searches)

提交回复
热议问题