Open carueda opened 1 year ago
Per a quick inspection, it does seem like library use (as exercised via bat::PrettyPrinter
) only considers the embedded syntaxes:
Sorry for the late reply here, I'm no expert on bat
internals :)
Per a quick inspection, it does seem like library use (as exercised via
bat::PrettyPrinter
) only considers the embedded syntaxes:* https://github.com/sharkdp/bat/blob/3d7817d662446ed03a95dfb404770a4ff8df135c/src/pretty_printer.rs#L54-L57 * https://github.com/sharkdp/bat/blob/3d7817d662446ed03a95dfb404770a4ff8df135c/src/pretty_printer.rs#L248-L252
I actually interpret this comment to mean, that the assets.get_syntaxes()
call will never fail because at a minimum, it always uses the assets from the binary. So there will always be at least one syntax, whether or not the "cache" folder is used.
But yes, it does seem like an unexpected omission that PrettyPrinter
will only ever use the assets from the binary. This confused me, but after some investigation, it seems (unless I'm mistaken) bat
the command line application isn't using PrettyPrinter
. Which kinda explains it :)
I think that all that needs to be fixed is to add to the bat
PrettyPrinter
public API a way to instantiate it with passing a cache directory. But presumably as the command line side isn't using this struct, then other apps relying on bat
as a library could achieve the same thing without it too...
Thanks for the note. Right. In my project I found a way to instruct the library to use my locally configured language. So, strictly speaking this is possible already. However, I understand that PrettyPrinter
is intended to be the API, but this use case is not covered, and that's why I decided to enter this ticket. Thanks.
I've been a happy user of the
bat
command line program for a good while (thanks!), including its use with a custom language ("TethysL") for which I defined a sublime spec according to the readme. In particular,bat --list-languages
includes an entry for such language, and rendering has been all great and as expected.Now, I just started experimenting with bat in library mode and was hoping that such use would also "discover" my local configuration for the custom language. However, I get
unknown syntax: 'TethysL'
. More details below.Perhaps library use only considers syntaxes embedded in it by default and I missing a way to instruct the library to also look into the location displayed by
"$(bat --config-dir)/syntaxes")
? Thanks!Info related to using bat as program:
Info related to using bat as library:
When running:
I get