diff options
| author | Adam Stankiewicz <sheerun@sher.pl> | 2020-10-02 03:42:03 +0200 | 
|---|---|---|
| committer | Adam Stankiewicz <sheerun@sher.pl> | 2020-10-02 03:42:03 +0200 | 
| commit | 94ec9c38e744241e48fb8d75ae6e8811bc73fc59 (patch) | |
| tree | 03940b00ce5d9a494253af5d2976d095a11a5d2f /scripts/build | |
| parent | bff55a54fa8a70e664ebe8a614681dd0d92d66b6 (diff) | |
| download | vim-polyglot-94ec9c38e744241e48fb8d75ae6e8811bc73fc59.tar.gz vim-polyglot-94ec9c38e744241e48fb8d75ae6e8811bc73fc59.zip | |
Do not use ++once to support older vims, fixes #7056
Diffstat (limited to '')
| -rwxr-xr-x | scripts/build | 33 | 
1 files changed, 15 insertions, 18 deletions
| diff --git a/scripts/build b/scripts/build index 8b40e571..48ed10a1 100755 --- a/scripts/build +++ b/scripts/build @@ -392,7 +392,8 @@ def rule_to_code(rule)    if rule.has_key?("filetype")      if rule.has_key?("fallback")        return <<~EOS -        set ft=#{rule["filetype"]} | au BufWritePost <buffer> ++once call polyglot#detect##{camelize(rule["extensions"].first)}() +        setf #{rule["filetype"]} +        call s:WritePostOnce('call polyglot#detect##{camelize(rule["extensions"].first)}()')          return        EOS      end @@ -496,7 +497,7 @@ end  def generate_ftdetect(packages, heuristics)    FileUtils.mkdir_p('autoload/polyglot') -  output = "\n" +  output = ""    all_filetypes = packages.flat_map { |f| f["filetypes"] || [] }    filetype_names = Set.new(all_filetypes.map { |f| f["name"] }) @@ -581,17 +582,9 @@ def generate_ftdetect(packages, heuristics)    show_warnings(all_filetypes, expected_filetypes) -  ftdetect = File.read('ftdetect/polyglot.vim') - -  starting = '" DO NOT EDIT CODE BELOW, IT IS GENERATED WITH MAKEFILE' -  ending = '" DO NOT EDIT CODE ABOVE, IT IS GENERATED WITH MAKEFILE' - -  File.write( -    'ftdetect/polyglot.vim', -    ftdetect.gsub(/(?<=#{starting}\n)(.*)(?=#{ending})/m) { output } -  ) +  inject_code('ftdetect/polyglot.vim', output) -  output = ["\" DO NOT EDIT CODE BELOW, IT IS GENERATED WITH MAKEFILE\n"] +  output = []    for heuristic in heuristics      output << <<~EOS @@ -601,7 +594,7 @@ def generate_ftdetect(packages, heuristics)      EOS    end -  File.write('autoload/polyglot/detect.vim', output.join("\n")) +  inject_code('autoload/polyglot/detect.vim', output.join("\n"))    output = <<~EOS      let s:interpreters = { @@ -619,9 +612,15 @@ def generate_ftdetect(packages, heuristics)  end  def inject_code(path, code) -  header = "\" DO NOT EDIT CODE BELOW, IT IS GENERATED WITH MAKEFILE\n" -  normal, generated = File.read(path).split(header) -  File.write(path, [normal, generated].join(header)) +  source = File.read(path) + +  starting = '" DO NOT EDIT CODE BELOW, IT IS GENERATED WITH MAKEFILE' +  ending = '" DO NOT EDIT CODE ABOVE, IT IS GENERATED WITH MAKEFILE' + +  File.write( +    path, +    source.gsub(/(?<=#{starting}\n)(.*)(?=#{ending})/m) { "\n" + code + "\n" } +  )  end  def generate_tests(packages) @@ -739,8 +738,6 @@ end  def generate_plugins(packages)    output = <<~EOS -    " DO NOT EDIT CODE BELOW, IT IS GENERATED WITH MAKEFILE -      let s:globs = {    EOS | 
