Skip to content

Support more languages... #3

@cdecompilador

Description

@cdecompilador

To do this, two things in the code must be modified:

1. The Function that returns the language name given the extension

fn get_language_name<'a>(extension: &'a str) -> &'a str {
    match extension {
        "rs" => "Rust",
        "c" => "C",
        "cpp" | "cxx" | "c++" => "C++",
        "py" => "Python",
        "js" | "jsx" => "Javascript",
        "ts" => "Typescript",
        _ => {
            println!("Uknown file extension: {}", extension);
            "Uknown"
        },
         // TODO: Add more
    }
}

2. Edit the constant KNWON_EXTENSION_BINDINGS

const KNOWN_EXTENSIONS_BINDINGS: &[(&str, &[&str])] = &[
    ("rs", &["//", "/*", "*/"]),
    ("c", &["//", "/*", "*/"]),
    ("cpp", &["//", "/*", "*/"]),("c++", &["//", "/*", "*/"]),("cxx", &["//", "/*", "*/"]),
    ("py", &["#", "\"\"\"", "\"\"\""]),
    ("js", &["//", "/*", "*/"]),("jsx", &["//", "/*", "*/"]),
    ("ts", &["//", "/*", "*/"]),
    // TODO: Add more...
];

The upgrade of grouping this two things in just one is also allowed, and probably done in the future

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions