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 let keywords = ["def", "class"];
24
25 for keyword in &keywords {
26 if context.prefix.is_empty() || keyword.starts_with(&context.prefix) {
27 suggestions.push(CompletionSuggestion::new(
28 keyword.to_string(),
29 CompletionKind::Keyword,
30 context.clone(),
31 ));
32 }
33 }
34
35 suggestions
36 }
37
38 fn language_name(&self) -> &str {
39 "python"
40 }
41
42 fn supports_language(&self, language: &str) -> bool {
43 language == "python" || language == "py"
44 }
45}