Module: Rvim::Lua::Cmd
- Defined in:
- lib/rvim/lua/cmd.rb
Overview
vim.cmd(“…”): run an ex command, just like ‘:` from a Lua plugin. NeoVim also supports vim.cmd as a callable table where vim.cmd.echo(“hi”) works. v3.0 supports the call-as-function form; the dotted form is added in a later ship.
Class Method Summary collapse
Class Method Details
.install(state, editor, _runtime) ⇒ Object
12 13 14 15 16 |
# File 'lib/rvim/lua/cmd.rb', line 12 def install(state, editor, _runtime) state.function 'vim.cmd' do |arg| run(editor, arg) end end |
.run(editor, arg) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rvim/lua/cmd.rb', line 18 def run(editor, arg) line = arg.to_s return if line.empty? # Split on newlines so a Lua heredoc with multiple commands works. line.each_line do |single| single = single.chomp.strip next if single.empty? parsed = Rvim::Command.parse(single) Rvim::Command.execute(editor, parsed) if parsed end end |