reovim_lang_bash/
lib.rs

1//! Bash language support for reovim
2
3use std::{any::TypeId, sync::Arc};
4
5use {
6    reovim_core::{
7        event_bus::EventBus,
8        plugin::{Plugin, PluginContext, PluginId, PluginStateRegistry},
9    },
10    reovim_plugin_treesitter::{LanguageSupport, RegisterLanguage, TreesitterPlugin},
11};
12
13/// Bash language support
14pub struct BashLanguage;
15
16impl LanguageSupport for BashLanguage {
17    fn language_id(&self) -> &'static str {
18        "bash"
19    }
20
21    fn file_extensions(&self) -> &'static [&'static str] {
22        &["sh", "bash", "zsh", "bashrc", "zshrc", "profile"]
23    }
24
25    fn tree_sitter_language(&self) -> reovim_plugin_treesitter::Language {
26        tree_sitter_bash::LANGUAGE.into()
27    }
28
29    fn highlights_query(&self) -> &'static str {
30        include_str!("queries/highlights.scm")
31    }
32
33    fn folds_query(&self) -> Option<&'static str> {
34        Some(include_str!("queries/folds.scm"))
35    }
36
37    fn textobjects_query(&self) -> Option<&'static str> {
38        Some(include_str!("queries/textobjects.scm"))
39    }
40}
41
42/// Bash language plugin
43pub struct BashPlugin;
44
45impl Plugin for BashPlugin {
46    fn id(&self) -> PluginId {
47        PluginId::new("reovim:lang-bash")
48    }
49
50    fn name(&self) -> &'static str {
51        "Bash Language"
52    }
53
54    fn description(&self) -> &'static str {
55        "Bash language support with syntax highlighting and semantic analysis"
56    }
57
58    fn dependencies(&self) -> Vec<TypeId> {
59        vec![TypeId::of::<TreesitterPlugin>()]
60    }
61
62    fn build(&self, _ctx: &mut PluginContext) {
63        // No commands to register
64    }
65
66    fn subscribe(&self, bus: &EventBus, _state: Arc<PluginStateRegistry>) {
67        bus.emit(RegisterLanguage {
68            language: Arc::new(BashLanguage),
69        });
70    }
71}