Web Components 㨠Electron ã§ã¤ãã Neovim ããã³ãã¨ã³ãã®æªæ¥
ãã®è¨äºã¯ Vim Advent Calendar 2015 ã®20æ¥ç®ã®è¨äºã§ãï¼
ã¾ãã¯ãã¡ãã®ã¹ã¯ãªã¼ã³ã·ã§ãããã覧ãã ããï¼
ã¨ãã£ã¿ã® UI ãã«ã¼ã½ã«ç§»å㯠Vim ã£ã½ãã§ããï¼markdown ã©ã¤ããã¬ãã¥ã¼ãã«ã¼ã½ã«ä½ç½®ã§ã®ç»åãããã¢ããï¼çµã¿è¾¼ã¿ãã©ã¦ã¶ãªã©è¬ã® UI ãè¦ã¦åãã¾ãï¼æ¬è¨äºã§ã¯ããã«ã¤ãã¦ããã ã¢ããã§å¿ è¦ãªç¥èããé ã追ã£ã¦ç´¹ä»ãã¾ãï¼
é·ãâ¦â¦ä¸è¡ã§
- Neovim msgpack-rpc API ã使ã£ã¦
<canvas>
㨠Node.js API 㧠Neovim ããã³ãã¨ã³ããä½æã - Web Component ã¨ãã¦ã©ãã ã㦠HTML ã¢ããªã«ç°¡åã«çµã¿è¾¼ããããã«ããä¸ã§
- UI ãã©ã°ã¤ã³ãã¦ã§ãæè¡ã§æ§ç¯ã§ãã NyaoVim ã¨ãã Neovim GUI ã¨ãã£ã¿ã Electron 使ã£ã¦ã¤ãã£ã¦ã¾ãï¼
ç®æ¬¡
- Web Components ã¨ã¯
- Neovim ã® ããã³ãã¨ã³ãåã msgpack-rpc API
- Neovim ã® UI ã Web Component ã¨ãã¦ã©ãããã
- Electron ã¢ããªã«çµã¿è¾¼ãã§ã¿ãä¾
- UI æ¡å¼µå¯è½ãª Neovim ããã³ãã¨ã³ã NyaoVim
- å®è£ ã®çµç·¯
- ã¾ã¨ã
- ãã¾ã
Web Components ã¨ã¯
HTML æ¨æºã¨ã㦠Web Components ã¨ããæ°æ©è½ãçå®ããã¦ãã¾ãï¼
Custom Element, Template, Shadow DOM, HTML import ã¨ããã¤ãã®æ©è½ã«åããã¦ãã¾ããï¼<div></div>
ã¨ãã£ãæ
£ã親ããã è¦ç´ ã«å ãï¼<foo-bar></foo-bar>
ã¨ãã£ãã«ã¹ã¿ã è¦ç´ ãã¤ãããã¨ãã§ããããã«ãªãã¾ãï¼CSS ã¯æ¬æ¥ã°ãã¼ãã«ã§ããï¼ã«ã¹ã¿ã è¦ç´ å
ã§å®ç¾©ããã¦ãã CSS ã¯ã³ã³ãã¼ãã³ãå
ã®ã¿ã«é©ç¨ããå¤ã«æã¿åºãã¾ããï¼ã¾ãï¼å¾æ¥ã® DOM è¦ç´ ã®ããã«ããããã£ã対å¿ãã class ã«ã¡ã½ãããçãããããã¦ã«ã¹ã¿ãã¤ãºå¯è½ã«ãããã§ãã¾ãï¼
å
·ä½çãªã«ã¹ã¿ã è¦ç´ ã®ã¤ããæ¹ããã£ã¨æ£ãã説æãç¥ãããæ¹ã¯ä¸è¨ã® html5rocks ã®è¨äºãªã©ãå½¹ã«ç«ã¡ã¾ãï¼
Custom Elements; HTML ã«æ°ããè¦ç´ ãå®ç¾©ãã
ã¾ã ä»æ§ã fix ããã¦ããªãæ©è½ã§ããï¼Google ã® Polymer ãªã© Web Component ãã©ãããã¦ä½¿ããããããã©ã¤ãã©ãªããã§ã«ããã¤ãããï¼åå©ç¨å¯è½ãªã³ã³ãã¼ãã³ããæä¾ããã¦ãã¾ãï¼
Neovim ã® UI msgpack-rpc API
Neovim ã«ã¯ msgpack-rpc ã§å¼ã³åºãã API ãããï¼ãã©ã°ã¤ã³ãå¥ããã»ã¹ã§åãã㦠Neovim æ¬ä½ã¨éä¿¡ãã remote plugin ãªã©ã§ä½¿ããã¦ãã¾ãï¼ã¦ã£ã³ãã¦ã»ã¿ãã»ãããã¡ã®æ
å ±ãåéããã Neovim ã«æå®æååãå
¥åãããï¼ã³ãã³ããå®è¡ããã Vim script ã eval ãããè²ã
ã§ãã¾ããï¼ãã®ä¸ã«1㤠vim_ui_attach
ã¨ããç¹å¥ãªãã®ãããã¾ãï¼
vim_ui_attach
ãå¼ã¶ã¨ï¼ãã以é Neovim å´ããå¼ã³åºãå
å´ã®ããã»ã¹ã« UI ã®æç»ã¤ãã³ããéç¥ãããããã«ãªãã¾ãï¼ããããã®éç¥ã¯ã¤ãã³ãåã¨ãã®å¼æ°ãæã£ã¦ãã¾ãï¼
ã¤ãã³ãå | 説æ |
---|---|
put |
å¼æ°ã§æ¸¡ãããããã¹ããã«ã¼ã½ã«ä½ç½®ä»¥éã«æç»ãã |
cursor_goto |
å¼æ°ã§æå®ããã (line, col) ã«ã«ã¼ã½ã«ã移åãã |
highlight_set |
æç»ããæåãèæ¯ã®è²ãã»ãããã |
clear |
ç»é¢å ¨ä½ãã¯ãªã¢ãã |
eol_clear |
ã«ã¼ã½ã«ä½ç½®ããè¡æ«ã¾ã§ã¯ãªã¢ãã |
scroll |
å¼æ°ã§ä¸ããããè¡æ°ã ã縦ã«ã¹ã¯ãã¼ã«ãã |
set_scroll_region |
ã¹ã¯ãã¼ã«ããç¯å²ãã»ãããã |
resize |
ç»é¢ã®ãµã¤ãºï¼è¡æ°ï¼æ¡æ°ï¼ãå¤æ´ãã |
update_fg |
foreground color ãå¼æ°ã§ä¸ããããè²ã«ã»ãããã |
update_bg |
background color ãå¼æ°ã§ä¸ããããè²ã«ã»ãããã |
mode_change |
ç¾å¨ã®ã¢ã¼ããå¼æ°ã§æå®ãããã¢ã¼ãã«å¤æ´ããï¼normal, insert ãªã©ï¼ |
busy_start |
å ¥åãåãä»ããªãç¶æ ãéå§ãã |
busy_stop |
å ¥åãåãä»ããªãç¶æ ãçµäºãã |
mouse_on |
ãã¦ã¹ãæå¹ã«ãã |
mouse_off |
ãã¦ã¹ãç¡å¹ã«ãã |
bell |
ãã«é³ãé³´ãã |
visual_bell |
ãã¸ã¥ã¢ã«ãã«ã表示ãã |
set_title |
ã¦ã£ã³ãã¦ã¿ã¤ãã«ãå¼æ°ã§æå®ãããæååã«ã»ãããã |
set_icon |
ã¦ã£ã³ãã¦ã¢ã¤ã³ã³ãå¼æ°ã§æå®ããããã¹ã®ç»åã«ã»ãããã |
è¦ã¦ã®éãï¼ããªãã¹ãã¼ããã«ãªéç¥ãé£ãã§ããã®ã§ï¼ã«ã¼ã½ã«ä½ç½®ãªã©ã®ç¶æ ãä¿æãã¤ã¤æ¥ãã¤ãã³ããé çªã«å¦çãã¦æç»ãã¦ããã° Neovim ã®ç»é¢ãæç»ãããã¨ãã§ãã¾ãï¼
Neovim ã§ã¯ nvim --embed
ã§èµ·åãããã¨ã§ãããã¬ã¹ã§å®è¡ãï¼ã¨ãã£ã¿ã®æç»ãå¥ã® UI ããã»ã¹ã«ä»»ããããã³ãã¨ã³ã-ããã¯ã¨ã³ãåã®ã¢ã¼ããã¯ãã£ããµãã¼ããã¦ãã¦ï¼ãã§ã« neovim-qt ã neovim-dot-app ãªã©ã® Neovim ããã³ãã¨ã³ããåå¨ãã¾ãï¼
Neovim ã® UI ã <canvas>
ã«æç»ã㦠WebComponent ã¨ãã¦ã©ãããã
ä¸è¨ã§èª¬æãã msgpack-rpc ãä»ãã UI æç»ã¤ãã³ãéç¥ã® API ã使ã£ã¦ HTML ã® <canvas>
ä¸ã« Neovim ã®ããã³ãã¨ã³ãé¨åãæç»ãï¼ããã Web Component ã¨ãã¦ã©ãããã¦ã¿ã¾ããï¼
HTML ä¸ã«æç»ããã¨ããé¸æãããã®ã¯ï¼è¿å¹´ NW.js ã Electron ã¨ãã£ããã¹ã¯ãããã¢ããªãã¬ã¼ã ã¯ã¼ã¯ãåºã¦ãã¦ãã¦ï¼å®¹æã« Neovim ã¨ãã£ã¿ããããã§ä½æããã¢ããªã«çµã¿è¾¼ããããã«ãªãããã§ãï¼ ã¾ãï¼WebSocket ãªã©ã§éä¿¡ãã¦æç»æ å ±ãåãåãã°ãªã¢ã¼ãã«ãã Neovim ãæå ã®ãã©ã¦ã¶ã«æç»ãã¦å¦çãããªã©ãå¯è½ã§ãï¼
ä»åã¯ãã¼ã«ã«ã§å®è¡ã§ããããã«ãããã®ã§ï¼å¤é¨ããã»ã¹ã¨ã㦠Neovim ãå®è¡ãæ¨æºå
¥åºåã§éä¿¡ãã¾ãï¼ãã©ã¦ã¶å
ã§ã¯å¤é¨ããã»ã¹ãèµ·ãããªãã®ã§ï¼Node.js ã® child_process
ã¢ã¸ã¥ã¼ã«ã§åããã»ã¹ã管çãã¾ãï¼ãã®ãã¨ããåããéãï¼ä»åã®ã¢ããã¼ãã§ã¯ä¸è¬çãªã¦ã§ããµã¼ãã¹ã«çµã¿è¾¼ããã¨ã¯ã§ãã¾ãããï¼Electron ã¢ããªãªã©ã® Node.js ãçµ±åãããç°å¢ã§ã¯å©ç¨ã§ãã¾ãï¼
ã¦ã¼ã¶ããã®å ¥åã Neovim ããã»ã¹ããã®éç¥ãªã©ã®ãã¼ã¿ããã¼ããã¾ãæ±ãã¤ã¤ï¼ã«ã¼ã½ã«ä½ç½®ãªã©ã®ç¶æ ãé©åã«æ´æ°ããããã« Flux ã¨ããã¢ã¼ããã¯ãã£ã使ãã¾ãï¼
(https://facebook.github.io/flux/docs/overview.html#content ããå¼ç¨)
ã¦ã¼ã¶ããã®å ¥åã Neovim ããã»ã¹ããã®ã¤ãã³ãéç¥ã¨ãã£ãç¶æ ãå¤æ´ããå¦çã Action ã¨ãã¦å®ç¾©ãï¼ãã£ã¹ãããã£ãéãã¦ã®ã¿ã¢ã¯ã·ã§ã³ãçºè¡ã§ããããã«ãã¾ãï¼çºè¡ãããã¢ã¯ã·ã§ã³ã¯ store ãå¤æ´ãï¼store ã listen ãã¦ãã view ã store ã®ç¶æ å¤æ´ãåãã¦æç»å¦çããã¾ãï¼ããã«ãã£ã¦ãã¼ã¿ã®æµããæ¹åãåæ¹åã«ãã¾ãï¼ ã¤ã¾ãï¼GUI ã§ã¯ãããã publisher / subscriber ãªå®è£ ãã¿ã¼ã³ã§ãï¼
ä»åã¯ãããªæãã«ãªãã¾ããï¼
ç·è²ã®é¨åã JavaScriptï¼å®éã«æ¸ããã®ã¯ TypeScript ã§ããï¼ã§æ¸ããã¦ãã¦ï¼view ãæç»ãã Screen
ï¼Neovim ããã»ã¹ã¨ããã¨ããã ProcessHandler
ï¼ããã¯åæ¹åã«ãªããããå¾ãªãï¼ï¼å¦çã«å¯¾å¿ãã Action
群ï¼ç¶æ
ãä¸æ¬ç®¡çãã Store
ã®ããããã®ã¯ã©ã¹ã§æ§æããã¦ãã¾ãï¼
ã¦ã¼ã¶ããã®å
¥å㯠Action ã¨ãã¦çºè¡ããï¼Store ãéãã¦ããã subscribe ãã¦ãã ProcessHandler ã«éããã¦æçµçã« Neovim ããã»ã¹ã«å±ãã¾ãï¼ã¾ãéã« Neovim ããã»ã¹ããã®éç¥ã¯ ProcessHandler ãä¸æ¦åããå¾ã¢ã¯ã·ã§ã³ã¨ãã¦çºè¡ããï¼Store ãéãã¦ããã subscribe ãã¦ãã Screen ãæç»æ
å ±ãåæ ãã¾ãï¼
Flux 㯠React.js ã¨ä¸ç·ã«èªããããã¨ãå¤ãã§ããï¼ç¹ã«ãããã£ãå¶ç´ã¯ç¡ãï¼ä»å㯠Screen
㯠<canvas>
ã« fillRect()
ã fillText()
ã¨ãã£ã canvas API ã§æç»ããã ãã®ãªãã¸ã§ã¯ãã§ãï¼ã¾ãï¼Store ã¯åä¸ã®ãã«ã¤ EventEmitter ã¨ãã¦å®è£
ããã¦ãã¾ãï¼
æçµçã«ä¸è¨ã®ã¯ã©ã¹ããã¹ã¦æã£ã editor
ãªãã¸ã§ã¯ãã®ããããã£ã«ä¸è¨ã¯ã©ã¹ã®ãªãã¸ã§ã¯ããå
¨ã¦æã£ã¦ï¼editor
ãªãã¸ã§ã¯ããéãã¦ãã¹ã¦ã®ãªãã¸ã§ã¯ãã«ã¢ã¯ã»ã¹ã§ããããã«ãã¦ããã¾ãï¼
å°ãä¸è¬ç㪠flux ãªã¦ã§ãã¢ããªã¨éãã®ã¯ï¼store ãã³ã³ãã¼ãã³ããã¼ã«ã«ãªã¨ããã§ããããï¼ããã¯ã³ã³ãã¼ãã³ããè¤æ°è¨ç½®ãããå¯è½æ§ãªã©ãèãã¦ãããªã£ã¦ãã¾ãï¼
ä»åã¯ãã® Neovim ããã³ãã¨ã³ãå®è£
ã Web Component ã¨ãã¦å®ç¾©ãããã®ã§ neovim-editor ã¨ãã Polymer element ãä½æ ãã¾ãï¼ã³ã³ãã¼ãã³ãã®ã«ã¹ã¿ãã¤ãºï¼e.g. Neovim ã«æ¸¡ãå¼æ°ï¼ã¯ã³ã³ãã¼ãã³ãã®ããããã£ã¨ãã¦è¨å®ã§ããããã«ãã¾ãï¼ä¸è¨ã® editor
ãªãã¸ã§ã¯ããã³ã³ãã¼ãã³ãã®ããããã£ã¨ãã¦æã¤ãã¨ã§ï¼<neovim-component>
è¦ç´ ãéã㦠Screen
, ProcessHandler
, Store
ã¨ãã£ããã¹ã¦ã®æ
å ±ã« JavaScript çµç±ã§ã¢ã¯ã»ã¹ã§ãã¾ãï¼
ãªãï¼è©¦ãã¦ãã¾ãããï¼ãããã Atom editor ã VisualStudio Code ã¨ãã£ã Electron ä¸ã«ã¤ããããã¨ãã£ã¿ã®ãã©ã°ã¤ã³ã¨ãã¦ã使ããã®ã§ã¯ãªããã¨æãã¾ãï¼ã¨ãã£ã¿ã®ä¸ã«ã¨ãã£ã¿ãçµè¾¼ãã®ãã©ããããå¬ãããã¯å¥åé¡ã§ããâ¦ï¼
Electron ã¢ããªã«çµã¿è¾¼ãã§ã¿ãä¾
ã¨ããããã§æ¬è¨äºåé ã§ãè¦ããã3æã®ã¹ã¯ãªã¼ã³ã·ã§ããã¯å
¨ã¦ <neovim-component>
ã«å¥ã®ã³ã³ãã¼ãã³ããçµã¿åãããä¾ã§ããï¼neovim-component ãªãã¸ã㪠ã§ã¯ããã¤ãã®ä¾ã Electron ã¢ããªã¨ãã¦å
¬éãã¦ãã¾ãï¼
https://github.com/rhysd/neovim-component/tree/master/example
- æå°éã® Electron ã¢ããª
- ã«ã¼ã½ã«ä¸ã®ãã¹ã®ç»åããããã¢ããã§è¡¨ç¤ºããæ¡å¼µ
- markdown ã¨ãã£ã¿
- ã¨ãã£ã¿çµã¿è¾¼ã¿ã®ã¢ãã¤ã«ãã©ã¦ã¶
å example ã®ãã£ã¬ã¯ããªå ã® README ã«å¾ãã°å®è¡ã§ããã¯ãã§ãï¼å example 㯠100ã300è¡ç¨åº¦ã§æ¸ããã¦ãã¾ãï¼
ä¾ãã° Neovim 㨠markdown ãã¬ãã¥ã¼ãåä½ããã markdown ã¨ãã£ã¿ã®ä¾ ã§ã¯ marked ã使ã£ã¦ã¤ãã£ã <markdown-viewer>
ã³ã³ãã¼ãã³ãï¼markdown ããã¹ããã»ãããã㨠HTML ã§æç»ãã¦ãããï¼ãä¸è¨ã®ããã«é
ç½®ãã¦ãã¾ãï¼
<body> <neovim-editor id="neovim" font="Ricty,monospace" width="800" height="1000"></neovim-editor> <markdown-viewer id="mdviewer"></markdown-viewer> </body>
ãã¨ã¯ Neovim å´ãã TextChanged
ããã³ TextChangedI
ã§ãããã¡ã®ããã¹ããå¤æ´ããããã³ã«ãããã¡ã®ããã¹ãã rpcnotify()
é¢æ°ã§éç¥ãï¼ãããåã㦠<markdown-viewer>
ã³ã³ãã¼ãã³ãã«ããã¹ãã渡ãå¦çã JavaScript ã§æ¸ãã¦ããã ãã§ãï¼ããã«ãã£ã¦å
¥åããªã¢ã«ã¿ã¤ã ã«ãã¬ãã¥ã¼ã«åæ ã§ãã¾ãï¼
ä¸è¨ã®ä¾ã§ã¯ï¼vim_command
msgpack-rpc API ã使ã£ã¦ç´æ¥ Neovim å´ã® autocmd ãå®ç¾©ãã¦ãã¾ãï¼
UI æ¡å¼µå¯è½ãª Neovim ããã³ãã¨ã³ã NyaoVim
å®ã¯ä»å㯠é«åº¦ã« UI æ¡å¼µå¯è½ãª Neovim ããã³ãã¨ã³ããã¤ãã ã®ãç®ç㧠neovim-component ã¯é£½ãã¾ã§ãããã¤ãããã¼ãã«éãã¾ããï¼
ã¨ããããã§ï¼Web Component ã使ã£ã¦ HTML, CSS, JavaScriptï¼Node.js, Electron APIï¼Neovim msgpack-rpc API ã使ã£ã¦ UI ãæ¡å¼µã§ãã Neovim ããã³ãã¨ã³ã NyaoVim ãã¤ãã£ã¦ãã¾ãï¼
Vim ãä½ã§ãªãã®ããæ¸ããã¦ãã :help design-not@ja
ã«ã¯æ¬¡ã®ãããªè¨è¿°ãããã¾ãï¼
Vim ãã·ã§ã«ã IDE ã®ã³ã³ãã¼ãã³ãã¨ãã¦ä½¿ãã
NyaoVim ã§ã¯ Neovim ããã³ãã¨ã³ãã1ã¤ã®ã³ã³ãã¼ãã³ãã¨ãã¦ï¼ã¢ããªå ã«è¤æ°ã® Web Component ãç½®ãï¼ä»ã® Web Component ã¨é£æºãã形㧠UI ãæ¡å¼µããä»çµã¿ãæä¾ãã¾ãï¼
NyaoVim ãç®æãã´ã¼ã«ã¯ä¸è¨ã®éãã§ãï¼
- NyaoVim æ¬ä½ã¯ï¼gVim ã®ãããªï¼æå°éã® Neovim ã® UI 㨠Web Component ã«ãã£ã¦ã¦ã¼ã¶ãèªç±ã« UI ãæ¡å¼µã§ããä»çµã¿ã®ã¿ãæä¾ãã¾ãï¼ã¦ã¼ã¶ã¯ããã使ã£ã¦èªåã®å¥½ããªã³ã³ãã¼ãã³ããä½æã»ã¤ã³ã¹ãã¼ã«ãã¦æ¡å¼µãã¾ãï¼
- UI æ¡å¼µã¯ Neovim ãã©ã°ã¤ã³ã¨ãã¦æä¾ã§ããããã«ãï¼æ°ããªãã©ã°ã¤ã³ããã¼ã¸ã£ãå¿ è¦ã¨ããªãããã«è¨è¨ãã¾ãï¼ããã«ãã£ã¦ vim-plug ãªã© Vim ãã©ã°ã¤ã³ããã¼ã¸ã£ã使ã£ã¦ UI ç¨ã®ãã©ã°ã¤ã³ã管çã§ãã¾ãï¼
- Neovimï¼ããã㯠Vimï¼æ¬æ¥ã®ã¨ãã£ã¿ã¨ãã¦ã®æ©è½æ§ï¼é«ãå¿çæ§ãªã©ï¼ãæãªããªãããã«å®è£ ãã¾ãï¼
- Linux, OS X, Windows 対å¿ã®ã¯ãã¹ãã©ãããã©ã¼ã ï¼ç¾æç¹ã§ã¯ Windows ããµãã¼ãã§ãã段éã«ã¾ã ãã¦ããªãã§ããâ¦ï¼
ãããã¦ã¿ã
NyaoVim ã¯ã¾ã ã¤ããã¯ããã段éã§ï¼ã¤ãä¸æ¨æ¥ UI ãã©ã°ã¤ã³ããã¼ãã§ããå®è£
ãå
¥ããã¨ããã§ãï¼<neovim-component>
ãå«ãã¦ã¾ã å®ç¨ã§ããã¬ãã«ã«ãªã£ã¦ãã¾ãããï¼version 0.0.2 ã¨ã㦠npm ããã±ã¼ã¸ã¨ãã¦å
¬éãã¦ãã¾ãï¼
$ npm install -g nyaovim $ nyaovim
å®è¡ããã¨ã·ã³ãã«ãª Neovim ã® GUI ã¨ãã£ã¿ãç«ã¡ä¸ããã¾ãï¼
ãµã³ãã«ãã©ã°ã¤ã³ã¨ã㦠nyaovim-popup-tooltip ãä½æããã®ã§ï¼ãããå ¥ãã¦ã¿ã¾ãããï¼
https://github.com/rhysd/nyaovim-popup-tooltip
UI ãã©ã°ã¤ã³ã¯ nyaovim-plugin
ã¨ãããã£ã¬ã¯ããªã runtimepath ã«å«ãã æ®éã® Neovim ãã©ã°ã¤ã³ãªã®ã§ï¼ä»ã®ãã©ã°ã¤ã³åæ§ã«ãã©ã°ã¤ã³ããã¼ã¸ã£ã§ã¤ã³ã¹ãã¼ã«ã§ãã¾ãï¼ä¾ãã° neobundle.vim ã使ãå ´åã¯ä¸è¨ã®ããã« init.vim
ã«æ¸ã㦠:NeoBundleInstall
ãã¾ãï¼
NeoBundle 'rhysd/nyaovim-popup-tooltip'
ä¸åº¦ã§ã nyaovim
ãå®è¡ãã¦ãã㨠~/.config/nyaovim/nyaovimrc.html
ãçæããã¦ããã¯ãã§ãï¼ãã®HTMLãã¡ã¤ã«ã NyaoVim ã®è¨å®ãã¡ã¤ã«ã§ãï¼nyaovim-popup-tooltip/nyaovim-plugin/popup-tooltip.html ã§æä¾ããã¦ãã <popup-tooltip>
ãä¸è¨ã®ããã«è¿½å ãã¾ãï¼
<dom-module id="nyaovim-app"> <template> <style> /* CSS configurations here */ </style> <!-- Component tags here --> <neovim-editor id="nyaovim-editor" argv$="[[argv]]" font-size="14" font="Ricty,monospace"></neovim-editor> <popup-tooltip editor="[[editor]]"></popup-tooltip> </template> </dom-module> <script src="file:///path/to/nyaovim-app.js"></script>
HTML ãã¡ã¤ã«ãè¨å®ãã¡ã¤ã«ã¨ãã¦ä½¿ããã¨ã§ï¼ã¦ã¼ã¶ã¯èªç±ã«ã¨ãã£ã¿å ã®ã³ã³ãã¼ãã³ãã CSS ã§ã¬ã¤ã¢ã¦ãã§ãï¼ã³ã³ãã¼ãã³ãã®ããããã£ã使ã£ã¦ã«ã¹ã¿ãã¤ãºãããã¨ãã§ãï¼è¿½å ã®å¦çã JavaScript ã§è¨è¿°ã§ãã¾ãï¼
ãã㧠editor="[[editor]]"
ã¨ããããããã£ãç®ãã²ãããããã¾ãããï¼ãã㯠Polymer ãæä¾ãã¦ãããã¼ã¿ãã¤ã³ãã£ã³ã°ã§ï¼<neovim-editor>
ã³ã³ãã¼ãã³ãã®ç´¹ä»æã«èª¬æãã editor
ãªãã¸ã§ã¯ãããã©ã°ã¤ã³å´ã«æ¸¡ã£ã¦ãã¦ãã¾ãï¼NyaoVim ã® UI ãã©ã°ã¤ã³ã¨ãã¦ã¯ Polymer ãå¿
é ã«ãã¦ããããã§ã¯ãªãã®ã§ï¼ããã§ã¯ãµã¼ãç¨åº¦ã«ã¹ã«ã¼ãã¦ãã ããï¼
æºåãã§ããã nyaovim
ã§ã¨ãã£ã¿ãç«ã¡ä¸ãã¦ä½ãããã¥ã¡ã³ããéãã¦ã¿ã¾ãããï¼http ãªã³ã¯ã§ããã¼ã«ã«ãã¡ã¤ã«ã¸ã®ãªã³ã¯ã§ãè¯ãã®ã§ï¼ç»åã¸ã®ãªã³ã¯ã®ä¸ã«ã«ã¼ã½ã«ãæã£ã¦è¡ã£ã¦ gi
ãå
¥åãã¦ã¿ã¦ãã ããï¼
å ¨ã¦ããã¾ããã£ã¦ããã°ä¸è¨ã®ããã«ãããã¢ããã§ã«ã¼ã½ã«ä¸ã®ç»åããã¬ãã¥ã¼ã§ãã¾ãï¼
NyaoVim ã® README ã«ã¯ UI ãã©ã°ã¤ã³ã®ä½ãæ¹ãï¼ãã£ããã¨ï¼æ¸ãã¾ãããï¼é·ããªããããã®ã§ããã§ã¯ç´¹ä»ãé¿ãã¾ãï¼æ°ã«ãªãæ¹ãããã£ãããã°ãªã³ã¯å ãèªãã§ã¿ã¦ãã ããï¼
å®è£ ã®çµç·¯
å ã Lime text ã CUI 㨠GUI ã®ä¸¡æ¹ããµãã¼ãããããã«ããã³ãã¨ã³ãï¼è¡¨ç¤ºå´ï¼ã¨ããã¯ã¨ã³ãï¼ã³ã¢ï¼ãå®å ¨ã«åããè¨è¨ããã¦ãã¦ããããã¢ã¼ããã¯ãã£ã«èå³ããã£ãã®ã§ï¼Neovim ã§ãä¼¼ããããªãã¨ãã§ããã¨ç¥ã調æ»ãå§ãã¾ããï¼
ä»å¹´ã¯ Electron ã¢ããªãã¤ãã£ãããã¦ããã®ã§ Electron ã§å®è£ ãããã¨ããã®ããã£ãã決ãã¦å ¬å¼ã® node client ã試ããã¨ãããã¾ãåããï¼API çã«ãã³ã¼ã«ããã¯ç¥ã«ãªã£ã¦ãã¾ãããã ã£ãã®ã§ã¾ã㯠node client ã fork ãã¾ããï¼
åçã«çæããã Neovim msgpack-rpc API åãã®ã¡ã½ãããã³ã¼ã«ããã¯ãã bluebird ã® Promise ãè¿ãããã«æ¸ãæãï¼TypeScript ããªãã¸ããªç´ä¸ã«ç½®ãã¦ãã index.d.ts
ãè¦ã¦ãããããã«ãªã£ãã®ã§ããã«å¯¾å¿ãï¼ããã¤ããã°ãä¿®æ£ãã¾ããï¼API ãã¬ã©ãã¨å¤ãã¦ãã¾ã£ãããï¼æ¬å®¶ã¸ã® PR ã¯ãªã¸ã§ã¯ããã㦠fork ã使ãç¶ãããã¨ã«ãã¾ããï¼
ããã§æºåãæ´ã£ãã®ã§ NyaoVim ã®ãããã¿ã¤ããæ¸ãå§ãã¾ããï¼æå㯠React 㨠Redux ã使ã£ã¦ DOM 㧠Neovim ã® UI ãæç»ãã¦ãã¾ããï¼React ã§æå°éã®ç¯å²ã ãå·®åæç»ããã°åé¡ãªãããªã¨æã£ã¦ããã®ã§ããï¼ä¾ãã° <C-e>
ãªã©ã§ç»é¢å
¨ä½ãã¹ã¯ãã¼ã«ããããã㨠DOM ãå
¨æ¸ãæãã«ãªã£ã¦ãã¾ãæç»ããã£ãããã¦ãã¾ãåé¡ã«å½ãã£ã¦ãã¾ãã¾ããï¼
ãã㧠react-canvas ã react-pixi ã使ãã¨ããæãããã¾ãããä»å¾ãã¡ã³ãããç¶ããããããªãæªããã£ãããï¼ç´ ç´ã« <canvas>
ã«ç´æ¥æç»ããããã«ã¹ã¯ã©ããããå®è£
ããªããã¾ããï¼
ãã®æã« Web Component ã¨ãã¦å®è£
ãã¦ä»ã® UI ã¨ãã¦çµã¿ç«ã¦ãã¨ããã¢ã¤ãã¢ãæãã¤ãï¼<neovim-editor>
ãå®è£
ããå¾ã¯ NyaoVim ã®ãããã¿ã¤ããå
¨ã¦æ¨ã¦ã¦æ°ããå®è£
ãã¾ããï¼ã¨ãããå®è£
ä¸ã§ãï¼ï¼
ã¾ã¨ã
Vim 㯠'Vim is a text editor' ã¨ãããã¬ã¼ãºã示ãããã«ç·¨éã«é¢ä¿ãªãæ©è½ãåãä»ããªãæ¹éã§éçºããã¦ããããï¼ã°ã©ãã£ã«ã«ãªè¡¨ç¾ã¯è¦æãªé¢ãããã¾ããï¼åããã®æ¹éã¯ã¨ã¦ãæ°ã«å ¥ã£ã¦ããã®ã§ããï¼ãã¯ãã°ã©ãã£ã«ã«ãªè£å©ãã»ãããªãã¨ããããã¾ãï¼ä¾ãã°ããã¥ã¡ã³ãã¨ãæè¿ã¯å¤§ä½ HTML ã§åºåããã¾ããï¼ï¼
ãããªããã§ä»åå㯠Web å¨ãã®æè¡ã使ã£ã¦ã¦ã¼ã¶ãèªç±ã«æ¡å¼µã§ãã UI ãã©ã°ã¤ã³æ©æ§ã neovim-component ãã¤ãã£ã¦ Neovim ããã³ãã¨ã³ã NyaoVim ãã¤ããã¾ããï¼HTML/CSS ã§ã¤ããã UI ãªãä½ã§ãã¤ããã¾ããï¼è¨å¤§ãª npm ããã±ã¼ã¸ã使ããã®ã§ï¼è¯ããã°ãã²æç¨ãªããã±ã¼ã¸ã¨ãæç¨ãããªãããã±ã¼ã¸ã¨ãã¤ãã£ã¦éãã§ã¿ã¦ãã ããï¼