1use crate::tags::{TagSet, tags_from_array};
2use phf::phf_map;
3
4pub static EXTENSION_TAGS: phf::Map<&'static str, &'static [&'static str]> = phf_map! {
5 "adoc" => &["text", "asciidoc"],
6 "ai" => &["binary", "adobe-illustrator"],
7 "aj" => &["text", "aspectj"],
8 "asciidoc" => &["text", "asciidoc"],
9 "apinotes" => &["text", "apinotes"],
10 "asar" => &["binary", "asar"],
11 "asm" => &["text", "asm"],
12 "astro" => &["text", "astro"],
13 "avif" => &["binary", "image", "avif"],
14 "avsc" => &["text", "avro-schema"],
15 "bash" => &["text", "shell", "bash"],
16 "bat" => &["text", "batch"],
17 "bats" => &["text", "shell", "bash", "bats"],
18 "bazel" => &["text", "bazel"],
19 "bb" => &["text", "bitbake"],
20 "bbappend" => &["text", "bitbake"],
21 "bbclass" => &["text", "bitbake"],
22 "beancount" => &["text", "beancount"],
23 "bib" => &["text", "bib"],
24 "bmp" => &["binary", "image", "bitmap"],
25 "bz2" => &["binary", "bzip2"],
26 "bz3" => &["binary", "bzip3"],
27 "bzl" => &["text", "bazel"],
28 "c" => &["text", "c"],
29 "c++" => &["text", "c++"],
30 "c++m" => &["text", "c++"],
31 "cc" => &["text", "c++"],
32 "ccm" => &["text", "c++"],
33 "cfg" => &["text"],
34 "chs" => &["text", "c2hs"],
35 "cjs" => &["text", "javascript"],
36 "clj" => &["text", "clojure"],
37 "cljc" => &["text", "clojure"],
38 "cljs" => &["text", "clojure", "clojurescript"],
39 "cmake" => &["text", "cmake"],
40 "cnf" => &["text"],
41 "coffee" => &["text", "coffee"],
42 "conf" => &["text"],
43 "cpp" => &["text", "c++"],
44 "cppm" => &["text", "c++"],
45 "cr" => &["text", "crystal"],
46 "crt" => &["text", "pem"],
47 "cs" => &["text", "c#"],
48 "csproj" => &["text", "xml", "csproj", "msbuild"],
49 "csh" => &["text", "shell", "csh"],
50 "cson" => &["text", "cson"],
51 "css" => &["text", "css"],
52 "csv" => &["text", "csv"],
53 "csx" => &["text", "c#", "c#script"],
54 "cu" => &["text", "cuda"],
55 "cue" => &["text", "cue"],
56 "cuh" => &["text", "cuda"],
57 "cxx" => &["text", "c++"],
58 "cxxm" => &["text", "c++"],
59 "cylc" => &["text", "cylc"],
60 "dart" => &["text", "dart"],
61 "dbc" => &["text", "dbc"],
62 "def" => &["text", "def"],
63 "dll" => &["binary"],
64 "dtd" => &["text", "dtd"],
65 "ear" => &["binary", "zip", "jar"],
66 "edn" => &["text", "clojure", "edn"],
67 "ejs" => &["text", "ejs"],
68 "ejson" => &["text", "json", "ejson"],
69 "elm" => &["text", "elm"],
70 "env" => &["text", "dotenv"],
71 "eot" => &["binary", "eot"],
72 "eps" => &["binary", "eps"],
73 "erb" => &["text", "erb"],
74 "erl" => &["text", "erlang"],
75 "ex" => &["text", "elixir"],
76 "exe" => &["binary"],
77 "exs" => &["text", "elixir"],
78 "eyaml" => &["text", "yaml"],
79 "f03" => &["text", "fortran"],
80 "f08" => &["text", "fortran"],
81 "f90" => &["text", "fortran"],
82 "f95" => &["text", "fortran"],
83 "feature" => &["text", "gherkin"],
84 "fish" => &["text", "fish"],
85 "fits" => &["binary", "fits"],
86 "fs" => &["text", "f#"],
87 "fsproj" => &["text", "xml", "fsproj", "msbuild"],
88 "fsx" => &["text", "f#", "f#script"],
89 "gd" => &["text", "gdscript"],
90 "gemspec" => &["text", "ruby"],
91 "geojson" => &["text", "geojson", "json"],
92 "ggb" => &["binary", "zip", "ggb"],
93 "gif" => &["binary", "image", "gif"],
94 "gleam" => &["text", "gleam"],
95 "go" => &["text", "go"],
96 "gotmpl" => &["text", "gotmpl"],
97 "gpx" => &["text", "gpx", "xml"],
98 "graphql" => &["text", "graphql"],
99 "gradle" => &["text", "groovy"],
100 "groovy" => &["text", "groovy"],
101 "gyb" => &["text", "gyb"],
102 "gyp" => &["text", "gyp", "python"],
103 "gypi" => &["text", "gyp", "python"],
104 "gz" => &["binary", "gzip"],
105 "h" => &["text", "header", "c", "c++"],
106 "hbs" => &["text", "handlebars"],
107 "hcl" => &["text", "hcl"],
108 "hh" => &["text", "header", "c++"],
109 "hpp" => &["text", "header", "c++"],
110 "hrl" => &["text", "erlang"],
111 "hs" => &["text", "haskell"],
112 "htm" => &["text", "html"],
113 "html" => &["text", "html"],
114 "hxx" => &["text", "header", "c++"],
115 "icns" => &["binary", "icns"],
116 "ico" => &["binary", "icon"],
117 "ics" => &["text", "icalendar"],
118 "idl" => &["text", "idl"],
119 "idr" => &["text", "idris"],
120 "inc" => &["text", "inc"],
121 "ini" => &["text", "ini"],
122 "inl" => &["text", "inl", "c++"],
123 "ino" => &["text", "ino", "c++"],
124 "inx" => &["text", "xml", "inx"],
125 "ipynb" => &["text", "jupyter", "json"],
126 "ixx" => &["text", "c++"],
127 "j2" => &["text", "jinja"],
128 "jade" => &["text", "jade"],
129 "jar" => &["binary", "zip", "jar"],
130 "java" => &["text", "java"],
131 "jenkins" => &["text", "groovy", "jenkins"],
132 "jenkinsfile" => &["text", "groovy", "jenkins"],
133 "jinja" => &["text", "jinja"],
134 "jinja2" => &["text", "jinja"],
135 "jl" => &["text", "julia"],
136 "jpeg" => &["binary", "image", "jpeg"],
137 "jpg" => &["binary", "image", "jpeg"],
138 "js" => &["text", "javascript"],
139 "json" => &["text", "json"],
140 "jsonld" => &["text", "json", "jsonld"],
141 "jsonnet" => &["text", "jsonnet"],
142 "json5" => &["text", "json5"],
143 "jsx" => &["text", "jsx"],
144 "key" => &["text", "pem"],
145 "kml" => &["text", "kml", "xml"],
146 "kt" => &["text", "kotlin"],
147 "kts" => &["text", "kotlin"],
148 "lean" => &["text", "lean"],
149 "lektorproject" => &["text", "ini", "lektorproject"],
150 "less" => &["text", "less"],
151 "lfm" => &["text", "lazarus", "lazarus-form"],
152 "lhs" => &["text", "literate-haskell"],
153 "libsonnet" => &["text", "jsonnet"],
154 "lidr" => &["text", "idris"],
155 "liquid" => &["text", "liquid"],
156 "lpi" => &["text", "lazarus", "xml"],
157 "lpr" => &["text", "lazarus", "pascal"],
158 "lr" => &["text", "lektor"],
159 "lua" => &["text", "lua"],
160 "m" => &["text", "objective-c"],
161 "m4" => &["text", "m4"],
162 "magik" => &["text", "magik"],
163 "make" => &["text", "makefile"],
164 "manifest" => &["text", "manifest"],
165 "map" => &["text", "map"],
166 "markdown" => &["text", "markdown"],
167 "md" => &["text", "markdown"],
168 "mdx" => &["text", "mdx"],
169 "meson" => &["text", "meson"],
170 "metal" => &["text", "metal"],
171 "mib" => &["text", "mib"],
172 "mjs" => &["text", "javascript"],
173 "mk" => &["text", "makefile"],
174 "ml" => &["text", "ocaml"],
175 "mli" => &["text", "ocaml"],
176 "mm" => &["text", "c++", "objective-c++"],
177 "modulemap" => &["text", "modulemap"],
178 "mscx" => &["text", "xml", "musescore"],
179 "mscz" => &["binary", "zip", "musescore"],
180 "mustache" => &["text", "mustache"],
181 "myst" => &["text", "myst"],
182 "ngdoc" => &["text", "ngdoc"],
183 "nim" => &["text", "nim"],
184 "nims" => &["text", "nim"],
185 "nimble" => &["text", "nimble"],
186 "nix" => &["text", "nix"],
187 "njk" => &["text", "nunjucks"],
188 "otf" => &["binary", "otf"],
189 "p12" => &["binary", "p12"],
190 "pas" => &["text", "pascal"],
191 "patch" => &["text", "diff"],
192 "pdf" => &["binary", "pdf"],
193 "pem" => &["text", "pem"],
194 "php" => &["text", "php"],
195 "php4" => &["text", "php"],
196 "php5" => &["text", "php"],
197 "phtml" => &["text", "php"],
198 "pl" => &["text", "perl"],
199 "plantuml" => &["text", "plantuml"],
200 "pm" => &["text", "perl"],
201 "png" => &["binary", "image", "png"],
202 "po" => &["text", "pofile"],
203 "pom" => &["pom", "text", "xml"],
204 "pp" => &["text", "puppet"],
205 "prisma" => &["text", "prisma"],
206 "properties" => &["text", "java-properties"],
207 "props" => &["text", "xml", "msbuild"],
208 "proto" => &["text", "proto"],
209 "ps1" => &["text", "powershell"],
210 "psd1" => &["text", "powershell"],
211 "psm1" => &["text", "powershell"],
212 "pug" => &["text", "pug"],
213 "puml" => &["text", "plantuml"],
214 "purs" => &["text", "purescript"],
215 "pxd" => &["text", "cython"],
216 "pxi" => &["text", "cython"],
217 "py" => &["text", "python"],
218 "pyi" => &["text", "pyi"],
219 "pyproj" => &["text", "xml", "pyproj", "msbuild"],
220 "pyt" => &["text", "python"],
221 "pyx" => &["text", "cython"],
222 "pyz" => &["binary", "pyz"],
223 "pyzw" => &["binary", "pyz"],
224 "qml" => &["text", "qml"],
225 "r" => &["text", "r"],
226 "rake" => &["text", "ruby"],
227 "rb" => &["text", "ruby"],
228 "resx" => &["text", "resx", "xml"],
229 "rng" => &["text", "xml", "relax-ng"],
230 "rs" => &["text", "rust"],
231 "rst" => &["text", "rst"],
232 "s" => &["text", "asm"],
233 "sas" => &["text", "sas"],
234 "sass" => &["text", "sass"],
235 "sbt" => &["text", "sbt", "scala"],
236 "sc" => &["text", "scala"],
237 "scala" => &["text", "scala"],
238 "scm" => &["text", "scheme"],
239 "scss" => &["text", "scss"],
240 "sh" => &["text", "shell"],
241 "sln" => &["text", "sln"],
242 "sls" => &["text", "salt"],
243 "so" => &["binary"],
244 "sol" => &["text", "solidity"],
245 "spec" => &["text", "spec"],
246 "sql" => &["text", "sql"],
247 "ss" => &["text", "scheme"],
248 "sty" => &["text", "tex"],
249 "styl" => &["text", "stylus"],
250 "sv" => &["text", "system-verilog"],
251 "svelte" => &["text", "svelte"],
252 "svg" => &["text", "image", "svg", "xml"],
253 "svh" => &["text", "system-verilog"],
254 "swf" => &["binary", "swf"],
255 "swift" => &["text", "swift"],
256 "swiftdeps" => &["text", "swiftdeps"],
257 "tac" => &["text", "twisted", "python"],
258 "tar" => &["binary", "tar"],
259 "targets" => &["text", "xml", "msbuild"],
260 "templ" => &["text", "templ"],
261 "tex" => &["text", "tex"],
262 "textproto" => &["text", "textproto"],
263 "tf" => &["text", "terraform"],
264 "tfvars" => &["text", "terraform"],
265 "tgz" => &["binary", "gzip"],
266 "thrift" => &["text", "thrift"],
267 "tiff" => &["binary", "image", "tiff"],
268 "toml" => &["text", "toml"],
269 "ts" => &["text", "ts"],
270 "tsv" => &["text", "tsv"],
271 "tsx" => &["text", "tsx"],
272 "ttf" => &["binary", "ttf"],
273 "twig" => &["text", "twig"],
274 "txsprofile" => &["text", "ini", "txsprofile"],
275 "txt" => &["text", "plain-text"],
276 "txtpb" => &["text", "textproto"],
277 "urdf" => &["text", "xml", "urdf"],
278 "v" => &["text", "verilog"],
279 "vb" => &["text", "vb"],
280 "vbproj" => &["text", "xml", "vbproj", "msbuild"],
281 "vcxproj" => &["text", "xml", "vcxproj", "msbuild"],
282 "vdx" => &["text", "vdx"],
283 "vh" => &["text", "verilog"],
284 "vhd" => &["text", "vhdl"],
285 "vim" => &["text", "vim"],
286 "vtl" => &["text", "vtl"],
287 "vue" => &["text", "vue"],
288 "war" => &["binary", "zip", "jar"],
289 "wav" => &["binary", "audio", "wav"],
290 "webp" => &["binary", "image", "webp"],
291 "whl" => &["binary", "wheel", "zip"],
292 "wkt" => &["text", "wkt"],
293 "woff" => &["binary", "woff"],
294 "woff2" => &["binary", "woff2"],
295 "wsdl" => &["text", "xml", "wsdl"],
296 "wsgi" => &["text", "wsgi", "python"],
297 "xhtml" => &["text", "xml", "html", "xhtml"],
298 "xacro" => &["text", "xml", "urdf", "xacro"],
299 "xctestplan" => &["text", "json"],
300 "xml" => &["text", "xml"],
301 "xq" => &["text", "xquery"],
302 "xql" => &["text", "xquery"],
303 "xqm" => &["text", "xquery"],
304 "xqu" => &["text", "xquery"],
305 "xquery" => &["text", "xquery"],
306 "xqy" => &["text", "xquery"],
307 "xsd" => &["text", "xml", "xsd"],
308 "xsl" => &["text", "xml", "xsl"],
309 "xslt" => &["text", "xml", "xsl"],
310 "yaml" => &["text", "yaml"],
311 "yamlld" => &["text", "yaml", "yamlld"],
312 "yang" => &["text", "yang"],
313 "yin" => &["text", "xml", "yin"],
314 "yml" => &["text", "yaml"],
315 "zcml" => &["text", "xml", "zcml"],
316 "zig" => &["text", "zig"],
317 "zip" => &["binary", "zip"],
318 "zpt" => &["text", "zpt"],
319 "zsh" => &["text", "shell", "zsh"],
320};
321
322pub static EXTENSIONS_NEED_BINARY_CHECK_TAGS: phf::Map<&'static str, &'static [&'static str]> = phf_map! {
323 "plist" => &["plist"],
324 "ppm" => &["image", "ppm"],
325};
326
327pub static NAME_TAGS: phf::Map<&'static str, &'static [&'static str]> = phf_map! {
328 ".ansible-lint" => &["text", "yaml"],
329 ".clang-format" => &["text", "yaml"],
330 ".clang-tidy" => &["text", "yaml"],
331 ".salt-lint" => &["text", "yaml", "salt-lint"],
332 ".yamllint" => &["text", "yaml", "yamllint"],
333 ".babelrc" => &["text", "json", "babelrc"],
334 ".bowerrc" => &["text", "json", "bowerrc"],
335 ".csslintrc" => &["text", "json", "csslintrc"],
336 ".eslintrc" => &["text", "json"],
337 ".eslintrc.js" => &["text", "javascript"],
338 ".eslintrc.json" => &["text", "json"],
339 ".eslintrc.yaml" => &["text", "yaml"],
340 ".eslintrc.yml" => &["text", "yaml"],
341 ".jshintrc" => &["text", "json", "jshintrc"],
342 ".mention-bot" => &["text", "json", "mention-bot"],
343 ".prettierrc" => &["text", "json"],
344 ".prettierrc.json" => &["text", "json"],
345 ".prettierrc.toml" => &["text", "toml"],
346 ".prettierrc.yaml" => &["text", "yaml"],
347 ".prettierrc.yml" => &["text", "yaml"],
348 ".stylintrc" => &["text", "json"],
349 ".bash_aliases" => &["text", "shell", "bash"],
350 ".bash_profile" => &["text", "shell", "bash"],
351 ".bashrc" => &["text", "shell", "bash"],
352 ".cshrc" => &["text", "shell", "csh"],
353 ".envrc" => &["text", "shell", "bash"],
354 ".zlogin" => &["text", "shell", "zsh"],
355 ".zlogout" => &["text", "shell", "zsh"],
356 ".zprofile" => &["text", "shell", "zsh"],
357 ".zshrc" => &["text", "shell", "zsh"],
358 ".zshenv" => &["text", "shell", "zsh"],
359 "direnvrc" => &["text", "shell", "bash"],
360 ".codespellrc" => &["text", "ini", "codespellrc"],
361 ".coveragerc" => &["text", "ini", "coveragerc"],
362 ".flake8" => &["text", "ini", "flake8"],
363 ".gitconfig" => &["text", "ini", "gitconfig"],
364 ".gitlint" => &["text", "ini", "gitlint"],
365 ".hgrc" => &["text", "ini", "hgrc"],
366 ".isort.cfg" => &["text", "ini", "isort"],
367 ".pypirc" => &["text", "ini", "pypirc"],
368 ".rstcheck.cfg" => &["text", "ini"],
369 ".sqlfluff" => &["text", "ini"],
370 "pylintrc" => &["text", "ini", "pylintrc"],
371 "setup.cfg" => &["text", "ini"],
372 ".dockerignore" => &["text", "dockerignore"],
373 ".gitattributes" => &["text", "gitattributes"],
374 ".gitignore" => &["text", "gitignore"],
375 ".gitmodules" => &["text", "gitmodules"],
376 ".npmignore" => &["text", "npmignore"],
377 ".prettierignore" => &["text", "gitignore", "prettierignore"],
378 ".bazelrc" => &["text", "bazelrc"],
379 ".browserslistrc" => &["text", "browserslistrc"],
380 ".editorconfig" => &["text", "editorconfig"],
381 ".mailmap" => &["text", "mailmap"],
382 ".pdbrc" => &["text", "python", "pdbrc"],
383 "BUILD" => &["text", "bazel"],
384 "BUILD.bazel" => &["text", "bazel"],
385 "CMakeLists.txt" => &["text", "cmake"],
386 "Dockerfile" => &["text", "dockerfile"],
387 "Containerfile" => &["text", "dockerfile"],
388 "Makefile" => &["text", "makefile"],
389 "GNUmakefile" => &["text", "makefile"],
390 "makefile" => &["text", "makefile"],
391 "meson.build" => &["text", "meson"],
392 "meson_options.txt" => &["text", "meson"],
393 "WORKSPACE" => &["text", "bazel"],
394 "WORKSPACE.bazel" => &["text", "bazel"],
395 "copy.bara.sky" => &["text", "bazel"],
396 "Cargo.toml" => &["text", "toml", "cargo"],
397 "Cargo.lock" => &["text", "toml", "cargo-lock"],
398 "composer.json" => &["text", "json"],
399 "composer.lock" => &["text", "json"],
400 "go.mod" => &["text", "go-mod"],
401 "go.sum" => &["text", "go-sum"],
402 "package.json" => &["text", "json"],
403 "package-lock.json" => &["text", "json"],
404 "Pipfile" => &["text", "toml"],
405 "Pipfile.lock" => &["text", "json"],
406 "poetry.lock" => &["text", "toml"],
407 "pom.xml" => &["pom", "text", "xml"],
408 "yarn.lock" => &["text", "yaml"],
409 "config.ru" => &["text", "ruby"],
410 "Gemfile" => &["text", "ruby"],
411 "Gemfile.lock" => &["text"],
412 "Rakefile" => &["text", "ruby"],
413 "Vagrantfile" => &["text", "ruby"],
414 "bblayers.conf" => &["text", "bitbake"],
415 "bitbake.conf" => &["text", "bitbake"],
416 "rebar.config" => &["text", "erlang"],
417 "sys.config" => &["text", "erlang"],
418 "sys.config.src" => &["text", "erlang"],
419 "AUTHORS" => &["text", "plain-text"],
420 "CHANGELOG" => &["text", "plain-text"],
421 "CONTRIBUTING" => &["text", "plain-text"],
422 "COPYING" => &["text", "plain-text"],
423 "LICENSE" => &["text", "plain-text"],
424 "MAINTAINERS" => &["text", "plain-text"],
425 "NEWS" => &["text", "plain-text"],
426 "NOTICE" => &["text", "plain-text"],
427 "PATENTS" => &["text", "plain-text"],
428 "README" => &["text", "plain-text"],
429 "Jenkinsfile" => &["text", "groovy", "jenkins"],
430 "PKGBUILD" => &["text", "bash", "pkgbuild", "alpm"],
431 "Tiltfile" => &["text", "tiltfile"],
432 "wscript" => &["text", "python"],
433};
434
435pub fn get_extension_tags(ext: &str) -> TagSet {
436 EXTENSION_TAGS
437 .get(ext)
438 .map(|&tags| tags_from_array(tags))
439 .unwrap_or_default()
440}
441
442pub fn get_extensions_need_binary_check_tags(ext: &str) -> TagSet {
443 EXTENSIONS_NEED_BINARY_CHECK_TAGS
444 .get(ext)
445 .map(|&tags| tags_from_array(tags))
446 .unwrap_or_default()
447}
448
449pub fn get_name_tags(name: &str) -> TagSet {
450 NAME_TAGS
451 .get(name)
452 .map(|&tags| tags_from_array(tags))
453 .unwrap_or_default()
454}