Adding Support for New Languages
This is a contributor guide for extending Probe. If you just need to know what’s supported, see Language Support.
This guide lists the exact files you must modify to add a new language to Probe.
Required File Modifications
Adding a new language requires modifying exactly 11 files. Missing any of these will result in incomplete language support.
Step 1: Core Language Implementation (4 files)
Step 2: Search & Extract Integration (4 files)
Step 3: CLI & User Interface (2 files)
Step 4: Documentation (1 file)
Step 1: Core Language Implementation
File 1: Cargo.toml
Add tree-sitter dependency:
tree-sitter-yourlang = "X.Y.Z"File 2: src/language/yourlang.rs
Create language implementation (copy from existing language like rust.rs):
use super::language_trait::LanguageImpl;
use tree_sitter::{Language as TSLanguage, Node};
pub struct YourLangLanguage;
impl LanguageImpl for YourLangLanguage {
fn get_tree_sitter_language(&self) -> TSLanguage {
tree_sitter_yourlang::language().into()
}
// ... implement other required methods
}File 3: src/language/mod.rs
Add module export:
pub mod yourlang;File 4: src/language/factory.rs
Add import:
use probe_code::language::yourlang::YourLangLanguage;Add registration:
"yourext" => Some(Box::new(YourLangLanguage::new())),Step 2: Search & Extract Integration
File 5: src/search/file_list_cache.rs
Add to get_language_extensions() function:
"yourlang" => vec![".yourext".to_string()],File 6: src/extract/formatter.rs
Add to syntax highlighting mapping:
"yourext" => "yourlang",File 7: src/search/results_formatter.rs
Add to language mapping:
"yourext" => "yourlang",File 8: src/search/search_output.rs
Add to language mapping and comment prefix:
// In syntax highlighting mapping:
"yourext" => "yourlang",
// In comment prefix mapping (choose appropriate section):
// For # comments:
"py" | "rb" | "sh" | "bash" | "pl" | "r" | "yourext" => "#",
// For // comments:
"rs" | "c" | "h" | "cpp" | "yourext" => "//",Step 3: CLI & User Interface
File 9: src/cli.rs
Add to language completion lists (2 locations):
"yourlang", "yourext",File 10: npm/src/mcp/index.ts
Add to supported languages description:
'Supported languages: rust, javascript, typescript, python, go, c, cpp, java, ruby, php, swift, csharp, yourlang.',Step 4: Documentation
File 11: site/supported-languages.md
Add table entry and language-specific features section.
Testing
Create comprehensive tests in your language file:
#[cfg(test)]
mod tests {
use super::*;
// Add tests for all LanguageImpl methods
}LanguageImpl Methods to Implement
Copy implementation patterns from similar languages:
get_tree_sitter_language()- Return tree-sitter languageis_acceptable_parent()- Define extractable code blocksis_test_node()- Detect test codeget_symbol_signature()- Extract clean signaturesfind_parent_function()- Optional method
Use tree-sitter playground to understand AST structure: https://tree-sitter.github.io/tree-sitter/playground
Verification
After modifying all 11 files:
cargo test- All tests passcargo run -- search "term" file.yourext- Search workscargo run -- extract file.yourext:N- Extract workscargo run -- search "test" --allow-tests- Test detection works