Neovim ã®ããã¼ãã¦ã£ã³ãã¦æ©è½ã使ã£ã¦ git-messenger.vim ãã¤ãããªããã
git-messenger.vim ã¯ï¼ã«ã¼ã½ã«ä¸ã®è¡ã®ã³ãããæ å ±ã表示ãã Vim ãã©ã°ã¤ã³ã§ãï¼
ä»æã®ããã¸ã§ã¯ãã®ã³ã¼ãã OSS ã®ã³ã¼ããèªãã§ããã¨ï¼ãªããããªã£ã¦ããã ããï¼ã¨æããã¨ãããããã¾ãï¼ã³ãããã¡ãã»ã¼ã¸ãã¾ã¨ãã«æ¸ãã¦ããããã¸ã§ã¯ãã§ã¯ï¼ãã®é¨åã®å¤æ´ãå ããã³ãããã¡ãã»ã¼ã¸ã«çãããããã¨ãããã®ã§ããï¼æ¯å git blame
ã§å¯¾è±¡ã®ã³ããããå¼ã£å¼µã£ã¦ã㦠git show
ã§èªãã®ã¯çµæ§å¤§å¤ã§ãï¼
git-messenger.vim ã§ã¯ï¼ãã®è² æ
ã軽æ¸ããããã«ï¼(1) ã«ã¼ã½ã«ãããè¡ã«ã³ãããæ
å ±ã git
ããå¼ã£å¼µã£ã¦ã㦠(2) è¯ãæãã«è¡¨ç¤ºãã ã¨ããæ©è½ãæä¾ãã¾ãï¼
ãã6å¹´ãåã«ã¤ãã£ããã©ã°ã¤ã³ãªã®ã§ããï¼Vim ã®å¶ç´ä¸ããã¤ãã®åé¡ãããï¼syohex ããã® Emacs port ã«æ¯ã¹ã¦è¯ããã®ã«ãªãã¾ããã§ããï¼Vim ã®ãã«ã¼ã³ï¼ãã¦ã¹ãä¸å®æéãããã¡ä¸ã«ç½®ãã¦ããã¨åºãããã¼ã«ãããï¼ã GUI ã«ãã対å¿ãã¦ããªãã®ã主ãªçç±ã§ããï¼
å æ¥ï¼Neovim ã«ããã¼ãã¦ã£ã³ãã¦æ©è½ãå ¥ãï¼CUI ã§ããã¼ã«ãããã®ãã㪠UI ãç°¡åã«ä½¿ããããã«ãªã£ãã®ã§ï¼git-messenger.vim ããã«ã¹ã¯ã©ããã§ã¤ãããªããã¾ããï¼Neovim ã®ããã¼ãã¦ã£ã³ãã¦ã«ã¤ãã¦ã¯å¾ã®ç« ã§ã¾ã¨ãã¾ããï¼
git-messenger.vim
ã¤ã³ã¹ãã¼ã«
ãã¹ã¦ Vim script ã§å®è£
ããã¦ããã®ã§ï¼ä»ã®ãã©ã°ã¤ã³ã¨åæ§ã« rhysd/git-messenger.vim
ãªãã¸ããªãã¤ã³ã¹ãã¼ã«ããã ã㧠OK ã§ãï¼ãã¨ãã¡ãã git
ã³ãã³ããè¦ãã¾ãï¼
ã³ãã³ãã®å®è¡ã¯ä»¥å㯠system()
ã使ã£ã¦ããã®ã§ããï¼å¤§ãããªãã¸ããªã§ãã¦ã¼ã¶ã®å
¥åããããã¯ããªãããã« job ã使ã£ã¦æ¸ãã¦ãã¾ãï¼ãªã®ã§ï¼Neovim ã¾ã㯠Vim (8 以éï¼ãå¿
è¦ã§ãï¼
ã¾ãï¼ããã¼ãã¦ã£ã³ãã¦ã¯æè¿ Neovim ã® master ã«å
¥ã£ãã¨ãããªã®ã§ã¾ã å®å®çã¨ãã¦ã¯ãªãªã¼ã¹ããã¦ãã¾ããï¼éçºçã® 0.4.0-dev ã使ãå¿
è¦ãããã¾ãï¼ä¾ãã° macOS ã§ããã° brew install neovim --HEAD
ã§å
¥ãã¾ãï¼
使ãæ¹
:GitMessenger
ãããã¯ããã©ã«ãã§ãããããã¦ãã <Leader>gm
ãå
¥åããã¨ï¼ã«ã¼ã½ã«ããã®ã³ãããæ
å ±ããããã¢ããã¦ã£ã³ãã¦ã§è¡¨ç¤ºããã¾ãï¼
- Commit hash
- Author, Committer
- Summary ï¼ã³ãããã¡ãã»ã¼ã¸ã®1è¡ç®ï¼
- Body ï¼ã³ãããã¡ãã»ã¼ã¸ã®2è¡ç®ä»¥éï¼
ãããã¢ããã¦ã£ã³ãã¦ã¯ Neovim 0.4.0 以éã§ã¯åè¿°ã®ããã¼ãã¦ã£ã³ãã¦ã§ï¼ãã以å¤ã§ã¯ãã¬ãã¥ã¼ã¦ã£ã³ãã¦ã§å®è£ ããã¦ãã¾ãï¼ãã®å¾ã«ã¼ã½ã«ãåããã¨ãããã¢ããã¯èªåã§éãã¾ãï¼
åºæ¬çã«ã¯ããã ãã§ããï¼ãããã¢ãããéãããã¨ã«ã«ã¼ã½ã«ãåããããã®ã¾ã¾ããä¸åº¦ :GitMessenger
ã³ãã³ãã <Leader>gm
ãå
¥åããã¨ãããã¢ããã¦ã£ã³ãã¦ã®ä¸ã«ã«ã¼ã½ã«ã移åã§ãã¾ãï¼ã³ãããã¡ãã»ã¼ã¸ãé·ããã¦å
¨é¨è¡¨ç¤ºã§ããªãã£ãæã®ã¹ã¯ãã¼ã«ãã¡ãã»ã¼ã¸ã®ã¯ãªãããã¼ãã¸ã®ã³ãã¼ãªã©ãã§ãã¾ãï¼
ã¦ã£ã³ãã¦å
ã§ã¯ããã¤ããã¼ã«ã«ãªãããã³ã°ãå®ç¾©ããã¦ããï¼o
ã§ããå¤ãã³ããããæç¹°ããã¨ãã§ãã¾ãï¼ç´è¿ã®ã³ãããã«ã»ããæ
å ±ãæ¸ãã¦ããã¨ã¯éããªãï¼ä¾ãã°ãã©ã¼ããã¿ã§ã®æ´å½¢ãæã¾ã£ããï¼å¥ã®ãªãã¡ã¯ã¿ãªã³ã°ãæã¾ã£ãããªã©ï¼ã®ã§ï¼ããããã¨ãã¯ããå¤ãã³ãããã®ã¡ãã»ã¼ã¸ã«ã»ããæ
å ±ããããã¨ãããã¾ãï¼ããã« O
ã§æ°ããã³ãããã«æ»ã£ããï¼q
ã§ã¦ã£ã³ãã¦ãéãããã§ãã¾ãï¼?
ã§ãã«ãï¼
ã«ã¹ã¿ãã¤ãº
- ããã©ã«ãã®ãããã³ã°
<Leader>gm
ãæ°ã«å ¥ããªãå ´åã¯g:git_messenger_no_default_mappings
ã«v:true
ãã»ãããã¦<Plug>(git-messenger)
ããããããã° OK ã§ã - ä»ã«ãããã¤ã
<Plug>
ããããå®ç¾©ããã¦ãã¾ã - ããã¤ãã®æåã¯ã°ãã¼ãã«å¤æ°ã§å¶å¾¡ã§ããããã«ãªã£ã¦ãã¾ã
- Neovim ã®ã¿ãããã¢ããã¦ã£ã³ãã¦å
ã®ãã¤ã©ã¤ããã«ã¹ã¿ãã¤ãºã§ãã¾ãï¼ããã©ã«ãã®è²åããã使ãã®ã«ã©ã¼ã¹ãã¼ã ã«åããªãã¨ãã¯èªåã§è²ãã«ã¹ã¿ãã¤ãºã§ãã¾ãï¼Neovim ã®ã¿ãªã®ã¯ã¦ã£ã³ãã¦ãã¼ã«ã«ã«ãã¤ã©ã¤ãè²ãå¤æ´ã§ãã
winhighlight
ã¨ãããªãã·ã§ã³ã Neovim ã ããæã£ã¦ããããã§ã
詳ããã¯ãªãã¸ããªã® README.md ã :help git-messenger
ã§ç¢ºèªã§ãã¾ãï¼
Neovim ã®ããã¼ãã¦ã£ã³ãã¦ã«ã¤ãã¦
Vim ã®ã¦ã£ã³ãã¦ã¯åå²ãããã¨ã§ã¿ã¤ã«åã«é ç½®ãããã¬ã¤ã¢ã¦ããã対å¿ãã¦ãããï¼ã¦ã£ã³ãã¦ãéãªããããªã¬ã¤ã¢ã¦ãã¯ï¼ç¡çç¢çãããã¡ãæ¸ãæãã¦ããã£ã½ãè¦ãããããªãã¨ãããªãéãï¼å®ç¾ã§ãã¾ããã§ããï¼
ãã㧠Neovim ã§ã¯ CSS ã® position: relative
ã position: absolute
ã®ããã«ä½ç½®åºæºã§ã¦ã£ã³ãã¦ã®éãªãã許ãã¦ã£ã³ãã¦ã¬ã¤ã¢ã¦ããå®è£
ãã¾ããï¼
ä½ãè¯ãã®ã
ãã®æ©è½ã®è¨è¨ã§ç¹ã«åªãã¦ããã¨æããç¹ã¯ï¼ã¬ã¤ã¢ã¦ã以å¤ã¯ã»ã¼å®å ¨ã«æ®éã® Vim ã®ã¦ã£ã³ãã¦ã¨åãã¨ããã§ãï¼
- CUI ã§ä½¿ãã
- ãã©ã°ã¤ã³éçºè ã¯ã¦ã£ã³ãã¦ã®éãæ¹ã ãåããã°ï¼ãã¨ã¯æ®éã® Vim ã®ã¦ã£ã³ãã¦ã¨åæ§ã«æ±ãã
- ã¦ã£ã³ãã¦å
ã®ã³ã³ãã³ãã¯æ®éã® Vim ã®ãããã¡ãªã®ã§ï¼
setline()
ãªã©ã§èªç±ã«è¿½å ã»å¤æ´ã»åé¤ã§ãã - filetype ãã»ãããããï¼èªç±ã«ãã¤ã©ã¤ãã§ãã
- ã¦ã£ã³ãã¦ãéã以å¤ã¯ãã«ã¼ã³ã®ãããªå°ç¨ã® API ãè¦ããªã
ãã®æ©è½ã«ããï¼ãã©ã°ã¤ã³éçºè ã¯ã¦ã£ã³ãã¦ã®ä¸ã«ãªã¼ãã¼ã¬ã¤ãããã㪠UI ãå¤ãªããã¯ãããã妥åãããã¨ãªãå®è£ ãããã¨ãã§ãã¾ãï¼ ã±ã£ã¨æãã¤ãã®ã¯
- è£å®ã¦ã£ã³ãã¦ã®èªä½
- ããã¥ã¡ã³ãæ å ±è¡¨ç¤ºãã¼ã«ããã
- fuzzy finder ã®é¸æã¦ã£ã³ãã¦ï¼VS Code ã®ãããªï¼
- ã¿ã¼ããã«è¡¨ç¤º
ãªã©ã«ä½¿ãããã§ãï¼
使ãæ¹
ããã¼ãã¦ã£ã³ãã¦ãéãã®ã«ã¯ nvim_open_win()
ï¼ãµã¤ãºãé
ç½®ãå¤ããã®ã«ã¯ nvim_win_set_config()
ã使ãã¾ãï¼
" éãã¦ã£ã³ãã¦ã®å¹ let width = 40 " éãã¦ã£ã³ãã¦ã®é«ã let height = 10 " ã¦ã£ã³ãã¦ãéãããã¨ï¼ã«ã¼ã½ã«ããã®ã¦ã£ã³ãã¦å ã«ç§»åããã let enter = v:true " ã«ã¼ã½ã«ã :wincmd ããã¦ã¹ã§ã¦ã£ã³ãã¦å ã«ç§»åã§ããã let focusable = v:true " ä½ã«å¯¾ãã¦ç¸å¯¾çã«ã¦ã£ã³ãã¦ã®é ç½®ä½ç½®ã決ããã " - "editor": ã¨ãã£ã¿ã®ã¹ã¯ãªã¼ã³ã«å¯¾ãã¦ï¼ã¹ã¯ãªã¼ã³ä¸ã®çµ¶å¯¾åº§æ¨ã§æå® " - "win": ç¾å¨ã®ã¦ã£ã³ãã¦ä½ç½®ã«å¯¾ãã¦ï¼ããã使ãå ´åã¯ãªãã·ã§ã³ã« 'win' ã¨ãããã¼ã§å¥é対象ã¦ã£ã³ãã¦ã®ã¦ã£ã³ã㦠ID ãæå®ãã " - "cursor": ã«ã¼ã½ã«ä½ç½®ã«å¯¾ã㦠let relative = 'cursor' " åºæºã¨ãªãã¦ã£ã³ãã¦ã®è§ãåé ã®ã©ãã«ããããæå®ãã¾ãï¼ããã©ã«ã "NW"ï¼ " - "NW": å·¦ä¸ " - "NE": å³ä¸ " - "SE": å³ä¸ " - "SW": å·¦ä¸ let anchor = 'NW' " 'relative' ã§æå®ããä½ç½®ã«å¯¾ããç¸å¯¾çãªãªãã»ãã let row = 1 let col = 0 " Neovim å ã§ã¯ãªãï¼GUI ããã³ãã¨ã³ãå´ã«ã¦ã£ã³ãã¦ãåºãããä¾é ¼ããã let external = v:false " ç¾å¨ã®ãããã¡ãããã¼ãã¦ã£ã³ãã¦ã§éã " ã«ã¼ã½ã«ã®ããä¸ã« 40x10 ã®ã¦ã£ã³ãã¦ãéããã let win_id = nvim_open_win(bufnr('%'), enter, { \ 'width': width, \ 'height': height, \ 'relative': relative, \ 'anchor': anchor, \ 'row': row, \ 'col': col, \ 'external': external, \}) " æ°ãããããã¡ãéããã enew " æ®éã« setline() ã使ã£ã¦ã³ã³ãã³ããã»ããããã call setline('.', ['hello', 'world!']) " filetype ãæå®ãã¦ãã¤ã©ã¤ããå®ç¾©ããã set filetype=ruby bufhidden=wipe nomodified buftype=nofile " ããã¼ãã¦ã£ã³ãã¦ãå¥ã®ãã¤ã©ã¤ãã§æç»ããã set winhighlight=Normal:MyNormal,NormalNC:MyNormalNC " nvim_win_set_config() ã§ã¦ã£ã³ãã¦ã®ã¬ã¤ã¢ã¦ããããç´ãã call nvim_win_set_config(win_id, { \ 'width': 60, \ 'height': 30, \ 'relative': 'editor', \ 'row': 10, \ 'col': 10, \})
ããã¼ãã¦ã£ã³ãã¦ã«ã¯ãã¼ãã¼ãç¡ãã®ã§ï¼ããã©ã«ãã®ã¾ã¾ã§ã¯ããã¼ãã¦ã£ã³ãã¦ã¨ä¸ã®ã¦ã£ã³ãã¦ã®å¢çããããã¾ããï¼ãªã®ã§ç¹ã«æå¾ã®æ¢åã®ã¦ã£ã³ãã¦ã¨å¥ã®ãã¤ã©ã¤ãã§èæ¯è²ãæç»ããã®ã¯éè¦ã§ãï¼ã¾ãï¼ããã¼ãã¦ã£ã³ãã¦å
ã§æ°ãããããã¡ãéããéã¯ã¦ã£ã³ãã¦ãéããã¨ä¸èº«ãèªåã§éæ¾ããããã bufhidden=wipe
ãæå®ãã¦ããã¾ãï¼
nvim_win_set_config()
ã§ã¦ã£ã³ãã¦ã®ã¬ã¤ã¢ã¦ãããããªãããã¨ãã§ããã®ã§ï¼ããã使ã£ã¦ã¦ã£ã³ãã¦ã®ãµã¤ãºå¤æ´ãä½ç½®å¤æ´ããã¾ãï¼
ã¡ãªã¿ã« row
ï¼col
ï¼width
ï¼height
ãã¨ãã£ã¿ã®ã¹ã¯ãªã¼ã³ããã¯ã¿åºãã¦ãã¾ã£ã¦ãã¨ã©ã¼ã«ãªãã¾ããï¼Neovim ã¯ãªãã¹ãã¦ã£ã³ãã¦ãã¹ã¯ãªã¼ã³å
ã«åããããã«æç»ãã¾ãï¼git-messenger.vim ã§ã¯ç¾å¨ã®ã«ã¼ã½ã«ä½ç½®ãããããã¢ãããåºãã®ã«ååãªå¹
ã»é«ãããããã確èªãï¼ã«ã¼ã½ã«ã®ä¸ä¸å·¦å³ã«ããã¼ãã¦ã£ã³ãã¦ãåºãåãã¾ãï¼