Class: Neovim::Executable

Inherits:
Object show all
Defined in:
lib/neovim/executable.rb

Overview

Object representing the ‘nvim` executable.

Defined Under Namespace

Classes: Error

Constant Summary collapse

VERSION_PATTERN =
/\ANVIM v?(.+)$/

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Executable

Returns a new instance of Executable.



19
20
21
# File 'lib/neovim/executable.rb', line 19

def initialize(path)
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



17
18
19
# File 'lib/neovim/executable.rb', line 17

def path
  @path
end

Class Method Details

.from_env(env = ENV) ⇒ Executable

Load the current executable from the NVIM_EXECUTABLE environment variable.

Parameters:

  • env (Hash) (defaults to: ENV)

Returns:



13
14
15
# File 'lib/neovim/executable.rb', line 13

def self.from_env(env=ENV)
  new(env.fetch("NVIM_EXECUTABLE", "nvim"))
end

Instance Method Details

#versionString

Fetch the nvim version.

Returns:

  • (String)


26
27
28
29
30
31
32
# File 'lib/neovim/executable.rb', line 26

def version
  @version ||= IO.popen([@path, "--version"]) do |io|
    io.gets[VERSION_PATTERN, 1]
  end
rescue => e
  raise Error, "Couldn't load #{@path}: #{e}"
end