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.



9
10
11
# File 'lib/neovim/plugin/dsl.rb', line 9

def initialize(plugin)
  @plugin = plugin
end

Instance Method Details

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

Register an nvim autocmd. See :h autocmd.

Parameters:

  • event (String)

    The event type. See :h autocmd-events

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

    Autocmd options.

  • &block (Proc, nil)

    The body of the autocmd.

Options Hash (options):

  • :pattern (String)

    The buffer name pattern. See :h autocmd-patterns.

  • :eval (String)

    An nvim expression. Gets evaluated and passed as an argument to the block.



65
66
67
# File 'lib/neovim/plugin/dsl.rb', line 65

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

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

Register an nvim command. See :h command.

Parameters:

  • name (String)

    The name of the command.

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

    Command options.

  • &block (Proc, nil)

    The body of the command.

Options Hash (options):

  • :nargs (Integer)

    The number of arguments to accept. See :h command-nargs.

  • :range (String, Boolean)

    The range argument. See :h command-range.

  • :count (Integer)

    The default count argument. See :h command-count.

  • :bang (Boolean)

    Whether the command can take a ! modifier. See :h command-bang.

  • :register (Boolean)

    Whether the command can accept a register name. See :h command-register.

  • :complete (String)

    Set the completion attributes of the command. See :h command-completion.

  • :eval (String)

    An nvim expression. Gets evaluated and passed as an argument to the block.

  • :sync (Boolean) — default: false

    Whether nvim should receive the return value of the block.



35
36
37
# File 'lib/neovim/plugin/dsl.rb', line 35

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

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

Register an nvim function. See :h function.

Parameters:

  • name (String)

    The name of the function.

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

    Function options.

  • &block (Proc, nil)

    The body of the function.

Options Hash (options):

  • :range (String, Boolean)

    The range argument. See :h func-range.

  • :eval (String)

    An nvim expression. Gets evaluated and passed as an argument to the block.

  • :sync (Boolean) — default: false

    Whether nvim should receive the return value of the block.



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

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