_diffctx/config/
extensions.rs1use once_cell::sync::Lazy;
2use rustc_hash::FxHashSet;
3
4fn set_from(exts: &[&'static str]) -> FxHashSet<&'static str> {
5 exts.iter().copied().collect()
6}
7
8pub static PYTHON_EXTENSIONS: Lazy<FxHashSet<&'static str>> =
9 Lazy::new(|| set_from(&[".py", ".pyi", ".pyw"]));
10
11pub static JAVASCRIPT_EXTENSIONS: Lazy<FxHashSet<&'static str>> =
12 Lazy::new(|| set_from(&[".js", ".jsx", ".mjs", ".cjs"]));
13
14pub static TYPESCRIPT_EXTENSIONS: Lazy<FxHashSet<&'static str>> =
15 Lazy::new(|| set_from(&[".ts", ".tsx", ".mts", ".cts"]));
16
17pub static JS_TS_EXTENSIONS: Lazy<FxHashSet<&'static str>> = Lazy::new(|| {
18 JAVASCRIPT_EXTENSIONS
19 .iter()
20 .chain(TYPESCRIPT_EXTENSIONS.iter())
21 .copied()
22 .collect()
23});
24
25pub static GO_EXTENSIONS: Lazy<FxHashSet<&'static str>> = Lazy::new(|| set_from(&[".go"]));
26
27pub static RUST_EXTENSIONS: Lazy<FxHashSet<&'static str>> = Lazy::new(|| set_from(&[".rs"]));
28
29pub static JAVA_EXTENSIONS: Lazy<FxHashSet<&'static str>> = Lazy::new(|| set_from(&[".java"]));
30
31pub static KOTLIN_EXTENSIONS: Lazy<FxHashSet<&'static str>> =
32 Lazy::new(|| set_from(&[".kt", ".kts"]));
33
34pub static SCALA_EXTENSIONS: Lazy<FxHashSet<&'static str>> =
35 Lazy::new(|| set_from(&[".scala", ".sc"]));
36
37pub static JVM_EXTENSIONS: Lazy<FxHashSet<&'static str>> = Lazy::new(|| {
38 JAVA_EXTENSIONS
39 .iter()
40 .chain(KOTLIN_EXTENSIONS.iter())
41 .chain(SCALA_EXTENSIONS.iter())
42 .copied()
43 .collect()
44});
45
46pub static C_EXTENSIONS: Lazy<FxHashSet<&'static str>> = Lazy::new(|| set_from(&[".c", ".h"]));
47
48pub static CPP_EXTENSIONS: Lazy<FxHashSet<&'static str>> = Lazy::new(|| {
49 set_from(&[
50 ".cpp", ".hpp", ".cc", ".hh", ".cxx", ".hxx", ".c++", ".h++", ".ipp", ".tpp",
51 ])
52});
53
54pub static C_FAMILY_EXTENSIONS: Lazy<FxHashSet<&'static str>> = Lazy::new(|| {
55 C_EXTENSIONS
56 .iter()
57 .chain(CPP_EXTENSIONS.iter())
58 .copied()
59 .chain([".m", ".mm"])
60 .collect()
61});
62
63pub static CSHARP_EXTENSIONS: Lazy<FxHashSet<&'static str>> = Lazy::new(|| set_from(&[".cs"]));
64
65pub static FSHARP_EXTENSIONS: Lazy<FxHashSet<&'static str>> =
66 Lazy::new(|| set_from(&[".fs", ".fsi", ".fsx"]));
67
68pub static DOTNET_EXTENSIONS: Lazy<FxHashSet<&'static str>> = Lazy::new(|| {
69 CSHARP_EXTENSIONS
70 .iter()
71 .chain(FSHARP_EXTENSIONS.iter())
72 .copied()
73 .collect()
74});
75
76pub static RUBY_EXTENSIONS: Lazy<FxHashSet<&'static str>> =
77 Lazy::new(|| set_from(&[".rb", ".rake", ".gemspec"]));
78
79pub static PHP_EXTENSIONS: Lazy<FxHashSet<&'static str>> = Lazy::new(|| {
80 set_from(&[
81 ".php", ".phtml", ".php3", ".php4", ".php5", ".php7", ".phps",
82 ])
83});
84
85pub static SHELL_EXTENSIONS: Lazy<FxHashSet<&'static str>> = Lazy::new(|| {
86 set_from(&[
87 ".sh", ".bash", ".zsh", ".ksh", ".fish", ".ps1", ".psm1", ".psd1",
88 ])
89});
90
91pub static SWIFT_EXTENSIONS: Lazy<FxHashSet<&'static str>> = Lazy::new(|| set_from(&[".swift"]));
92
93pub static OTHER_CODE_EXTENSIONS: Lazy<FxHashSet<&'static str>> = Lazy::new(|| {
94 set_from(&[
95 ".lua", ".r", ".jl", ".pl", ".pm", ".ex", ".exs", ".erl", ".hs", ".clj", ".lisp", ".ml",
96 ".mli", ".nim", ".v", ".zig", ".d", ".ada", ".pas", ".f90", ".f95", ".cob", ".asm", ".s",
97 ".vhd", ".sv", ".vue", ".svelte", ".dart",
98 ])
99});
100
101pub static CODE_EXTENSIONS: Lazy<FxHashSet<&'static str>> = Lazy::new(|| {
102 PYTHON_EXTENSIONS
103 .iter()
104 .chain(JS_TS_EXTENSIONS.iter())
105 .chain(GO_EXTENSIONS.iter())
106 .chain(RUST_EXTENSIONS.iter())
107 .chain(JVM_EXTENSIONS.iter())
108 .chain(C_FAMILY_EXTENSIONS.iter())
109 .chain(DOTNET_EXTENSIONS.iter())
110 .chain(RUBY_EXTENSIONS.iter())
111 .chain(PHP_EXTENSIONS.iter())
112 .chain(SHELL_EXTENSIONS.iter())
113 .chain(SWIFT_EXTENSIONS.iter())
114 .chain(OTHER_CODE_EXTENSIONS.iter())
115 .copied()
116 .collect()
117});
118
119pub static CONFIG_EXTENSIONS: Lazy<FxHashSet<&'static str>> = Lazy::new(|| {
120 set_from(&[
121 ".yaml",
122 ".yml",
123 ".json",
124 ".toml",
125 ".ini",
126 ".cfg",
127 ".conf",
128 ".xml",
129 ".properties",
130 ])
131});
132
133pub static DOC_EXTENSIONS: Lazy<FxHashSet<&'static str>> =
134 Lazy::new(|| set_from(&[".md", ".rst", ".txt", ".adoc"]));