vim: add .vim/bundle/vim-terraform
This commit is contained in:
parent
9837c9bea5
commit
91936cfde7
18 changed files with 1367 additions and 0 deletions
36
.vim/bundle/vim-terraform/update_data_sources.rb
Executable file
36
.vim/bundle/vim-terraform/update_data_sources.rb
Executable file
|
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
# Use this script to update the resources recognized in syntax/terraform.vim.
|
||||
# You'll need a current checkout of the Terraform source.
|
||||
|
||||
resource_declaration = /"(.*)":.*dataSource.*\(\),$/
|
||||
syntax_file = 'syntax/terraform.vim'
|
||||
|
||||
# Specify the location of the Terraform source as the only argument to this
|
||||
# script.
|
||||
raise 'Please specify the location of the Terraform source.' if ARGV.empty?
|
||||
|
||||
# Create the list of resources.
|
||||
provider_files = Dir.glob("#{ARGV[0]}/builtin/providers/*/*provider.go")
|
||||
resources = provider_files.collect do |f|
|
||||
File.open(f, 'r').readlines.collect do |l|
|
||||
match = resource_declaration.match(l)
|
||||
" \\ #{match[1]}\n" if match
|
||||
end.reject(&:nil?)
|
||||
end.flatten.sort.uniq
|
||||
|
||||
# Read in the existing syntax file.
|
||||
syntax = File.open(syntax_file, 'r').readlines
|
||||
|
||||
# Replace the terraResourceTypeBI lines with our new list.
|
||||
first = syntax.index { |l| /^syn keyword terraDataTypeBI/.match(l) } + 1
|
||||
last = syntax.index { |l| /^""" end data sources/.match(l) }
|
||||
syntax.slice!(first, last - first)
|
||||
resources.reverse_each do |r|
|
||||
syntax.insert(first, r)
|
||||
end
|
||||
|
||||
# Write the syntax file back out.
|
||||
File.open(syntax_file, 'w') do |f|
|
||||
f.puts syntax
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue