More Related Content Similar to VimとRubyのアツい関係 Similar to VimとRubyのアツい関係 (12) VimとRubyのアツい関係11. Vimの式を評価
let a = "foo"
let b = 42
ruby << EOF
p VIM.evaluate('a') #=> "foo"
p VIM.evaluate('b') #=> 42
p VIM.evaluate('getpos(".")') #=> [0, 43, 1, 0]
EOF
13. 応用:変数の受け渡し
func! Add(v0, v1)
ruby << EOF
v0 = VIM::evaluate('a:v0')
v1 = VIM::evaluate('a:v1')
VIM::command("let result = #{v0 + v1}")
EOF
return result
endfunc
echo Add(1, 2) “ 3
20. Ripper.lex
[[[1, 0], :on_ident, "puts"],
[[1, 4], :on_sp, " "],
[[1, 5], :on_tstring_beg, """],
[[1, 6], :on_tstring_content, "Hello,
World!"],
[[1, 19], :on_tstring_end, """],
[[1, 20], :on_nl, "n"]]
21. Ripper.sexp
[:program,
[[:command,
[:@ident, "puts", [1, 0]],
[:args_add_block,
[[:string_literal,
[:string_content, [:@tstring_content, "Hello,
World!", [1, 6]]]]],
false]]]]
25. 参考
● Vimプラグイン RubyJump v0.9.2をリリースした
○ http://www.xmisao.com/2014/05/16/rubyjump-released.html
● VimのRubyインタフェース入門
○ http://www.xmisao.com/2014/05/13/vim-ruby-interface.html
● Rubyの標準添付ライブラリripperでRubyのソースをパースする
○ http://www.xmisao.com/2014/05/12/ruby-ripper.html
● Rubyのバージョンとripperの関係
○ http://www.xmisao.com/2014/05/16/study-of-ruby-ripper.htm