tagsãã¡ã¤ã«ãä½æãããauto-ctags.vimãä½ã£ã
auto-ctags.vim
https://github.com/soramugi/auto-ctags.vim
çµç·¯
vimã§ã¿ã°ã¸ã£ã³ãããæã¯æåãããã®ã§ãããã¼ãã®ã³ã¼ãã£ã³ã°ã§ããã¥ã¡ã³ããç¡ãã¦ãã¿ã°ã¸ã£ã³ãã¨grepã§ããã°ã¾ããªãã¨ããªãã§ããã£ã¦ãªããã§ãã£ã¦ããã®ã§ããã
ã¿ã°ã¸ã£ã³ããããã¨ããæã«tagsã®ãã©ã¼ããããå´©ãã¦ãã¦ã¸ã£ã³ãããäºãåºæ¥ãªãã£ãããtagsãè¤æ°æ¤åºããã¦æ°ã«æã®tagsãªã¹ãã表示ããã¦ãããã©ãå ´æã¯åãã¨ãåããããªtagsãã¡ã¤ã«ãè¤æ°ä½ããã¦ãããã¨è»½ããã¬ã¼ãããããäºãæ°ã«ãããããã«ãªã£ã¦ãã¦ã¾ããã
以åã¾ã§ã®ç°å¢ã§ã¯tagsä½æã®vimãã©ã°ã¤ã³ãvim-tagsã使ç¨ãã¦tagsãã¡ã¤ã«ãä½æããããã«ãã¦ãã¾ããã
ä¿åããã°tagsãä½æãããã¨ãããã©ã®ã³ã
ãªã«ãè¨å®ã足ããªãã®ããªã¨ãã©ã°ã¤ã³ã®è¨è¿°ãèªãã§ããã¨ãªãã¨ãªã使ãã¥ããããªã¨æãããã¨ãããä½ç¹ãã
- ããã©ã«ãã®tagsä½æå ´æããã¼ã¸ã§ã³ç®¡çãã£ã¬ã¯ããªä¸
- æå®ããããã¹ã«tagsãä½æããã¦ããªãã¨èªåä½æã¯ãããªãã
- ctagsããã»ã¹ãå®è¡ä¸ã®æã«ããã«å®è¡ãããã¨tagsãã¡ã¤ã«ãå£ããå ´åã®åé¿ãããã¦ãªã
- ä½æããã¦ããtagsãä½ãç´ãã®ãvimããã¯åºæ¥ãªãã
ãã«ãªã¯éããã¨ãããã ãã©ããã©ã«ãå¤ãããããã®ãã ãªãã¨ããissueè¦ãã質åã¨ãã°ã£ãã ãããã¨ã½ã¼ã¹ã³ã¼ãèªã¿zrãã©ãããªãvimã®ãã¹ãã試ãã¦ã¿ãããªã¼
ã¨ãèãã¦ããé¢åããããªã£ã¦èªåã§ä½ã£ã¦ãã¾ãäºã«ã
ãªã®ã§READMEã«Polisyã¨ãæ¸ãã¦ã¾ãããã¡ãã¡issueã§ããããªå¤æ´ããããã©ããï¼ï¼ï¼ãã¨ã確èªã¨ãã®é¢åã ã(æ¸ãã¦ãããã°å
¨ç¶çãã¾ãã)ãããç¹å®ã®ç¸æã«åãã£ã¦èªåã®æè¦ãä¼ããã£ã¦ã®ãã©ããè¦æã§èª°ãããããããªã空éã«ã¨ããããæãã¦ç«ã¡å»ãã¨ããã¦ãã人ã§ããã¨ããããæ¸ãã¨ãã¦æå³æ±²ã¿åã£ã¦ããããã©ããã¼ã£ã¦ãªãã®ã§ãã
ç´æ¥çãªé¢ä¿ãããéæ¥çãªé¢ä¿ãä¸åº¦è¯ãã¨æããæãããªã¨æãæãã§æãã¦ã¾ãã
ãã¨ãããããã«ãªã¯éãããâ¡ããã«ãªã¯ããã£ãï¼ãªããã¤ã±ã¦ç¡ããã©æè§ã ããã¼ã¸ããã(ãªããèªåãä½ããããã®ã§ã¯ç¡ããªã£ããããªãã)ã
ã¦ã®ãããã¨æ¬å½ã«æ²ããã®ã§ãªãã¨ããã¹ãããããªã®ããã®ã解ããªããã©ãå¯è½æ§ã¯ããæ°ããããä»äººã®æè¦ãå°éããæ¥æ¬äººãªãã§ã¯ã¨ããããªã¤ã¡ã¼ã¸ã§ããé å¼µãæ¥æ¬äººï¼ãã¯ãé å¼µãã¾ãï¼
ã©ãã§ãããã§ããã
使ç¨æ¹æ³
ã¡ãªã¿ã«ãauto-ctags.vimãã¨ãæ¸ãã¦ã¾ããããã©ã«ãã§ã¯autoã§ã¯ç¡ãã§ããè¨èã£ã¦æ¬å½ã«é£ããã§ããã
ã¤ã³ã¹ãã¼ã«
ã¾ãã¯ctagsãã¤ã³ã¹ãã¼ã«ãã¦ããã¾ãã
mac
brew install ctags
debianç³»
sudo apt-get install exuberant-ctags
redhatç³»ã¯ãªããé©å½ã«ã
5.8ã¨ãæ°ããã®ctagsãå
¥ããäºããå§ããã¾ãã
windowsã¯å®è¡ç¢ºèªã§ãã¦ãªãã®ã§ããããã§ãã誰ã人æ±ã¼
ããã¦ã使ãã®ããã±ã¼ã¸ç®¡çãã©ã°ã¤ã³ã¨ãã§ããã¾ããèªåã¯NeoBundle
NeoBundle 'soramugi/auto-ctags.vim'
å®è¡
ããããã«tagsãä½æãããã«ã¬ã³ããã£ã¬ã¯ããªã«ç§»åãã¦vimãéãã¦ä»¥ä¸ã®ã³ãã³ããæã¡è¾¼ãã°
:Ctags
ã«ã¬ã³ããã£ã¬ã¯ããªç´ä¸ã«tagsãã¡ã¤ã«ãããä½æããã¦ããã¾ãã
`:Ctags`ã³ãã³ãã¯ä½æããã¦ããtagsãåé¤ãã¦ããä½ãç´ãã¾ãã
è¨å®
auto-ctags.vimã®autoæãæ¼åºãããæã«ã¯ä»¥ä¸ããã¡ã¤ã«ãä¿åãããæã«tagsãä½æããã¾ãã
let g:auto_ctags = 1
tagsãä½æãããã£ã¬ã¯ããªãæå®ãããæã«ã¯ä»¥ä¸ãæåã«ä¸è´ãããã¿ã¼ã³ã®ãã£ã¬ã¯ããªã«æ ¼ç´ããã¾ããä½æãããtagsã¯å¥éèªã¿åããããªè¨å®æ¸ãã¦ããã¦ãã ããã
let g:auto_ctags_directory_list = ['.git', '.svn']
ãã¨ã¯ctagsã®ãªãã·ã§ã³æå®ã ã£ãã
let g:auto_ctags_tags_args = '--tag-relative --recurse --sort=yes'
éãã¦ããã¡ã¤ã«ã¿ã¤ãå°ç¨ã®tagsãä½ã£ããã§ãã¾ãã`.rb`ãvimã§ã®ãã¡ã¤ã«ã¿ã¤ãã`ruby`ãéãã¦ãæã«ã¯`ruby.tags`ãä½æããã¾ããä½æãããtagsã¯å¥éèªã¿åããããªè¨å®æ¸ãã¦ããã¦ãã ããã
let g:auto_ctags_filetype_mode = 1
解説
ãã£ã¨èª¬æã¯ãããªãã®ã§ãã
å
é¨çã«ã¯`:Ctags`ãå®è¡ããã¨
- tagsåé¤
- tags.lockãç¡ãã確èª
- tags.lockä½æ
- ctagsã³ãã³ãå®è¡
- tags.lockåé¤
ã¦æµãã§ãã
ãã¹ã
ãã¨ã¯ä»åã®vimãã©ã°ã¤ã³ã«ã¯travis-ciã®ãã¹ããå®è¡ããã¦ãã¦ããã¹ããã¬ã¼ã ã¯ã¼ã¯ã«ã¯vimrunnerã使ã£ã¦ãã¾ãã
rubyã®rspecå½¢å¼ã§ãã¹ããè¨è¿°ã§ããã®ã§ãããã¦ããããã¹ãã¨ãããããæ©è½ãã¹ããªæãã§ãã£ãã°ããã«ããã®è¨å®ã§æå¾
ããçµæã«ãªã£ã¦ãããã¨ã確èªããã ãã§è¯ãæãã§ããã
ãã¼ã«ã«ã§ãã¹ãããã¹ããtravis-ciã§ã¯ãã¹ããªãã£ããã¨ãããã¾ããããããè¯å¥½ã
vimã®ãã¹ããã¬ã¼ã ã¯ã¼ã¯ã¨ãããã¾ãå®çãã¦ãªãã®ã§ãéçºã«åå ãã¦å®çãããã®ã楽ããã
ã¾ã¨ã
tagsã£ã¦é¢åããããããªãã§ããã
楽ããããããªãã§ããã
楽ãã¾ãããã