|
|
|
|
@ -27,6 +27,7 @@ pub struct TreeSitterConfig {
|
|
|
|
|
extern "C" {
|
|
|
|
|
fn tree_sitter_c() -> Language;
|
|
|
|
|
fn tree_sitter_clojure() -> Language;
|
|
|
|
|
fn tree_sitter_cpp() -> Language;
|
|
|
|
|
fn tree_sitter_css() -> Language;
|
|
|
|
|
fn tree_sitter_elisp() -> Language;
|
|
|
|
|
fn tree_sitter_elixir() -> Language;
|
|
|
|
|
@ -46,7 +47,7 @@ pub fn from_extension(extension: &OsStr) -> Option<TreeSitterConfig> {
|
|
|
|
|
// TODO: find a nice way to extract name and extension information
|
|
|
|
|
// from the package.json in these parsers.
|
|
|
|
|
match extension.to_string_lossy().borrow() {
|
|
|
|
|
"c" | "h" => Some(TreeSitterConfig {
|
|
|
|
|
"c" => Some(TreeSitterConfig {
|
|
|
|
|
name: "C",
|
|
|
|
|
language: unsafe { tree_sitter_c() },
|
|
|
|
|
atom_nodes: (vec!["string_literal", "char_literal"])
|
|
|
|
|
@ -55,6 +56,22 @@ pub fn from_extension(extension: &OsStr) -> Option<TreeSitterConfig> {
|
|
|
|
|
// TODO: Handle array_declarator where [ is the second token.
|
|
|
|
|
open_delimiter_tokens: (vec!["(", "{"]).into_iter().collect(),
|
|
|
|
|
}),
|
|
|
|
|
// Treat .h as C++ rather than C. This is an arbitrary choice,
|
|
|
|
|
// but C++ is more widely used than C according to
|
|
|
|
|
// https://madnight.github.io/githut/
|
|
|
|
|
//
|
|
|
|
|
// TODO: allow users to override the association between
|
|
|
|
|
// extensions and parses.
|
|
|
|
|
"cc" | "cpp" | "h" | "hpp" => Some(TreeSitterConfig {
|
|
|
|
|
name: "C++",
|
|
|
|
|
language: unsafe { tree_sitter_cpp() },
|
|
|
|
|
// The C++ grammar extends the C grammar, so the node
|
|
|
|
|
// names are generally the same.
|
|
|
|
|
atom_nodes: (vec!["string_literal", "char_literal"])
|
|
|
|
|
.into_iter()
|
|
|
|
|
.collect(),
|
|
|
|
|
open_delimiter_tokens: (vec!["(", "{"]).into_iter().collect(),
|
|
|
|
|
}),
|
|
|
|
|
"bb" | "boot" | "clj" | "cljc" | "clje" | "cljs" | "cljx" | "edn" | "joke" | "joker" => {
|
|
|
|
|
Some(TreeSitterConfig {
|
|
|
|
|
name: "Clojure",
|
|
|
|
|
|