-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvim_setup.rb
64 lines (53 loc) · 1.79 KB
/
vim_setup.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env ruby
require 'fileutils'
require 'open-uri'
PREFIX = 'https://raw.githubusercontent.com/htsign/my-vim-settings/master'.freeze
def fetch_and_write filename, subdirs = []
path = File.expand_path((['~'] + subdirs + [filename]).join '/')
open(path, 'w') do |f|
f.write URI.open("#{PREFIX}/#{filename}").read
end
end
fetch_and_write '.vimrc'
FileUtils.mkdir_p File.expand_path('~/.vim')
fetch_and_write 'keymap.vim', ['.vim']
fetch_and_write 'codeium.vim', ['.vim']
fetch_and_write 'easymotion.vim', ['.vim']
fetch_and_write 'ctrlp.vim', ['.vim']
Dir.chdir File.expand_path('~/.vim') do
EXT_PACKAGES = [
['vim-jp/vimdoc-ja'],
['neoclide/coc.nvim', 'release'],
['Exafunction/codeium.vim'],
['easymotion/vim-easymotion'],
['ctrlpvim/ctrlp.vim'],
['mattn/ctrlp-matchfuzzy'],
['itchyny/vim-cursorword'],
['kshenoy/vim-signature'],
['tpope/vim-surround'],
].freeze
FTPLUGIN_PACKAGES = [
['sheerun/vim-polyglot'],
['mechatroner/rainbow_csv'],
['MTDL9/vim-log-highlighting'],
['plasticboy/vim-markdown'],
].freeze
def install_packages packages, category
root = File.expand_path("~/.vim/pack/#{category}/start")
FileUtils.mkdir_p root
packages.each do |pkg, branch|
author, name = pkg.split('/')
dir = File.join root, name
if Dir.exist? dir
puts "\033[33mupdating #{author}/#{name}...\033[0m"
branch ||= `git -C #{dir} remote show origin`.match(/^\s*HEAD branch: (.+)$/) { $1 }
`git -C #{dir} fetch --prune`
`git -C #{dir} reset --hard origin/#{branch}`
else
`git -C #{root} clone #{branch ? "-b #{branch}" : ''} https://github.com/#{pkg}.git`
end
end
end
install_packages EXT_PACKAGES, 'extensions'
install_packages FTPLUGIN_PACKAGES, 'ftplugins'
end