Should offer ability to detect generic vi: ft=* style language designations
donaldguy opened this issue Β· comments
Hi π if anyone else actually see's this note to self.
I have recently started using bat
as my goto ~pager. In working with some stuff I've already found myself in want of sharkdp/bat#1600 but I suspect that it should go into syntect proper rather than be grafted on in bat
I am looking to get into more rust, so I am setting this aside in this fork as a "good first issue" type of dealio
Cause I want the experience at least as much as I want the feature shipped immediately
For what its worth, I plan to crib from https://github.com/ctlajoie/vscode-modelines/blob/master/src/modelines.ts for the generic detection logic
if someone wants to beat me to it :-)
It looks like there isn't any need to change outside the one function. It is already always called when extension is indeterminete
so its just a question of having (optional?) fallback to a default pattern if the syntax doesn't specify one (or if it does but none match?)
This is to say we need to stick our (varying result) checker at the bottom of the first_line_cache
except that it obviously then can't only be a static regex to index match as it is now
#[derive(Debug)]
struct FirstLineCache {
/// (first line regex, syntax index) pairs for all syntaxes with a first line regex
regexes: Vec<(Regex, usize)>,
}
needing to resolve to a dynamic result (which should itself cross-check for a definition?)
there is ... probably a relevant trait for this - but I am a rust noob
If we were okay with naivety we could use a capture group against mode/ft I think