on master help sign in
Support env flags in shebang (#1224)
70c6253ath3
helix-core/src/syntax.rs+3−2
@@ -310,8 +310,9 @@ impl Loader {
310
310
311 pub fn language_config_for_shebang(&self, source: &Rope) -> Option<Arc<LanguageConfiguration>> {
311 pub fn language_config_for_shebang(&self, source: &Rope) -> Option<Arc<LanguageConfiguration>> {
312 let line = Cow::from(source.line(0));
312 let line = Cow::from(source.line(0));
313− static SHEBANG_REGEX: Lazy<Regex> =
313+ static SHEBANG_REGEX: Lazy<Regex> = Lazy::new(|| {
314− Lazy::new(|| Regex::new(r"^#!\s*(?:\S*[/\\](?:env\s+)?)?([^\s\.\d]+)").unwrap());
314+ Regex::new(r"^#!\s*(?:\S*[/\\](?:env\s+(?:\-\S+\s+)*)?)?([^\s\.\d]+)").unwrap()
315+ });
315 let configuration_id = SHEBANG_REGEX
316 let configuration_id = SHEBANG_REGEX
316 .captures(&line)
317 .captures(&line)
317 .and_then(|cap| self.language_config_ids_by_shebang.get(&cap[1]));
318 .and_then(|cap| self.language_config_ids_by_shebang.get(&cap[1]));