Open Septias opened 6 months ago
syntect
is just a library, which happens to come with some language syntax support by default (which is unlikely to change much), but there's nothing to stop users of the library from using whatever languages they want...
see also:
Nix is one of the extra syntax definitions that gets bundled in with two-face
. E.g.
[package]
name = "demo"
version = "0.1.0"
edition = "2021"
[dependencies]
syntect = "5.2.0"
two-face = "0.3.0"
const NIX_TEXT: &str = r#"{ lib }:
let
defaultSourceType = tname: {
shortName = tname;
isSource = false;
};
in lib.mapAttrs (tname: tset: defaultSourceType tname // tset) {
fromSource = {
isSource = true;
};
binaryNativeCode = {};
binaryBytecode = {};
binaryFirmware = {};
}"#;
fn main() {
let syn_set = two_face::syntax::extra_newlines();
let theme_set = two_face::theme::extra();
let syn_ref = syn_set.find_syntax_by_extension("nix").unwrap();
let theme = theme_set.get(two_face::theme::EmbeddedThemeName::Nord);
let htmlified =
syntect::html::highlighted_html_for_string(NIX_TEXT, &syn_set, syn_ref, theme).unwrap();
println!("{htmlified}");
}
prints out HTML that renders as vv in my browser
Can you add the nix language as supported language?
It has a syntax definition file here: https://github.com/bbenoist/vscode-nix/blob/master/syntaxes/nix.tmLanguage