Fix some missing extensions warnings

This commit is contained in:
Adam Stankiewicz
2020-09-28 00:31:39 +02:00
parent 7ec499c19f
commit 2116dd281b
5 changed files with 57 additions and 25 deletions

View File

@@ -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'

View File

@@ -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',

View File

@@ -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')

View File

@@ -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

View File

@@ -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"]