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 =
"local fn = vim.fn\nlocal install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'\nif fn.empty(fn.glob(install_path)) > 0 then\n  packer_bootstrap = fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path})\nend\\n\n"
BOOTSTRAP_TAIL =
"if packer_bootstrap then\n    require('packer').sync()\n  end\n"
BLOCK_START =
"require('packer').startup(function(use)\\n\n"
BLOCK_END =
"end)\n"

Instance Method Summary collapse

Constructor Details

#initialize(manager, io, configuration) ⇒ 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