From cbde2571d4f79770ac552fe75440de72893bc73a Mon Sep 17 00:00:00 2001 From: Adam Stankiewicz Date: Sun, 25 Oct 2020 03:19:58 +0100 Subject: Respect symlinks for resolving vim-polyglot as fallback, closes #605 --- scripts/build | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) (limited to 'scripts/build') diff --git a/scripts/build b/scripts/build index 86237647..7d069d94 100755 --- a/scripts/build +++ b/scripts/build @@ -293,33 +293,26 @@ def copy_file(name, src, dest) open(src, "r") do |input| open(dest, "w") do |output| - if dest.match?(/\.vim$/) && !dest.match('after/') + if dest.match?(/\.vim$/) output << <<~EOF - let s:base = expand(":h:h") - let Filter = { _, v -> stridx(v, s:base) == -1 && stridx(v, $VIMRUNTIME) == -1 && v !~ "after" } - let files = filter(globpath(&rtp, '#{dest}', 1, 1), Filter) - if len(files) > 0 - exec 'source ' . files[0] + if !polyglot#util#IsEnabled('#{name}', expand(':p')) finish endif + EOF end - if name == "jsx" - output << "if !exists('g:polyglot_disabled') || (index(g:polyglot_disabled, 'javascript') == -1 && index(g:polyglot_disabled, 'jsx') == -1)\n\n" - else - output << "if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, '#{name}') == -1\n\n" - end contents = File.read(input) - # fix encoding if required - contents.gsub!(/!@#%#/, "") rescue contents = contents.force_encoding('iso-8859-1').encode('utf-8') - # ..= is feature of new vims... - contents.gsub!(' ..= ', ' .= ') - # https://github.com/vim/vim/pull/7091 - contents.gsub!(/set(local)? fileencoding=utf-8/, '') - contents.gsub!(/ fileencoding=utf-8/, '') - contents.gsub!('À-ÿ', '\u00ac-\uffff') + if dest.match?(/\.vim$/) + # fix encoding if required + contents.gsub!(/!@#%#/, "") rescue contents = contents.force_encoding('iso-8859-1').encode('utf-8') + # ..= is feature of new vims... + contents.gsub!(' ..= ', ' .= ') + # https://github.com/vim/vim/pull/7091 + contents.gsub!(/set(local)? fileencoding=utf-8/, '') + contents.gsub!(/ fileencoding=utf-8/, '') + contents.gsub!('À-ÿ', '\u00ac-\uffff') + end output << contents - output << "\nendif\n" end end end @@ -681,7 +674,7 @@ def generate_ftdetect(packages, heuristics) end if package_autocommands.flatten.size > 0 - output << "if !has_key(s:disabled_packages, '#{package["name"]}')\n" + output << "if polyglot#util#IsEnabled('#{package["name"]}', 'ftdetect')\n" output << indent(package_autocommands.map { |pc| pc.reverse.join("\n") }.join("\n\n"), 2) output << "\nendif\n\n" end -- cgit v1.2.3