diff options
author | Adam Stankiewicz <sheerun@sher.pl> | 2020-09-28 00:31:39 +0200 |
---|---|---|
committer | Adam Stankiewicz <sheerun@sher.pl> | 2020-09-28 00:31:39 +0200 |
commit | 2116dd281b99ed77bf9134f96a33230dc5b30e1c (patch) | |
tree | 6fa103dad3cbdf2f4a44173caecb29cec8b0721c | |
parent | 7ec499c19f91122724d1518887ba3ffe4a8fcb43 (diff) | |
download | vim-polyglot-2116dd281b99ed77bf9134f96a33230dc5b30e1c.tar.gz vim-polyglot-2116dd281b99ed77bf9134f96a33230dc5b30e1c.zip |
Fix some missing extensions warnings
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | autoload/sleuth.vim | 2 | ||||
-rw-r--r-- | ftdetect/polyglot.vim | 9 | ||||
-rw-r--r-- | packages.yaml | 5 | ||||
-rwxr-xr-x | scripts/build | 64 |
5 files changed, 57 insertions, 25 deletions
@@ -7,4 +7,4 @@ test: @ scripts/test dev: - @ echo "polyglot.vim\npackages.yaml\nheuristics.yaml\nscripts/test\nscripts/build\ntests/extensions.vim" | DEV=1 entr bash -c 'make && make test' + @ find scripts . -type f -depth 1 | DEV=1 entr bash -c 'make && make test' diff --git a/autoload/sleuth.vim b/autoload/sleuth.vim index aa61d8fb..41ebe474 100644 --- a/autoload/sleuth.vim +++ b/autoload/sleuth.vim @@ -200,7 +200,7 @@ let s:globs = { \ 'terraform': '*.hcl,*.nomad,*.tf,*.tfvars,*.workflow', \ 'textile': '*.textile', \ 'thrift': '*.thrift', - \ 'tmux': '.tmux.conf', + \ 'tmux': '.tmux*.conf', \ 'toml': '*.toml,Cargo.lock,Gopkg.lock,poetry.lock,Pipfile', \ 'tptp': '*.p,*.tptp,*.ax', \ 'trasys': '*.inp', diff --git a/ftdetect/polyglot.vim b/ftdetect/polyglot.vim index 4b01a241..52c536e9 100644 --- a/ftdetect/polyglot.vim +++ b/ftdetect/polyglot.vim @@ -427,7 +427,7 @@ if !has_key(s:disabled_packages, 'scss') endif if !has_key(s:disabled_packages, 'sh') - au! BufRead,BufNewFile *.zsh,.zshrc,.zshenv,.zlogin,.zprofile,.zlogout + au! BufRead,BufNewFile */etc/udev/cdsymlinks.conf,*.zsh,.zshrc,.zshenv,.zlogin,.zprofile,.zlogout endif if !has_key(s:disabled_packages, 'smt2') @@ -446,6 +446,10 @@ if !has_key(s:disabled_packages, 'terraform') au! BufRead,BufNewFile *.tf endif +if !has_key(s:disabled_packages, 'tmux') + au! BufRead,BufNewFile .tmux*.conf +endif + if !has_key(s:disabled_packages, 'toml') au! BufRead,BufNewFile Pipfile endif @@ -1737,6 +1741,7 @@ if !has_key(s:disabled_packages, 'sh') au BufNewFile,BufRead *.sh.in set ft=sh au BufNewFile,BufRead *.tmux set ft=sh au BufNewFile,BufRead *.tool set ft=sh + au BufNewFile,BufRead */etc/udev/cdsymlinks.conf set ft=sh au BufNewFile,BufRead {.,}bash_aliases set ft=sh au BufNewFile,BufRead {.,}bash_history set ft=sh au BufNewFile,BufRead {.,}bash_logout set ft=sh @@ -1834,7 +1839,7 @@ if !has_key(s:disabled_packages, 'thrift') endif if !has_key(s:disabled_packages, 'tmux') - au BufNewFile,BufRead {.,}tmux.conf set ft=tmux + au BufNewFile,BufRead {.,}tmux*.conf set ft=tmux endif if !has_key(s:disabled_packages, 'toml') diff --git a/packages.yaml b/packages.yaml index bbbb8a88..78595209 100644 --- a/packages.yaml +++ b/packages.yaml @@ -1492,6 +1492,9 @@ filetypes: - 'zlogin' - 'zprofile' - 'zlogout' + extra_filenames: + # Udev symlinks config + - '*/etc/udev/cdsymlinks.conf' - name: zsh extensions: - zsh @@ -1611,7 +1614,7 @@ remote: ericpruitt/tmux.vim:vim filetypes: - name: tmux filenames: - - '.tmux.conf' + - '.tmux*.conf' --- name: toml remote: cespare/vim-toml diff --git a/scripts/build b/scripts/build index 68557196..0d810d7b 100755 --- a/scripts/build +++ b/scripts/build @@ -539,23 +539,7 @@ def generate_ftdetect(packages, heuristics) end end - defined_extensions = all_filetypes.flat_map { |f| expand_all(f["extensions"] || []).map { |e| [f["name"], e] } } - expected_extensions = expected_filetypes.flat_map { |f| expand_all(f["extensions"] || []).map { |e| [f["name"], e] } } - ignored_extensions = all_filetypes.flat_map { |f| expand_all(f.fetch("ignored_extensions", [])).map { |e| [f["name"], e] } } - - defined_filenames = all_filetypes.flat_map { |f| expand_all(f["filenames"] || []).map { |e| [f["name"], e] } } - expected_filenames = expected_filetypes.flat_map { |f| expand_all(f["filenames"] || []).map { |e| [f["name"], e] } } - ignored_filenames = all_filetypes.flat_map { |f| expand_all(f.fetch("ignored_filenames", [])).map { |e| [f["name"], e] } } - - ignored_warnings = all_filetypes.flat_map { |f| expand_all(f.fetch("ignored_warnings", [])).map { |e| [f["name"], e] } + [f, "*"] } - - for name, e in expected_extensions - defined_extensions - ignored_extensions - ignored_warnings - puts "Missing extension for #{name}: #{e}" - end - - for name, e in expected_filenames - defined_filenames - ignored_filenames - ignored_warnings - puts "Missing filename for #{name}: #{e}" - end + show_warnings(all_filetypes, expected_filetypes) ftdetect = read_section('ftdetect/polyglot.vim') @@ -650,14 +634,30 @@ def comma_expanson(s) end end -def expand_all(pattern) +def expand_all(pattern, all = false) + if !pattern + return [] + end + if pattern.is_a?(Array) - return pattern.flat_map { |p| expand_all(p) } + return pattern.flat_map { |p| expand_all(p, all) } end comma_expanson(pattern).flat_map do |e| brace_expansion(e).flat_map do |e2| - square_expansion(e2) + square_expansion(e2).flat_map do |e3| + results = [e3] + if all + if e3[0] == "." + results << e3[1..-1] + end + if e3.include?("*") + results.concat(results.map { |e4| e4.gsub("*", "") }) + end + results << "*" + end + results + end end end end @@ -719,6 +719,30 @@ def generate_plugins(packages) File.write('autoload/sleuth.vim', output) end +def process_list(list, extras) + list.flat_map do |f| + expand_all(yield f, extras).uniq.map { |e| [f["name"], e] } + end +end + +def show_warnings(all_filetypes, expected_filetypes) + all_expected = process_list(expected_filetypes, false) do |f| + (f["extensions"] || []).map { |e| "*" + e } + (f["filenames"] || []) + end + + all_handled = process_list(all_filetypes, all_expected) do |f| + [f["filenames"], f["ignored_filenames"], f["ignored_warnings"]].compact.flatten + + [f["extensions"], f["ignored_extensions"]].compact.flatten.map { |e| "*." + e } + end + + for name, e in all_expected - all_handled + if e.match?(/\/\*\.[^\/]+$/) && all_handled.include?([name, e.split('/').last]) + next + end + puts "Missing for #{name}: #{e}" + end +end + if __FILE__ == $0 if !ENV["DEV"] |