Class: Neovim::DslProvider

Inherits:
DslBase show all
Defined in:
lib/neovim/ruby_provider.rb

Constant Summary collapse

TYPE =
:script

Constants included from Logging

Logging::DEFAULT_LEVEL, Logging::LEVELS

Instance Method Summary collapse

Methods inherited from DslBase

#add_plugins, #initialize, open

Methods included from Logging

put

Constructor Details

This class inherits a constructor from Neovim::DslBase

Instance Method Details

#rpc(name) ⇒ Object



181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/neovim/ruby_provider.rb', line 181

def rpc name
  add_handler nil, name do |client,*args|
    WriteOut.redirect client do
      WriteErr.redirect client do
        yield client, *args
      end
    end
  rescue ScriptError, StandardError
    line = $@.first[ /:(\d+):/, 1]
    client.err_writeln "Ruby #$! (#{$!.class}), line #{line}"
  end
end

#setup(&block) ⇒ Object



166
167
168
# File 'lib/neovim/ruby_provider.rb', line 166

def setup &block
  add_setup_block &block
end

#setup_autocmd(event, fn, *args) ⇒ Object



170
171
172
173
174
175
# File 'lib/neovim/ruby_provider.rb', line 170

def setup_autocmd event, fn, *args
  add_setup_block do |client|
    a = [ client.channel_id, "'#{fn}'", *args].join ", "
    client.command "autocmd #{event} * call rpcrequest(#{a})"
  end
end

#updater(name, &block) ⇒ Object



177
178
179
# File 'lib/neovim/ruby_provider.rb', line 177

def updater name, &block
  add_handler nil, name, &block
end