dotfiles-mirror/config/nvim/vim-graft/graft.rb
2025-10-06 04:02:59 +03:30

49 lines
1.4 KiB
Ruby

#!/usr/bin/env ruby
# Graft - Vim plugin management with ruby
# Copyright (C) 2025 Ahamed Rumi
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
require("./config.rb")
require("fileutils")
PL = CONFIG[:plugins]
RT = File.expand_path("#{CONFIG[:runtime]}/pack/graft/start")
# Create pack directory
if !Dir.exist?(RT)
FileUtils.mkdir_p(RT)
end
# Install plugins
PL.each do |plugin|
# Dynamic plugin link
link = plugin.include?("://") ? plugin : "https://github.com/#{plugin}"
# Base name of plugin
name = File.basename(link, ".git")
# Handle plugin already exists
if Dir.exist?("#{RT}/#{name}")
puts "Skipping #{name} (already installed)"
next
end
# install plugin
if system("git clone #{link} #{RT}/#{name} --depth=1")
puts("Done: install plugin #{link}")
else
puts("Fatal: failed to install plugin #{link}")
end
end