Skip to main content

rinne_graph/lang/
python.rs

1//! Python language support.
2
3use super::LanguageSupport;
4use tree_sitter::{Language, Query};
5
6pub struct Python {
7    query: Query,
8}
9
10impl Python {
11    pub fn new() -> Self {
12        let language: Language = tree_sitter_python::LANGUAGE.into();
13        let query = Query::new(&language, include_str!("../queries/python.scm"))
14            .expect("valid python query");
15        Self { query }
16    }
17}
18
19impl Default for Python {
20    fn default() -> Self {
21        Self::new()
22    }
23}
24
25impl LanguageSupport for Python {
26    fn name(&self) -> &'static str {
27        "python"
28    }
29    fn language(&self) -> Language {
30        tree_sitter_python::LANGUAGE.into()
31    }
32    fn query(&self) -> &Query {
33        &self.query
34    }
35}