unite.vim ã® action ã«ã¤ãã¦ç解ãã
ãã®è¨äºã¯ Vim Advent Calendar 2012 308æ¥ç®ã®è¨äºã«ãªãã¾ãã
ä»å㯠unite.vim ã® action ã«ã¤ãã¦ç°¡åã«èª¬æãã¦ã¿ãããã¨æãã¾ãã
[unite.vim ã® action ã¨ã¯]
action ã¨ã¯ãunite.vim ã§åºåãããåè£ã«å¯¾ãã¦å¦çãè¡ãçºã®æ©è½ã§ãã
åè£ãé¸ãã§ã
é常ãunite.vim ã¯é¸æããåè£ã«å¯¾ã㦠action ãå®è¡ããäºã§ãã®åè£ã«å¦çãè¡ãã¾ãã
ãã® action ã¯æ§ã
ãªå ´æã§ä½¿ç¨ããã¦ãã¾ãã
ä¾ãã°ãããã©ã«ãã® actionï¼åè£ãé¸æãã¦
" åè£ãé¸æã㦠<CR> ããã¨æ°ããã¿ããã¼ã¸ã§ãã¡ã¤ã«ãéã :Unite file -default-action=tabopen
ã®ããã« action ãæå®ãã¦æåãå¶å¾¡ããäºãã§ãã¾ãã
ä¸è¨ã®å ´å㯠"tabopen" ã action ã«å½ããã¾ãã
unite.vim ãããã©ã«ãã§ç¨æãã¦ãã action ã¯
:help unite-actions
ã§ç¢ºèªããäºãã§ãã¾ãã
[unite-kind ã«ã¤ãã¦]
action ã¯å¤§ããåã㦠unite-source 㨠unite-kind ã«å±ãã¾ãã
unite-source ã¯ãã®åã®éã unite-source ã«å±ãã action ã«ãªãã¾ãã
unite-source ãä½æããå ´åã«ãã® unite-source åºæã®æä½ãè¡ãã¨ãã«å®ç¾©ããäºãå¤ãã§ãã
ä¸æ¹ãunite-kind ã¯ãè¤æ°ã® action ã種é¡ãã¨ã«1ã¤ã«ã¾ã¨ãããã®ã«ãªãã¾ãã
ä¾ãã° kind-file ã¯ãã¡ã¤ã«æä½ã«é¢ãã actionï¼rename ã copyï¼ããããkind-buffer ã§ããã°ãããã¡ã«é¢ãã actionï¼delete ã openï¼ãããã¾ãã
â赤ãæ ã§å²ã¾ããé¨åã kind
ãã® unite-kind 㯠unite-source ãä½æããå ´åã«å©ç¨ã§ããåè£ã«å¯¾ã㦠kind ãè¨å®ãããã¨ã§ãã® kind ã® action ã使ç¨ããäºãã§ãã¾ãã
ä¾ãã°ãåè£ããã¡ã¤ã«ã§ããã° kind-file ãè¨å®ãããã¨ã§ rename ã copy ãªã©ã®ãã¡ã¤ã«é¢é£ã® action ãè¡ããã¨ãã§ããããã«ãªãã¾ãã
[action ãå®ç¾©ãã]
action ã¯ã¦ã¼ã¶ããã§ãå®ç¾©ãã¦ä½¿ç¨ããäºãã§ãã¾ãã
ã¨ãããäºã§ä¸è¨ã®ãµã¤ãã«ãæ¸ããã¦ãã :verbose ã unite-mapping ããå¼ã³åºã action ãå®ç¾©ãã¦ã¿ããã¨æãã¾ãã
let s:action = { \ 'description' : 'verbose', \ 'is_selectable' : 1, \} function! s:action.func(candidates) for candidate in a:candidates execute "verbose map" substitute(candidate.action__mapping, '\\\(<.*>\)', '\1', "g") endfor endfunction " kind ã§ã¯ãªã㦠source ã® mapping ã«å¯¾ã㦠action ãè¨å®ãã call unite#custom#action('source/mapping/*', 'verbose', s:action) " previewï¼pãã¼ï¼ã§ action ãå®è¡ãããå ´å㯠" call unite#custom#action('source/mapping/*', 'preview', s:action)
ãããªæã㧠unite-mapping ã« action ãè¨å®åºæ¥ã¾ããã
unite.vim 㯠action ã®ä½¿ãæ¹ãè¨å®æ¹æ³ãæ¡å¼µæ¹æ³ãªã©ãè¦ããã¨å¿ç¨ç¯å²ãã°ãã¨åºããã®ã§æ´»ç¨ãã¦ã¿ãã¨ããã¨æãã¾ãã