Class: NvimConf::Writers::Code::Plugins::Packer

Inherits:
Object
  • Object
show all
Defined in:
lib/nvim_conf/writers/code/plugins/packer.rb

Constant Summary collapse

BOOTSTRAP_HEADER =
<<~BOOTSTRAP_HEADER
  local fn = vim.fn
  local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
  if fn.empty(fn.glob(install_path)) > 0 then
    packer_bootstrap = fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path})
  end\n
BOOTSTRAP_HEADER
BOOTSTRAP_TAIL =
<<~BOOTSTRAP_TAIL
  if packer_bootstrap then
      require('packer').sync()
    end
BOOTSTRAP_TAIL
BLOCK_START =
<<~START
  require('packer').startup(function(use)\n
START
BLOCK_END =
<<~END
  end)
END

Instance Method Summary collapse

Constructor Details

#initialize(manager, io, configuration) ⇒ Packer

Returns a new instance of Packer.



30
31
32
33
34
35
# File 'lib/nvim_conf/writers/code/plugins/packer.rb', line 30

def initialize(manager, io, configuration)
  @manager = manager
  @io = io
  @configuration = configuration
  @plugins = install_self(manager.plugins)
end

Instance Method Details

#writeObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/nvim_conf/writers/code/plugins/packer.rb', line 37

def write
  write_start_of_bootstrap
  @io.write(
    BLOCK_START
  )

  @plugins.each do |plugin|
    @io.write(
      "#{plugin_indent(@configuration[:generator].new(plugin).generate)}\n"
    )
  end

  write_tail_of_bootstrap

  @io.write(
    BLOCK_END
  )
end