Clang ã使ç¨ããéåæ㧠C++ ã®ã³ã¼ãè£å®ãè¡ãVimãã©ã°ã¤ã³ãã¤ãã£ã
ãã®è¨äºã¯ Vim Advent Calendar 2012 316æ¥ç®ã®è¨äºã«ãªãã¾ãã
ã¡ãªã¿ã«ãã Twitter ã¨ãã§
ã2012å¹´ã¨2013å¹´ã® Vim Advent Calendar ã並走ããã®ãã
ã¿ãããªçºè¨ãè¦ããã¾ãã
Vim Advent Calendar 2012 ã¯11ææ«ã§çµäºãã¾ãã
ã§ãã®ã§ãåå ããããæ¹ã¯ä»ã®ãã¡ã«ç»é²ãã¦ããã¨ããã¨æãã¾ãã
- å ãã¿ï¼Vim で非同期で Clang を使用したコード補完を行う
以åãVim Advent Calendar 㧠Clang ã使ç¨ãã C++ ã®ã³ã¼ãè£å®ãè¡ãã¹ã¯ãªãããæ¸ããã®ã§ãããããããã©ã°ã¤ã³åãã¾ããã
åºæ¬çãªåä½ã¯ååã¨å¤ãããªããã§ãã以ä¸ã®ãããªéããããã¾ãã
- neocomplete.vim ã¨ä½µç¨ãã¦ä½¿ç¨å¯è½
- åä½ã§ãåä½å¯è½
- ç°¡åãªãã£ãã·ã³ã°å¦çã追å
- ç´åã®åè£ã§ããã°ããã«çµæã表示ããã¾ã
- å
¥åããã¯ã¼ãã§çµãè¾¼ã¿ãè¡ã
- å¦çä¸ã«ãã¼å ¥åãã§ããçµäºããæã«ãã®ã¯ã¼ãã§çµãè¾¼ã¿ãè¡ã
åä½ã§ã使ç¨ããäºã¯å¯è½ãªã®ã§ãããneocomplete.vim ã¨ä½µç¨ãã¦ä½¿ç¨ã§ããããã«ãã¾ããã
ãã¨ãéåæã§ã³ã¼ãè£å®ãè¡ããã¨ããã³ã³ã»ãããªã®ã§è£å®å¦çèªä½ã¯ clang_complete ãããé
ãã§ãã
[ãã©ã°ã¤ã³]
NeoBundle "Shougo/vimproc.vim" NeoBundle "osyo-manga/vim-reunions" NeoBundle "osyo-manga/vim-marching"
[使ãæ¹]
ãã®ãã©ã°ã¤ã³ã¯æåã§è£å®ãè¡ãã¾ãã
è£å®ãè¡ãããä½ç½®ã§ãªã ãè£å®ï¼
ãã®æã«è£å®å¦çãéåæã§è¡ããããããè£å®å¦çä¸ã§ãã£ã¦ããã¼å
¥åãè¡ããã¨ã¯å¯è½ã§ãã
ã¾ããè£å®é度ã«ãã£ã¦ã¯è£å®ã¦ã£ã³ãã¦ã表示ãããã¾ã§ã«æéããããå ´åãããã¾ãã
ãã㯠'updatetime' ãªãã·ã§ã³ã®å¤ã«ä¾åããçºã'updatetime' ã®è¨å®ã大ããå ´åã¯å¦çãçµäºãã¦ãã¦ã表示ãããã¾ã§ã«æéããããå¯è½æ§ãããã¾ãã
èªåè£å®ãè¡ãããå ´å㯠neocomplete.vim ã使ç¨ããå¿
è¦ãããã¾ãã
neocomplete.vim ã使ç¨ããå ´åã¯è¨å®ãå¿
è¦ã«ãªãã¾ãã
ä¸è¨ã®è¨å®ä¾ãåèã«ãã¦ä¸ããã
[è¨å®ä¾]
" clang ã³ãã³ãã®è¨å® let g:marching_clang_command = "C:/clang.exe" " ãªãã·ã§ã³ã追å ããå ´å let g:marching_clang_command_option="-std=c++1y" " ã¤ã³ã¯ã«ã¼ããã£ã¬ã¯ããªã®ãã¹ãè¨å® let g:marching_include_paths = [ \ "C:/MinGW/lib/gcc/mingw32/4.6.2/include/c++" \ "C:/cpp/boost" \] " neocomplete.vim ã¨ä½µç¨ãã¦ä½¿ç¨ããå ´å let g:marching_enable_neocomplete = 1 if !exists('g:neocomplete#force_omni_input_patterns') let g:neocomplete#force_omni_input_patterns = {} endif let g:neocomplete#force_omni_input_patterns.cpp = \ '[^.[:digit:] *\t]\%(\.\|->\)\w*\|\h\w*::\w*' " å¦çã®ã¿ã¤ãã³ã°ãå¶å¾¡ãã " ç°å¢ã«åããã¦ééãçããã " set updatetime=200 " ãªã ãè£å®æã«è£å®ã¯ã¼ããæ¿å ¥ããããªãå ´å imap <buffer> <C-x><C-o> <Plug>(marching_start_omni_complete)
['updatetime' ã«ä¾å]
ãã®ãã©ã°ã¤ã³ã¯ CursorHoldI æã«è£å®ã®çµäºã®ãã§ãã¯ãè¡ã£ã¦ãããã 'updatetime' ã®å¤ã«å¤§ããä¾åãã¾ãã
'updatetime' ã®å¤ã大ãããã°ããã ãçµäºããã§ãã¯ããééãé·ããªã£ã¦ãã¾ãã¾ãã
ã§ãã®ã§ããªãã¹ãå°ããå¤ã®æ¹ãè£å®é度ã¯æ©ãæãããã¾ãã
[è£å®ã¦ã£ã³ãã¦ã表示ããã¦ããå ´åã¯å¦çãããªã]
ãã㯠Vim ã®ä»æ§ã«ãªããã§ãããè£å®ã¦ã£ã³ãã¦ã表示ããã¦ããé㯠CursorHoldI ãå¼ã°ãã¾ããã
ãã®çºãè£å®å¦çã®å®äºãã§ãã¯ãè¡ãããªãã®ã§è£å®å¦çãçµäºãã¦ãã¦ãè£å®ã¦ã£ã³ãã¦ãæ´æ°ããããããªäºã¯ããã¾ããã
ãã㯠neocomplete.vim ã§èªåè£å®ã使ç¨ãã¦ããå ´åã«æ³¨æãå¿
è¦ã§ãã
[ãã£ãã·ã³ã°]
marching.vim ã§ã¯ç°¡åãªãã£ãã·ã³ã°ãè¡ã£ã¦ãã¾ãã
ç´åã®è£å®ã§ããã°ãã£ãã·ã³ã°ãå©ç¨ãã¦ããã«çµæã表示ããã¾ãã
ã¾ããç¾å¨ã¯ normal ã«æ»ãã¨ãã£ãã·ã³ã°ã¯åé¤ããã¾ãã
ãã®ãããã®å¦çã¯ä»å¾æ¹åãã¦ããäºå®ã§ãã
â»è¿½è¨
[clang_complete ã¨æ¯è¼ãã¦]
clang_complete ã¨æ¯ã¹ãã¨ä»¥ä¸ã®æ§ãªç¹å¾´ãéããããã¾ãã
- è£å®é度㯠clang_complete ãããé ã
- clang_complete ã¨ã¯éããã¼å
¥åãã¦ããéã§ãéåæã§è£å®å¦çãè¡ããã
- clang_complete ã®å ´åã¯ãã¼å ¥åããã£ãå ´åãè£å®å¦çã¯ä¸æããã¦ãã¾ããã
- marching.vim ã¯ãã¼å ¥åä¸ã§ãè£å®å¦çãè¡ããã
- if_python ã«ä¾åãã¦ããªã
- è£å®æã«è¡¨ç¤ºãããããã¹ãã貧弱
- å¼æ°ãªã©ã®è¡¨ç¤ºã¯ä»å¾è¿½å ãã¦ãããã
- C++ ã®ã¿ã«å¯¾å¿
è£å®é度㯠clang_complete ã®æ¹ãå§åçã«æ©ãã§ãã
ãã ããã£ãã·ã³ã°ãå¦çä¸ã«ãå
¥åå¯è½ãªã© clang_complete ã«ã¯ãªãæ©è½ãããã®ã§ä¸æ¦ã«ã©ã¡ããä¸ãªã®ãã¯ãããªãã¨æãã¾ãã
ã¨ãããæãã§ä½ã£ã¦ã¿ã¾ããã
ã¨ãããããæä½éã®æ©è½ã ãå®è£
ããã®ã§æ¬²ããæ©è½ãä¸å
·åãªã©ããã° Issues ã«æãã¦ããããã¨å©ããã¾ãã