pub struct PluginApi { /* private fields */ }Expand description
Plugin API context - provides safe access to editor functionality
Implementations§
Source§impl PluginApi
impl PluginApi
Sourcepub fn new(
hooks: Arc<RwLock<HookRegistry>>,
commands: Arc<RwLock<CommandRegistry>>,
command_sender: Sender<PluginCommand>,
state_snapshot: Arc<RwLock<EditorStateSnapshot>>,
) -> PluginApi
pub fn new( hooks: Arc<RwLock<HookRegistry>>, commands: Arc<RwLock<CommandRegistry>>, command_sender: Sender<PluginCommand>, state_snapshot: Arc<RwLock<EditorStateSnapshot>>, ) -> PluginApi
Create a new plugin API context
Sourcepub fn register_hook(
&self,
hook_name: &str,
callback: Box<dyn Fn(&HookArgs) -> bool + Sync + Send>,
)
pub fn register_hook( &self, hook_name: &str, callback: Box<dyn Fn(&HookArgs) -> bool + Sync + Send>, )
Register a hook callback
Sourcepub fn unregister_hooks(&self, hook_name: &str)
pub fn unregister_hooks(&self, hook_name: &str)
Remove all hooks for a specific name
Sourcepub fn register_command(&self, command: Command)
pub fn register_command(&self, command: Command)
Register a command
Sourcepub fn unregister_command(&self, name: &str)
pub fn unregister_command(&self, name: &str)
Unregister a command by name
Sourcepub fn send_command(&self, command: PluginCommand) -> Result<(), String>
pub fn send_command(&self, command: PluginCommand) -> Result<(), String>
Send a command to the editor (async/non-blocking)
Sourcepub fn insert_text(
&self,
buffer_id: BufferId,
position: usize,
text: String,
) -> Result<(), String>
pub fn insert_text( &self, buffer_id: BufferId, position: usize, text: String, ) -> Result<(), String>
Insert text at a position in a buffer
Sourcepub fn delete_range(
&self,
buffer_id: BufferId,
range: Range<usize>,
) -> Result<(), String>
pub fn delete_range( &self, buffer_id: BufferId, range: Range<usize>, ) -> Result<(), String>
Delete a range of text from a buffer
Sourcepub fn add_overlay(
&self,
buffer_id: BufferId,
namespace: Option<String>,
range: Range<usize>,
options: OverlayOptions,
) -> Result<(), String>
pub fn add_overlay( &self, buffer_id: BufferId, namespace: Option<String>, range: Range<usize>, options: OverlayOptions, ) -> Result<(), String>
Add an overlay (decoration) to a buffer Add an overlay to a buffer with styling options
Returns an opaque handle that can be used to remove the overlay later.
Colors can be specified as RGB arrays or theme key strings. Theme keys are resolved at render time, so overlays update with theme changes.
Sourcepub fn remove_overlay(
&self,
buffer_id: BufferId,
handle: String,
) -> Result<(), String>
pub fn remove_overlay( &self, buffer_id: BufferId, handle: String, ) -> Result<(), String>
Remove an overlay from a buffer by its handle
Sourcepub fn clear_namespace(
&self,
buffer_id: BufferId,
namespace: String,
) -> Result<(), String>
pub fn clear_namespace( &self, buffer_id: BufferId, namespace: String, ) -> Result<(), String>
Clear all overlays in a namespace from a buffer
Sourcepub fn clear_overlays_in_range(
&self,
buffer_id: BufferId,
start: usize,
end: usize,
) -> Result<(), String>
pub fn clear_overlays_in_range( &self, buffer_id: BufferId, start: usize, end: usize, ) -> Result<(), String>
Clear all overlays that overlap with a byte range Used for targeted invalidation when content changes
Sourcepub fn open_file_at_location(
&self,
path: PathBuf,
line: Option<usize>,
column: Option<usize>,
) -> Result<(), String>
pub fn open_file_at_location( &self, path: PathBuf, line: Option<usize>, column: Option<usize>, ) -> Result<(), String>
Open a file at a specific line and column (1-indexed) This is useful for jumping to locations from git grep, LSP definitions, etc.
Sourcepub fn open_file_in_split(
&self,
split_id: usize,
path: PathBuf,
line: Option<usize>,
column: Option<usize>,
) -> Result<(), String>
pub fn open_file_in_split( &self, split_id: usize, path: PathBuf, line: Option<usize>, column: Option<usize>, ) -> Result<(), String>
Open a file in a specific split at a line and column
Similar to open_file_at_location but targets a specific split pane. The split_id is the ID of the split pane to open the file in.
Sourcepub fn start_prompt(
&self,
label: String,
prompt_type: String,
) -> Result<(), String>
pub fn start_prompt( &self, label: String, prompt_type: String, ) -> Result<(), String>
Start a prompt (minibuffer) with a custom type identifier The prompt_type is used to filter hooks in plugin code
Sourcepub fn set_prompt_suggestions(
&self,
suggestions: Vec<Suggestion>,
) -> Result<(), String>
pub fn set_prompt_suggestions( &self, suggestions: Vec<Suggestion>, ) -> Result<(), String>
Set the suggestions for the current prompt This updates the prompt’s autocomplete/selection list
Sourcepub fn set_prompt_input_sync(&self, sync: bool) -> Result<(), String>
pub fn set_prompt_input_sync(&self, sync: bool) -> Result<(), String>
Enable/disable syncing prompt input text when navigating suggestions
Add a menu item to an existing menu
Add a new top-level menu
Remove a menu item from a menu
Remove a top-level menu
Sourcepub fn create_virtual_buffer(
&self,
name: String,
mode: String,
read_only: bool,
) -> Result<(), String>
pub fn create_virtual_buffer( &self, name: String, mode: String, read_only: bool, ) -> Result<(), String>
Create a new virtual buffer (not backed by a file)
Virtual buffers are used for special displays like diagnostic lists, search results, etc. They have their own mode for keybindings.
Sourcepub fn create_virtual_buffer_with_content(
&self,
name: String,
mode: String,
read_only: bool,
entries: Vec<TextPropertyEntry>,
) -> Result<(), String>
pub fn create_virtual_buffer_with_content( &self, name: String, mode: String, read_only: bool, entries: Vec<TextPropertyEntry>, ) -> Result<(), String>
Create a virtual buffer and set its content in one operation
This is the preferred way to create virtual buffers since it doesn’t require tracking the buffer ID. The buffer is created and populated atomically.
Sourcepub fn set_virtual_buffer_content(
&self,
buffer_id: BufferId,
entries: Vec<TextPropertyEntry>,
) -> Result<(), String>
pub fn set_virtual_buffer_content( &self, buffer_id: BufferId, entries: Vec<TextPropertyEntry>, ) -> Result<(), String>
Set the content of a virtual buffer with text properties
Each entry contains text and metadata properties (e.g., source location).
Sourcepub fn get_text_properties_at_cursor(
&self,
buffer_id: BufferId,
) -> Result<(), String>
pub fn get_text_properties_at_cursor( &self, buffer_id: BufferId, ) -> Result<(), String>
Get text properties at cursor position in a buffer
This triggers a command that will make properties available to plugins.
Sourcepub fn define_mode(
&self,
name: String,
bindings: Vec<(String, String)>,
read_only: bool,
allow_text_input: bool,
) -> Result<(), String>
pub fn define_mode( &self, name: String, bindings: Vec<(String, String)>, read_only: bool, allow_text_input: bool, ) -> Result<(), String>
Define a buffer mode with keybindings
Bindings are specified as (key_string, command_name) pairs.
Sourcepub fn show_buffer(&self, buffer_id: BufferId) -> Result<(), String>
pub fn show_buffer(&self, buffer_id: BufferId) -> Result<(), String>
Switch the current split to display a buffer
Sourcepub fn set_split_scroll(
&self,
split_id: usize,
top_byte: usize,
) -> Result<(), String>
pub fn set_split_scroll( &self, split_id: usize, top_byte: usize, ) -> Result<(), String>
Set the scroll position of a specific split
Sourcepub fn get_highlights(
&self,
buffer_id: BufferId,
range: Range<usize>,
request_id: u64,
) -> Result<(), String>
pub fn get_highlights( &self, buffer_id: BufferId, range: Range<usize>, request_id: u64, ) -> Result<(), String>
Request syntax highlights for a buffer range
Sourcepub fn get_active_buffer_id(&self) -> BufferId
pub fn get_active_buffer_id(&self) -> BufferId
Get the currently active buffer ID
Sourcepub fn get_active_split_id(&self) -> usize
pub fn get_active_split_id(&self) -> usize
Get the currently active split ID
Sourcepub fn get_buffer_info(&self, buffer_id: BufferId) -> Option<BufferInfo>
pub fn get_buffer_info(&self, buffer_id: BufferId) -> Option<BufferInfo>
Get information about a specific buffer
Sourcepub fn list_buffers(&self) -> Vec<BufferInfo>
pub fn list_buffers(&self) -> Vec<BufferInfo>
Get all buffer IDs
Sourcepub fn get_primary_cursor(&self) -> Option<CursorInfo>
pub fn get_primary_cursor(&self) -> Option<CursorInfo>
Get primary cursor information for the active buffer
Sourcepub fn get_all_cursors(&self) -> Vec<CursorInfo>
pub fn get_all_cursors(&self) -> Vec<CursorInfo>
Get all cursor information for the active buffer
Sourcepub fn get_viewport(&self) -> Option<ViewportInfo>
pub fn get_viewport(&self) -> Option<ViewportInfo>
Get viewport information for the active buffer
Sourcepub fn state_snapshot_handle(&self) -> Arc<RwLock<EditorStateSnapshot>>
pub fn state_snapshot_handle(&self) -> Arc<RwLock<EditorStateSnapshot>>
Get access to the state snapshot Arc (for internal use)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for PluginApi
impl RefUnwindSafe for PluginApi
impl Send for PluginApi
impl Sync for PluginApi
impl Unpin for PluginApi
impl UnsafeUnpin for PluginApi
impl UnwindSafe for PluginApi
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more