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

#mkplugin, open

Methods included from Logging

put

Constructor Details

#initialize(source) ⇒ DslProvider

Returns a new instance of DslProvider.



58
59
60
# File 'lib/neovim/ruby_provider.rb', line 58

def initialize source
  super *[]
end

Instance Method Details

#rpc(name) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/neovim/ruby_provider.rb', line 77

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



62
63
64
# File 'lib/neovim/ruby_provider.rb', line 62

def setup &block
  add_setup_block &block
end

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



66
67
68
69
70
71
# File 'lib/neovim/ruby_provider.rb', line 66

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



73
74
75
# File 'lib/neovim/ruby_provider.rb', line 73

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