mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-27 08:03:37 +00:00
Plugins can add their own tabs to the double-Shift search dialog: `[[contributes.searchCategories]]` declares a stable id and a title, and the optional `search-provider` export (SDK `search::SearchProvider`) answers the category's queries. Queries keep their raw text (at most 1024 bytes, 1–200 results), are cancellable and time-boxed, and run without prompts. Results open a validated location in the current project or run one of the plugin's own declared commands. Custom tabs stay out of All, so endpoint search and the other tabs are unchanged; disabling, uninstalling or reloading the plugin withdraws its tabs. Plugin API 1.13 (WIT, engine and SDK versions, docs); `plugin_search` is a cancellable command. Every plugin component is rebuilt. Closes #3966 Co-authored-by: DeH40 <26625570+DeH40@users.noreply.github.com>
31 lines
1000 B
Rust
31 lines
1000 B
Rust
//! Custom categories in Search Everywhere (API 1.11).
|
|
use crate::{Error, Invocation, Location};
|
|
|
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
pub enum SearchTarget {
|
|
Location(Location),
|
|
/// A local id declared in `contributes.commands`, and its optional argument.
|
|
Command {
|
|
id: String,
|
|
arg: Option<String>,
|
|
},
|
|
}
|
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
|
pub struct SearchItem {
|
|
pub id: String,
|
|
pub title: String,
|
|
pub description: Option<String>,
|
|
pub target: SearchTarget,
|
|
}
|
|
#[derive(Clone, Debug, Default, PartialEq, Eq)]
|
|
pub struct SearchPage {
|
|
pub items: Vec<SearchItem>,
|
|
pub has_more: bool,
|
|
}
|
|
/// Declare `[[contributes.searchCategories]]` and register with
|
|
/// `register_plugin!(MyPlugin, search)`. Calls are bounded, cancellable and
|
|
/// non-interactive. Return at most `limit` items, in relevance order.
|
|
pub trait SearchProvider {
|
|
fn search(&mut self, category: &str, query: &str, limit: u32, ctx: &Invocation) -> Result<SearchPage, Error>;
|
|
}
|