vtcode_core/code/code_completion/languages/
python.rs1use super::LanguageProvider;
2use crate::code::code_completion::context::CompletionContext;
3use crate::code::code_completion::engine::{CompletionKind, CompletionSuggestion};
4
5pub struct PythonProvider;
7
8impl PythonProvider {
9 pub fn new() -> Self {
10 Self
11 }
12}
13
14impl Default for PythonProvider {
15 fn default() -> Self {
16 Self::new()
17 }
18}
19
20impl LanguageProvider for PythonProvider {
21 fn get_completions(&self, context: &CompletionContext) -> Vec<CompletionSuggestion> {
22 let mut suggestions = Vec::new();
23
24 if context.prefix.is_empty() || "def".starts_with(&context.prefix) {
26 suggestions.push(CompletionSuggestion::new(
27 "def".to_string(),
28 CompletionKind::Keyword,
29 context.clone(),
30 ));
31 }
32
33 if context.prefix.is_empty() || "class".starts_with(&context.prefix) {
34 suggestions.push(CompletionSuggestion::new(
35 "class".to_string(),
36 CompletionKind::Keyword,
37 context.clone(),
38 ));
39 }
40
41 suggestions
42 }
43
44 fn language_name(&self) -> &str {
45 "python"
46 }
47
48 fn supports_language(&self, language: &str) -> bool {
49 language == "python" || language == "py"
50 }
51}