Class: Neovim::Plugin::DSL

Inherits:
BasicObject
Defined in:
lib/neovim/plugin/dsl.rb

Overview

The DSL exposed in Neovim.plugin blocks.

Instance Method Summary collapse

Constructor Details

#initialize(plugin) ⇒ DSL

Returns a new instance of DSL.



7
8
9
# File 'lib/neovim/plugin/dsl.rb', line 7

def initialize(plugin)
  @plugin = plugin
end

Instance Method Details

#autocmd(event, options = {}, &block) ⇒ Object

Register an nvim autocmd.

Parameters:

  • event (String)
  • options (Hash) (defaults to: {})
  • &block (Proc, nil)

Options Hash (options):

  • :pattern (String)
  • :eval (String)
  • :sync (Boolean) — default: false


51
52
53
# File 'lib/neovim/plugin/dsl.rb', line 51

def autocmd(event, options={}, &block)
  register_handler(:autocmd, event, options, block)
end

#command(name, options = {}, &block) ⇒ Object

Register an nvim command.

Parameters:

  • name (String)
  • options (Hash) (defaults to: {})
  • &block (Proc, nil)

Options Hash (options):

  • :nargs (Fixnum)
  • :count (Fixnum)
  • :eval (String)
  • :sync (Boolean) — default: false
  • :bang (Boolean)
  • :register (Boolean)
  • :complete (Boolean)
  • :range (String, Boolean)


25
26
27
# File 'lib/neovim/plugin/dsl.rb', line 25

def command(name, options={}, &block)
  register_handler(:command, name, options, block)
end

#function(name, options = {}, &block) ⇒ Object

Register an nvim function.

Parameters:

  • name (String)
  • options (Hash) (defaults to: {})
  • &block (Proc, nil)

Options Hash (options):

  • :eval (String)
  • :sync (Boolean) — default: false
  • :range (String, Boolean)


38
39
40
# File 'lib/neovim/plugin/dsl.rb', line 38

def function(name, options={}, &block)
  register_handler(:function, name, options, block)
end

#rpc(name, options = {}, &block) ⇒ Object

Register a top-level remote procedure call (RPC).

This can be used to directly expose an RPC call without a namespace. This is used primarily for exposing legacy ruby provider calls.

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :sync (Boolean) — default: false


61
62
63
64
65
66
67
# File 'lib/neovim/plugin/dsl.rb', line 61

def rpc(name, options={}, &block)
  sync = options.delete(:sync)

  @plugin.handlers.push(
    Handler.unqualified(name, sync, options, block)
  )
end