дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-03 16:51:16 +02:00
feat(plugins): open files as text and contribute to Open In (API 1.19) (#6866)
Plugins can open a file in the built-in text editor even when a custom editor claims it (workspace.editor open-as-text, SDK open_editor_as_text), and commands can contribute to the Open In submenu (openIn menu location, file as the argument, no submenus). Docs, versioning table and rebuilt components included. Fixes #6852 Fixes #6853
Цей коміт міститься в:
1 джерело
4a714b2eff
коміт
7f32d04b19
128 files changed
+327
-196
No files matched your search
@@ -2043,8 +2043,14 @@ impl HostApi for PluginApi {
|
||||
fn open_editors(&self, client: &str) -> Result<Vec<ide_plugin::OpenEditor>, HostError> {
|
||||
self.shared.workspace().ok_or_else(|| HostError::NotFound("window project".into()))?.open_editors(client)
|
||||
}
|
||||
fn editor_open(&self, client: &str, path: &Path, selection: Option<ide_core::Range>) -> Result<(), HostError> {
|
||||
self.shared.sink.emit(Some(client), PluginEvent::EditorOpen { path: path.into(), selection });
|
||||
fn editor_open(
|
||||
&self,
|
||||
client: &str,
|
||||
path: &Path,
|
||||
selection: Option<ide_core::Range>,
|
||||
as_text: bool,
|
||||
) -> Result<(), HostError> {
|
||||
self.shared.sink.emit(Some(client), PluginEvent::EditorOpen { path: path.into(), selection, as_text });
|
||||
Ok(())
|
||||
}
|
||||
fn editor_ranges(
|
||||
|
||||
@@ -277,8 +277,9 @@ pub enum PluginEvent {
|
||||
/// Complete replacement of one plugin's console highlight rules (empty: none).
|
||||
#[serde(rename_all = "camelCase")]
|
||||
ConsoleRulesChanged { plugin_id: String, rules: Vec<ide_plugin::ConsoleRule> },
|
||||
/// Open a file in the invoking window.
|
||||
EditorOpen { path: ide_core::IpcPath, selection: Option<ide_core::Range> },
|
||||
/// Open a file in the invoking window; `as_text` in the text editor even when a custom editor claims it.
|
||||
#[serde(rename_all = "camelCase")]
|
||||
EditorOpen { path: ide_core::IpcPath, selection: Option<ide_core::Range>, as_text: bool },
|
||||
/// Change selection or scrolling only in this window's already open editor.
|
||||
EditorRanges { path: ide_core::IpcPath, ranges: Vec<ide_core::Range>, reveal: bool },
|
||||
/// A bounded output channel snapshot, or withdrawal when the plugin stops.
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
//! ```toml
|
||||
//! [[contributes.menus]]
|
||||
//! menu = "editor.context" # projectView.context, editorTab.context, tools, viewItem.context, commit.message,
|
||||
//! # services.context / services.toolbar (API 1.18: the Services tree's own nodes)
|
||||
//! # services.context / services.toolbar (API 1.18: the Services tree's own nodes),
|
||||
//! # openIn (API 1.19: the Open In › submenu of the editor, its tab and the project view)
|
||||
//! command = "check"
|
||||
//! when = "editorLang == java"
|
||||
//! # view = "<view id>" # required for (only allowed on) viewItem.context
|
||||
@@ -116,7 +117,9 @@ const COMMIT_MESSAGE_MENU: &str = "commit.message";
|
||||
/// The Services tool window's context menu and toolbar for the IDE's own nodes (run
|
||||
/// configurations, Docker containers…): the command gets the selected services.
|
||||
const SERVICES_MENUS: [&str; 2] = ["services.context", "services.toolbar"];
|
||||
const MENU_IDS: [&str; 12] = [
|
||||
/// The Open In › submenu of the editor, editor tab and project view menus: the command gets the file.
|
||||
const OPEN_IN_MENU: &str = "openIn";
|
||||
const MENU_IDS: [&str; 13] = [
|
||||
"editor.context",
|
||||
"projectView.context",
|
||||
"editorTab.context",
|
||||
@@ -129,6 +132,7 @@ const MENU_IDS: [&str; 12] = [
|
||||
"searchResults.context",
|
||||
SERVICES_MENUS[0],
|
||||
SERVICES_MENUS[1],
|
||||
OPEN_IN_MENU,
|
||||
];
|
||||
const MAX_TITLE: usize = 256;
|
||||
const MAX_SETTINGS: usize = 200;
|
||||
@@ -196,6 +200,9 @@ pub(super) fn menu(pkg: &Package, decl: toml::Value) -> Result<UiDecl, String> {
|
||||
if SERVICES_MENUS.contains(&d.menu.as_str()) {
|
||||
pkg.manifest.needs_api(&format!("contributes.menus: {}", d.menu), 18)?;
|
||||
}
|
||||
if d.menu == OPEN_IN_MENU {
|
||||
pkg.manifest.needs_api(&format!("contributes.menus: {OPEN_IN_MENU}"), 19)?;
|
||||
}
|
||||
if let Some(w) = &d.when {
|
||||
validate_when(w).map_err(|e| format!("contributes.menus: {e}"))?;
|
||||
}
|
||||
@@ -1402,6 +1409,22 @@ mod tests {
|
||||
assert!(menu(&pkg, toolbar).unwrap_err().contains("only for context menus"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn open_in_menu_requires_api_1_19_and_takes_no_submenu() {
|
||||
let pkg = |api: &str| {
|
||||
let manifest = ide_extension::Manifest::parse(&format!(
|
||||
"id='test'\nname='Test'\nversion='1.0.0'\nengines.openidea='{api}'\n[[contributes.commands]]\nid='show'\ntitle='Show'"
|
||||
))
|
||||
.unwrap();
|
||||
Package::new(manifest, std::path::PathBuf::from("/unused"))
|
||||
};
|
||||
let decl = || toml::from_str("menu='openIn'\ncommand='show'\nwhen='editorLang == xml'").unwrap();
|
||||
assert!(menu(&pkg("^1.18"), decl()).unwrap_err().contains("1.19"));
|
||||
assert!(menu(&pkg("^1.19"), decl()).is_ok());
|
||||
let grouped = toml::from_str("menu='openIn'\ncommand='show'\nsubmenu='BPMN'").unwrap();
|
||||
assert!(menu(&pkg("^1.19"), grouped).unwrap_err().contains("only for context menus"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn escape_bindings_need_api_1_10_and_a_when_clause() {
|
||||
let pkg = |api: &str| {
|
||||
|
||||
@@ -184,8 +184,14 @@ pub trait HostApi: Send + Sync {
|
||||
fn reply_content_tab(&self, client: &str, request: &str, reply: crate::ContentTabReply) -> Result<(), HostError>;
|
||||
/// The invoking window's editors.
|
||||
fn open_editors(&self, client: &str) -> Result<Vec<crate::OpenEditor>, HostError>;
|
||||
/// Opens a validated file and optionally selects a range.
|
||||
fn editor_open(&self, client: &str, path: &Path, selection: Option<ide_core::Range>) -> Result<(), HostError>;
|
||||
/// Opens a validated file and optionally selects a range; `as_text` skips custom editors.
|
||||
fn editor_open(
|
||||
&self,
|
||||
client: &str,
|
||||
path: &Path,
|
||||
selection: Option<ide_core::Range>,
|
||||
as_text: bool,
|
||||
) -> Result<(), HostError>;
|
||||
/// Changes the selections, or reveals a range, only in an editor of this window.
|
||||
fn editor_ranges(
|
||||
&self,
|
||||
|
||||
@@ -1211,14 +1211,10 @@ impl editor::Host for StoreData {
|
||||
.map_err(to_wit))
|
||||
}
|
||||
fn open(&mut self, path: String, selection: Option<wit::Range>) -> Fallible<()> {
|
||||
if let Err(e) = self.require_window() {
|
||||
return Ok(Err(e));
|
||||
}
|
||||
let real = match self.openable_path(&path) {
|
||||
Ok(p) => p,
|
||||
Err(e) => return Ok(Err(e)),
|
||||
};
|
||||
Ok(self.host.editor_open(self.client().unwrap(), &real, selection.map(core_range)).map_err(to_wit))
|
||||
self.open_editor(path, selection, false)
|
||||
}
|
||||
fn open_as_text(&mut self, path: String, selection: Option<wit::Range>) -> Fallible<()> {
|
||||
self.open_editor(path, selection, true)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1227,6 +1223,16 @@ fn core_range(r: wit::Range) -> ide_core::Range {
|
||||
}
|
||||
|
||||
impl StoreData {
|
||||
fn open_editor(&mut self, path: String, selection: Option<wit::Range>, as_text: bool) -> Fallible<()> {
|
||||
if let Err(e) = self.require_window() {
|
||||
return Ok(Err(e));
|
||||
}
|
||||
let real = match self.openable_path(&path) {
|
||||
Ok(p) => p,
|
||||
Err(e) => return Ok(Err(e)),
|
||||
};
|
||||
Ok(self.host.editor_open(self.client().unwrap(), &real, selection.map(core_range), as_text).map_err(to_wit))
|
||||
}
|
||||
/// A `project` resource's path: inside the resource's root, or — for a
|
||||
/// project window group — inside any of its member roots (as the editor and
|
||||
/// LSP resolve them). When no root accepts the path, the resource root's own
|
||||
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
8a08e92c30faaa683e531fd91c8a69392d75165cff62153e216008f7abbcb1ea
|
||||
8da08e3230812e4f7cf875362c095ac4885c3262636e51b111e95f2fd962e08a
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
de08e41d78da65ee3de2c709112e8d8905b50432bd59af1701dd633f674fa121
|
||||
9ebd066471e76d6261ab1b4b1e057a85bfdd9abb9f596149798d573336a6d1af
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
455c833fc7d02c083a1ae67d1df507f29581f77d7f8624ff562f1ce982efc730
|
||||
cb058e76b7f4d12ea56b157481874f076fd7d549ae15b11cf914e9af56417331
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
a891db4b18f175648ec47a6c1e20edde0ff266d38b37a1fd2acc8f95ddf0d5b4
|
||||
58b531185ceaefbfcd78c62663717d0875aefc20b7f63bcd9cd2f412defbf9a9
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
30f99018d1c6e518fbc179b2090a7f65856e10b9bed4bb76e605d88acec86393
|
||||
89e515fce0e0cd4029a46c066a2b65592a22178ea77907c520beba447b6bb502
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
39e361f892aa0944bc3eac5a2a9f5a7133deced54ca28193f8d789eaccc1a326
|
||||
4e9714318c72fd137fb71234b00f48378256a7558328414aee1911f9eca640bf
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
f36cf494eb56ebb9d6459a0b84b854ce413eed79e563074bc850de3ee4a4bb2d
|
||||
37f6ac9b07a333793798fd909fec9940fdffadd305a0ae1f15d50a918a6e738b
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
ea314de1d7cdf468b69603bda1766c7361497c9a50fc3e43ab508592d1861fe7
|
||||
46b9a5d0dd6670ae30c5c35909c02bc583e6ce4368aaa0df9aaaf917f141ccbe
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
218dbcd47abeb8ef4b06e13cbbfdd7e24790c11f27c352ce95cfbb6cba61a062
|
||||
c029e8c5d44bd10bfc962747643033ad661406a4e71266060b83b479528ac62f
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
78bad0a6062a0131527a700e0b75ca24fd96162e8fe326b45b5a96c8da8723b4
|
||||
df74de6fd1067530b30e32dc9955d2540cc11a84ab366c1d55286b1f666171d3
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
f90db44c3df10b60fca9e337eba1d3269d8299ca06f5e60cbd9ab7dd65d32fba
|
||||
010115b90cf7c62b304a419a85d2bf1e87a08cf8b71a22b83db7228c74fc879c
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
72aac6f440205694028e52df9932340131f6f30d89fbe3e9363a97110c912336
|
||||
4d64d801f5b861964a90907eb2d35fcfaac0fd5bba32f6fa739d419370ad34bb
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
366172ef7c2d4d2d218d3a653763852983b0af21e7e79ee644c4c216b64b2665
|
||||
91dbf215e6388c1c4c8f09a8194d66888b0060bb44ee590b63a25aa3f8b1cdf8
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
3eac3cab007df8f12e89b044f02348f564a5ec53376743ffccaacc6df383fd37
|
||||
b83536a1c2620edaddc9712ebfcc284d83fd59054f17b4e10c99f3d55fe0a8bf
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
3dab8c8f0177ab0de22a6daccc374c7aaa7e37f6959815edee5641d45bffa3ab
|
||||
2af8aa827092f59d6faa02d4084f79a66bda9ef5211a1450542361702d04e7ae
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
834b90f241c89b7f24217f4ea579810de703da23806b7e21113df5a43ea20dbb
|
||||
93c276cf31b807543d700c2010a128741b269d897993882ff378061b1ed0b56d
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
dbff03557f56e4483e8770c1dcca455c78f4331265613a93475ee28a8c581d79
|
||||
ed76d43bce1e0801aac9010ccbb6d6e5cb680283df6467961156d3ae7a6c3177
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
e674c90857e859a6a7684f9d7899dbdf05f9fe5d310ed809def6bf5403877bda
|
||||
c2c601d62f588a9618844e46e62998e26389a4eaaba1f3be90d0c70c6c19050a
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
0e856198f5839dc675afcc883b43aa9c950c4f73807fe0b1145d976e00bbf2f4
|
||||
10eeb474973e8dea250698a0322ce19705ec86beef29730500ebe611d3f796fa
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
b693136d64688418665ef010b5cb83b86fc4b0adc052b7783530cc53d863085e
|
||||
3d65392e8a6723b33061b243deace1e6ede4d6d258c4c16719ed7533a2b1e3b1
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
cb07913a6a7a1f61521818ffada5b59b8b30e08bc5ef3ed21a9d3a1924ac4445
|
||||
33396b01be200316e5922b6db22e0bd498aad4c77a52254b24134c31c1f7a256
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
47642c0e293829c19528d85d6058b0ea08d68d3380032c4e04937322c88178a2
|
||||
7a98500c653f18188570c91cadc4fc3c7e2bed2fcdd2ba8945a98bc13b7c5af4
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
61cc8a30b6db4a50502b014e4849365cd25b86cc197305d570241186bb1bdbaf
|
||||
7ac9e871f691e989cdef0d4ac3baf8fa338114ad906befd229a124e50897898d
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
72c8ce5f05dd3425fad3e9d8928a06f79f258beaaabcde7f14d5c1c65d3c2d97
|
||||
e6bfa4a44f635fafd16103235424e40b8cd6849ed83f582af84fc9baac800882
|
||||
@@ -1 +1 @@
|
||||
667102db97617a5149e1a4fb1f81bb57a25cf0265cf08b37f76a976b42bd54a8
|
||||
7eccc42692e9d289e15fe131195ed67ebe9102f387cef02da19a581f37d729dc
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
70b2bd11475b9cafb21ebe8cd2dfc888e442c9de0220d93c85fb3a25b45e96da
|
||||
a09c1f93e121b27d71bb6ac717a1222e240799f2bc0a6def8805ab4a62bed1a6
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
1f633882937a9b8fa9d73466cd96dd6f6e3ff620148fd831fdced35fc2d79517
|
||||
8d34f0080002a1a68df23ba8fefb5cec34a986ca4610866f99007c6c62792ff5
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
6e9a028bd06f3d79f05462a82bcc250a589f938c029633a73d28750a8ae72dbe
|
||||
f1f0d0d2d8c45fe4ce0c948a129c68e433f2d4ae068deb8bd7cbceb0ea015f27
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
c5f5ca68fac368b962ce152be508927ed42c60d1796adb9eadfc9c903766cc4c
|
||||
8d107d10fbb8916cce95a4e2291830449f2dc9d6341e3dbba51a5ae7642d17d5
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
cba28a450b12be242a5e0e4285ea61af01b055eced9d28c0c102383186596a1c
|
||||
966ae3021ee93af461d19c78053d42918917e7a754dac5becda21fba3e8b9ddd
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
baf3b27249b7cf07ffc62f1d5a6989ac17738d19074bb5d927ada85e202eac94
|
||||
161ef690cbb2b0c4aadcc0719f9dbe58a5ee0235895427f8137816d270d0ba6a
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
a47ab3aaf7b2858899bee1999a6cb031a27436132c202081085da92b7c352321
|
||||
3f1cdd40349346eab3ba5f175d674a202fc6237b5c83388767e3667bea51515f
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
8f6e6b21759f7feeac98aac63d916d470ea1321d8023110b27fe4d4ae383a9e7
|
||||
429ffc70da72af8532d68ebb741fb4a694465b5460567c42ceeb76f66ca02165
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
3d783bec5d19f49de0dd736030eaf693d0b8a5f71799617e7a21d5c939809d17
|
||||
e7141ca998b249cbc0a4dc0565fa621119f25c9a213ccfdbd6d3b62378c47239
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
06b50aaaddd87cd8d412db5d94375c703e205991e5de2db517d6342578fed332
|
||||
5cae8da91f43fa48fa84b0a7c71530f0629cdac20bbbda4cd0d1f405e9d3fb72
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
a0eb78229020e413e63fa93df7cbd631b1b5f02336eb6453bc75de39d41aafd9
|
||||
b1f943eb3661ec38eed856269d30009738ec833a75e7a7a0da09358afa6dff36
|
||||
Бінарний файл не відображається.
+1
-1
@@ -1 +1 @@
|
||||
60aee3fc7660b9f2fe53c7baf446b4a3c12e7f25ae092ed3a05331e2919221b4
|
||||
5f525aeb82bde5016791285b92674347b303edd27770d67028f32dd8071e4ee1
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
77db8099d8a68aafffc6eda2b1388b587a30f4fa83bfd611b968e5d4a680ad38
|
||||
a803720da55b706875485399f700cc6d8d6b7e9adca74dc9931052b4143b4e27
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
eb5277d6c1856122e1f7dc999d8d55067a6327fb3cb89c870661d280c63946fd
|
||||
8dd5fd56707cf120f1bcddec5093c5d5a075faae8dcb4ad17b6797efdcee9621
|
||||
@@ -173,6 +173,7 @@ when = "editorLangId == markdown" # optional
|
||||
| `searchResults.context` | Right-click menu of a search result | 1.4 |
|
||||
| `services.context` | Right-click menu of the IDE's own Services nodes (run configurations, Docker) | 1.18 |
|
||||
| `services.toolbar` | Services toolbar, for the selected IDE-owned nodes | 1.18 |
|
||||
| `openIn` | **Open In** submenu of the editor, editor tab and Project view menus | 1.19 |
|
||||
|
||||
Using a menu newer than 1.0 means declaring at least that API in `engines.openidea`.
|
||||
Every entry names a command the plugin declares. The menu's `when` applies alongside the
|
||||
@@ -207,6 +208,18 @@ command = "kube.logs"
|
||||
when = "viewItemKind == pod"
|
||||
```
|
||||
|
||||
**Open In** (API 1.19). `openIn` entries join the IDE's own **Open In** targets (Project
|
||||
View, Associated Application, Terminal, Browser…) in the editor, editor tab and Project
|
||||
view menus. The command gets the file as for `projectView.context`; `submenu` isn't
|
||||
allowed, since the entry already sits in a submenu.
|
||||
|
||||
```toml
|
||||
[[contributes.menus]]
|
||||
menu = "openIn"
|
||||
command = "bpmn.showInDiagrams"
|
||||
when = "editorLang == xml"
|
||||
```
|
||||
|
||||
**Services menus** (API 1.18). `services.context` and `services.toolbar` act on the nodes
|
||||
the IDE puts in Services itself: run configurations and Docker containers. The `when`
|
||||
clause sees, for each selected service, `serviceProvider` (`runConfigurations` or
|
||||
|
||||
@@ -171,7 +171,10 @@ layout = "tab" # or "split" / "preview": beside the text editor
|
||||
```
|
||||
|
||||
- `priority = "default"` opens matching files in the plugin's editor; `option` makes it
|
||||
available through **Open With**. **Open as Text** opens the text editor.
|
||||
available through **Open With**. **Open as Text** opens the text editor; the plugin's
|
||||
own "view source" does the same with `host::open_editor_as_text(path, selection)`
|
||||
(`editor.open-as-text`, API 1.19), which opens the file like `host::open_editor` but
|
||||
always in the text editor.
|
||||
- `layout = "split"` or `"preview"` opens the file in the text editor with the plugin's
|
||||
editor beside it and the **Editor Only** / **Editor and Preview** / **Preview Only**
|
||||
switch in the tab strip, as for Markdown; the value is the layout files start in.
|
||||
|
||||
@@ -33,7 +33,7 @@ The plugin API has one version number: the version of the WIT package in [`wit/`
|
||||
| 1.16.0 | OpenIDEA 0.1.52 | Optional `completion-list-provider` export: completion marked incomplete is asked again while typing on, without re-asking the language server or other plugins; `decorations.set-markdown`: line-end decorations whose hover is a Markdown card |
|
||||
| 1.17.0 | OpenIDEA 0.1.53 | `decorations.set-styled`: editor decorations with their own `#rrggbb` / `#rrggbbaa` foreground and background, for colors outside the theme palette |
|
||||
| 1.18.0 | OpenIDEA 0.1.54 | `[[contributes.overlays]]`: a package web page floating over the workbench that never takes the keyboard focus, placed and resized through `openidea.overlay`; `[[contributes.dialogs]]`: a package web page in a modal, resizable IDE dialog opened with `views.reveal`, with a `closed` view event and `openidea.dialog.close()`; `events.subscribe-paths-with-options` (`debounce-ms`), `workspace.project.generation` and `FilesChanged` project/generation fields, stale run target/configuration rejection, and the `project-closed` lifecycle event; `execution-configurations`, `run.start-with-options` and `runDetectors.outputMode`: `pipes` or `pty` console output for plugin run configurations; `[[contributes.runAnything]]` with the `run-anything-provider` export: Run Anything lines starting with the plugin's prefix; `views.open-terminal-session-in`: a keyed terminal in a project directory; `workspace.invoking-project`: the project of the window a call serves, also in `gutter-actions` and `hover-actions`; `events.watch-paths` and the `watched-files-changed` event: files and directories outside the project, within `fs.read` grants; the `run-configuration-completion` export: completion in the Arguments field of the plugin's own run configurations; `services.context` and `services.toolbar` menus on the IDE's own Services nodes, with the selected services as the command argument; `executor` on `[[contributes.javaAgents]]`: "Run/Debug '<name>' with <title>" beside Run and Debug, the only launches that get that agent, also startable from the plugin's own commands with a configuration id; grant-scoped `agents.fork-session`: fork a recorded native agent session (`claude` or `codex`) into a new task in the invoking window's project (`agents` capability), with the host validating the session and building the fork invocation itself |
|
||||
| 1.19.0 | In development on `main` | `[capabilities.reasons]`: the plugin's own sentence on why it asks for a capability, shown below the host's description in the permission dialog and Settings › Plugins; `settings.open` / `settings.open-permissions`: open Settings at one of the plugin's own pages or at its permissions; `net.fetch-stream`: a response whose body is read as it arrives (server-sent events, streamed model replies), with the SDK's `host::fetch_stream` and `sse` parser |
|
||||
| 1.19.0 | In development on `main` | `[capabilities.reasons]`: the plugin's own sentence on why it asks for a capability, shown below the host's description in the permission dialog and Settings › Plugins; `settings.open` / `settings.open-permissions`: open Settings at one of the plugin's own pages or at its permissions; `net.fetch-stream`: a response whose body is read as it arrives (server-sent events, streamed model replies), with the SDK's `host::fetch_stream` and `sse` parser; `editor.open-as-text`: open a file in the built-in text editor even when a custom editor claims it (the SDK's `host::open_editor_as_text`); the `openIn` menu: the **Open In** submenu of the editor, its tab and the Project view |
|
||||
|
||||
The full list of what each version added is in [`plugins/README.md`](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md).
|
||||
|
||||
|
||||
@@ -143,20 +143,21 @@ command = "test-selection"
|
||||
when = "editorLangId == markdown" # 可选
|
||||
```
|
||||
|
||||
| `menu` | 位置 | API |
|
||||
| ----------------------- | ---------------------------------------------------- | ---- |
|
||||
| `editor.context` | 编辑器右键菜单 | 1.0 |
|
||||
| `projectView.context` | 项目工具窗口右键菜单 | 1.0 |
|
||||
| `editorTab.context` | 编辑器标签页右键菜单 | 1.0 |
|
||||
| `tools` | 主菜单中的 **工具** | 1.0 |
|
||||
| `viewItem.context` | 插件自有视图中条目的右键菜单(需要 `view`) | 1.2 |
|
||||
| `commit.message` | 提交信息上方的工具栏(提交工具窗口和提交对话框) | 1.3 |
|
||||
| `editor.title` | 编辑器标签栏的动作区 | 1.4 |
|
||||
| `mainToolbar` | 主工具栏 | 1.4 |
|
||||
| `problems.context` | 问题工具窗口中问题条目的右键菜单 | 1.4 |
|
||||
| `searchResults.context` | 搜索结果的右键菜单 | 1.4 |
|
||||
| `services.context` | IDE 自带 Services 节点(运行配置、Docker)的右键菜单 | 1.18 |
|
||||
| `services.toolbar` | 选中 IDE 自带节点时的 Services 工具栏 | 1.18 |
|
||||
| `menu` | 位置 | API |
|
||||
| ----------------------- | -------------------------------------------------------------- | ---- |
|
||||
| `editor.context` | 编辑器右键菜单 | 1.0 |
|
||||
| `projectView.context` | 项目工具窗口右键菜单 | 1.0 |
|
||||
| `editorTab.context` | 编辑器标签页右键菜单 | 1.0 |
|
||||
| `tools` | 主菜单中的 **工具** | 1.0 |
|
||||
| `viewItem.context` | 插件自有视图中条目的右键菜单(需要 `view`) | 1.2 |
|
||||
| `commit.message` | 提交信息上方的工具栏(提交工具窗口和提交对话框) | 1.3 |
|
||||
| `editor.title` | 编辑器标签栏的动作区 | 1.4 |
|
||||
| `mainToolbar` | 主工具栏 | 1.4 |
|
||||
| `problems.context` | 问题工具窗口中问题条目的右键菜单 | 1.4 |
|
||||
| `searchResults.context` | 搜索结果的右键菜单 | 1.4 |
|
||||
| `services.context` | IDE 自带 Services 节点(运行配置、Docker)的右键菜单 | 1.18 |
|
||||
| `services.toolbar` | 选中 IDE 自带节点时的 Services 工具栏 | 1.18 |
|
||||
| `openIn` | 编辑器、编辑器标签页和项目视图右键菜单里的 **打开方式** 子菜单 | 1.19 |
|
||||
|
||||
使用 1.0 之后加入的菜单,需要在 `engines.openidea` 中至少声明对应的 API 版本。每个条目都必须指向插件声明过的命令。
|
||||
菜单的 `when` 与命令自身的 `when` 同时生效。
|
||||
@@ -187,6 +188,17 @@ command = "kube.logs"
|
||||
when = "viewItemKind == pod"
|
||||
```
|
||||
|
||||
**打开方式**(API 1.19)。`openIn` 条目与 IDE 自己的 **打开方式** 目标(项目视图、关联的应用程序、终端、浏览器…)
|
||||
并列,出现在编辑器、编辑器标签页和项目视图的右键菜单里。命令拿到的文件参数与 `projectView.context` 相同;
|
||||
条目本身已在子菜单里,因此不允许 `submenu`。
|
||||
|
||||
```toml
|
||||
[[contributes.menus]]
|
||||
menu = "openIn"
|
||||
command = "bpmn.showInDiagrams"
|
||||
when = "editorLang == xml"
|
||||
```
|
||||
|
||||
**Services 菜单**(API 1.18)。`services.context` 和 `services.toolbar` 作用于 IDE 自己放进 Services 的节点:
|
||||
运行配置和 Docker 容器。`when` 可以对每个选中的服务使用 `serviceProvider`(`runConfigurations` 或 `docker`)、
|
||||
`serviceKind`(运行配置类型,例如 `spring-boot`;容器为 `docker-container`)、`serviceId`、`serviceName`、
|
||||
|
||||
@@ -153,7 +153,8 @@ layout = "tab" # 或 "split" / "preview":显示在文本编
|
||||
```
|
||||
|
||||
- `priority = "default"` 时匹配的文件直接用插件编辑器打开;`option` 时可通过 **打开方式** 选择。
|
||||
**作为文本打开** 会打开文本编辑器。
|
||||
**作为文本打开** 会打开文本编辑器;插件自己的“查看源码”可以用 `host::open_editor_as_text(path, selection)`
|
||||
(`editor.open-as-text`,API 1.19)做同样的事:像 `host::open_editor` 一样打开文件,但总是用文本编辑器。
|
||||
- `layout = "split"` 或 `"preview"` 时,文件在文本编辑器中打开,插件编辑器显示在旁边,标签栏中出现
|
||||
**仅编辑器** / **编辑器和预览** / **仅预览** 切换,和 Markdown 一样;取值决定文件打开时的初始布局。
|
||||
`"tab"`(默认)是独立的标签页。
|
||||
|
||||
@@ -30,7 +30,7 @@ description: "engines.openidea、插件 API 从 1.0 到 1.19 的各个版本,
|
||||
| 1.16.0 | OpenIDEA 0.1.52 | 可选 `completion-list-provider` 导出:标记为不完整的补全在继续输入时再次询问,不会重新询问语言服务器和其他插件;`decorations.set-markdown`:悬停显示 Markdown 卡片的行尾装饰 |
|
||||
| 1.17.0 | OpenIDEA 0.1.53 | `decorations.set-styled`:自带 `#rrggbb` / `#rrggbbaa` 前景色和背景色的编辑器装饰,用于主题调色板之外的颜色 |
|
||||
| 1.18.0 | OpenIDEA 0.1.54 | `[[contributes.overlays]]`:悬浮在工作台上方、从不抢占键盘焦点的插件网页,可通过 `openidea.overlay` 移动和调整大小;`[[contributes.dialogs]]`:插件网页显示在可调整大小的模态对话框中,用 `views.reveal` 打开,关闭时发 `closed` 视图事件,页面可调用 `openidea.dialog.close()`;`events.subscribe-paths-with-options`(`debounce-ms`)、`workspace.project.generation` 与 `FilesChanged` 的 `project`/`generation` 字段、过期运行目标/配置拒绝以及 `project-closed` 生命周期事件;`execution-configurations`、`run.start-with-options` 与 `runDetectors.outputMode`:插件运行配置的控制台输出方式(`pipes` 或 `pty`);`[[contributes.runAnything]]` 与 `run-anything-provider` 导出:以插件前缀开头的 Run Anything 行;`views.open-terminal-session-in`:在项目子目录中打开带 key 的终端;`workspace.invoking-project`:本次调用所服务窗口的项目,`gutter-actions` 和 `hover-actions` 中也可用;`events.watch-paths` 与 `watched-files-changed` 事件:监听项目之外、`fs.read` 授权范围内的文件和目录;`run-configuration-completion` 导出:补全插件自己运行配置的“实参”字段;`services.context` 和 `services.toolbar` 菜单:作用于 IDE 自带的 Services 节点,命令参数是选中的服务;`[[contributes.javaAgents]]` 的 `executor`:运行和调试旁边的“使用 <title> 运行/调试 '<name>'”,只有经它启动时才加载该代理,插件自己的命令也可用配置 id 经它启动;需授权的 `agents.fork-session`:把录制的原生 agent 会话(`claude` 或 `codex`)派生为调用窗口项目中的新任务(`agents` 能力),宿主自行校验会话并构造 fork 调用 |
|
||||
| 1.19.0 | `main` 上开发中 | `[capabilities.reasons]`:插件用一句话说明为什么需要某个能力,显示在授权对话框和 设置 › 插件 中宿主说明的下方;`settings.open` / `settings.open-permissions`:打开设置并定位到插件自己的页面或它的权限;`net.fetch-stream`:边到达边读取响应体(服务器推送事件 SSE、模型的流式回复),SDK 提供 `host::fetch_stream` 和 `sse` 解析器 |
|
||||
| 1.19.0 | `main` 上开发中 | `[capabilities.reasons]`:插件用一句话说明为什么需要某个能力,显示在授权对话框和 设置 › 插件 中宿主说明的下方;`settings.open` / `settings.open-permissions`:打开设置并定位到插件自己的页面或它的权限;`net.fetch-stream`:边到达边读取响应体(服务器推送事件 SSE、模型的流式回复),SDK 提供 `host::fetch_stream` 和 `sse` 解析器;`editor.open-as-text`:即使文件被自定义编辑器认领,也用内置文本编辑器打开(SDK 的 `host::open_editor_as_text`);菜单点 `openIn`:编辑器、标签页和项目视图的 **打开方式** 子菜单 |
|
||||
|
||||
每个版本新增内容的完整列表见 [`plugins/README.md`](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md)。
|
||||
|
||||
|
||||
+28
-28
@@ -136,34 +136,34 @@ work), but 0.1 code no longer runs: rebuild it against the 1.0 SDK.
|
||||
|
||||
### Contribution points
|
||||
|
||||
| Point | Declaration | Code needed |
|
||||
| ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- |
|
||||
| `commands` | `id`, `title`, `category?`, `when?` | to run them |
|
||||
| `themes` | `path` (theme JSON), `editor-scheme?` | no |
|
||||
| `iconThemes` | `id`, `label`, `path` (icon theme JSON, see §5) | no |
|
||||
| `languages` | `path` (`languages/<id>.toml` format, see §6) | no |
|
||||
| `runDetectors` | `id`, `name`, `files`, `command`, `args?`, `test?`, `framework?` (API 1.4; §6.2) | no |
|
||||
| `runConfigurations` | `files`: marker files for the optional `run-configurations` export (API 1.4) | yes |
|
||||
| `javaAgents` | `path` (a jar in the package), `args?`, `vmOptions?`, `jdk?`, `executor?` — a Java agent for Java run configurations, behind `java.agent` (API 1.10; `vmOptions`/`jdk` in 1.14; `executor` in 1.18; _Java agents_) | no |
|
||||
| `skills` | `path` (`skills/<name>/SKILL.md` in the package) — agent skill folder staged into coding-agent sessions (API 1.15) | no |
|
||||
| `mcpTools` | `name`, `description`, `inputSchema` (package JSON Schema path), `readOnly`, `destructive` (API 1.4; see _Plugin MCP tools_) | yes |
|
||||
| `snippets` | `language`, `path` (named JSON snippets; API 1.4) | no |
|
||||
| `providers` | `kinds`, `languages` (editor providers, see _Providers_) | yes |
|
||||
| `secrets` | `name`, `label`, `description?` (see _Network_) | to use them |
|
||||
| `menus` | `menu` (`editor.context`, `projectView.context`, `editorTab.context`, `viewItem.context`, `tools`, `commit.message`; API 1.4: `editor.title`, `mainToolbar`, `problems.context`, `searchResults.context`; API 1.18: `services.context`, `services.toolbar`), `view?`, `command`, `when?` | no |
|
||||
| `keymaps` | `command`, `key`, `mac?` (`Ctrl+Alt+C`; a chord: `Meta+K Meta+C`); `key = "Escape"` with a required `when` (API 1.10) runs after the editor's own Escape handling | no |
|
||||
| `statusBar` | `id`, `text`, `tooltip?`, `command?`, `align?`, `priority?` | no |
|
||||
| `settings` | `schema` (JSON file) or `pages` (API 1.3), `title?` — see _Settings_ | no |
|
||||
| `views` | `id`, `title`, `icon?` (an icon name or a package SVG), `location` (`left`, `right`, `bottom`, `services`), `web?` (_Web views_), `frames?` (API 1.16), `group?`, `when?` (API 1.3) | without `web` |
|
||||
| `customEditors` | `id`, `title`, `patterns` (file names), `priority` (`default`, `option`), `layout?`, `web?`, `frames?`, `binary?` (API 1.16) | without `web` |
|
||||
| `editorPanels` | `id`, `web`, `width` (pixels, 40–400), `when?`, `frames?` (API 1.16) — needs `editor.read` (API 1.9; _Editor panels_) | no |
|
||||
| `overlays` | `id`, `web`, `width`, `height` (pixels, 40–800), `anchor?`, `when?`, `interactive?` — floats over the workbench, never takes the focus (API 1.18; _Overlays_) | no |
|
||||
| `runAnything` | `prefix`, `title?` — Run Anything lines starting with `prefix`, answered by the `run-anything-provider` export (API 1.18; _Run Anything entries_) | no |
|
||||
| `dialogs` | `id`, `title`, `web`, `width` (320–1600), `height` (200–1200) — a modal, resizable dialog opened by `views::reveal(id)` (API 1.18; _Dialogs_) | no |
|
||||
| `fileIcons` | `id`, `patterns` (file names), `icon` (SVG), `iconDark?` — whatever icon theme is in use | no |
|
||||
| `fileTemplates` | `id`, `name`, `extension`, `path`; API 1.3: `fileName`, `variables = [{ name, prompt }]` — New menu | no |
|
||||
| `commitChecks` | `id`, `title` — a before-commit check in Commit Options (see _Commits_) | yes |
|
||||
| `serverCommands` | `server`, `command`, `run` — a language server's client command run by this plugin's command (API 1.9; see _Commands a server hands to the client_) |
|
||||
| Point | Declaration | Code needed |
|
||||
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------- |
|
||||
| `commands` | `id`, `title`, `category?`, `when?` | to run them |
|
||||
| `themes` | `path` (theme JSON), `editor-scheme?` | no |
|
||||
| `iconThemes` | `id`, `label`, `path` (icon theme JSON, see §5) | no |
|
||||
| `languages` | `path` (`languages/<id>.toml` format, see §6) | no |
|
||||
| `runDetectors` | `id`, `name`, `files`, `command`, `args?`, `test?`, `framework?` (API 1.4; §6.2) | no |
|
||||
| `runConfigurations` | `files`: marker files for the optional `run-configurations` export (API 1.4) | yes |
|
||||
| `javaAgents` | `path` (a jar in the package), `args?`, `vmOptions?`, `jdk?`, `executor?` — a Java agent for Java run configurations, behind `java.agent` (API 1.10; `vmOptions`/`jdk` in 1.14; `executor` in 1.18; _Java agents_) | no |
|
||||
| `skills` | `path` (`skills/<name>/SKILL.md` in the package) — agent skill folder staged into coding-agent sessions (API 1.15) | no |
|
||||
| `mcpTools` | `name`, `description`, `inputSchema` (package JSON Schema path), `readOnly`, `destructive` (API 1.4; see _Plugin MCP tools_) | yes |
|
||||
| `snippets` | `language`, `path` (named JSON snippets; API 1.4) | no |
|
||||
| `providers` | `kinds`, `languages` (editor providers, see _Providers_) | yes |
|
||||
| `secrets` | `name`, `label`, `description?` (see _Network_) | to use them |
|
||||
| `menus` | `menu` (`editor.context`, `projectView.context`, `editorTab.context`, `viewItem.context`, `tools`, `commit.message`; API 1.4: `editor.title`, `mainToolbar`, `problems.context`, `searchResults.context`; API 1.18: `services.context`, `services.toolbar`; API 1.19: `openIn`), `view?`, `command`, `when?` | no |
|
||||
| `keymaps` | `command`, `key`, `mac?` (`Ctrl+Alt+C`; a chord: `Meta+K Meta+C`); `key = "Escape"` with a required `when` (API 1.10) runs after the editor's own Escape handling | no |
|
||||
| `statusBar` | `id`, `text`, `tooltip?`, `command?`, `align?`, `priority?` | no |
|
||||
| `settings` | `schema` (JSON file) or `pages` (API 1.3), `title?` — see _Settings_ | no |
|
||||
| `views` | `id`, `title`, `icon?` (an icon name or a package SVG), `location` (`left`, `right`, `bottom`, `services`), `web?` (_Web views_), `frames?` (API 1.16), `group?`, `when?` (API 1.3) | without `web` |
|
||||
| `customEditors` | `id`, `title`, `patterns` (file names), `priority` (`default`, `option`), `layout?`, `web?`, `frames?`, `binary?` (API 1.16) | without `web` |
|
||||
| `editorPanels` | `id`, `web`, `width` (pixels, 40–400), `when?`, `frames?` (API 1.16) — needs `editor.read` (API 1.9; _Editor panels_) | no |
|
||||
| `overlays` | `id`, `web`, `width`, `height` (pixels, 40–800), `anchor?`, `when?`, `interactive?` — floats over the workbench, never takes the focus (API 1.18; _Overlays_) | no |
|
||||
| `runAnything` | `prefix`, `title?` — Run Anything lines starting with `prefix`, answered by the `run-anything-provider` export (API 1.18; _Run Anything entries_) | no |
|
||||
| `dialogs` | `id`, `title`, `web`, `width` (320–1600), `height` (200–1200) — a modal, resizable dialog opened by `views::reveal(id)` (API 1.18; _Dialogs_) | no |
|
||||
| `fileIcons` | `id`, `patterns` (file names), `icon` (SVG), `iconDark?` — whatever icon theme is in use | no |
|
||||
| `fileTemplates` | `id`, `name`, `extension`, `path`; API 1.3: `fileName`, `variables = [{ name, prompt }]` — New menu | no |
|
||||
| `commitChecks` | `id`, `title` — a before-commit check in Commit Options (see _Commits_) | yes |
|
||||
| `serverCommands` | `server`, `command`, `run` — a language server's client command run by this plugin's command (API 1.9; see _Commands a server hands to the client_) |
|
||||
|
||||
A `viewItem.context` menu needs `view`, the id of one of the plugin's own
|
||||
views. It adds the commands to the right-click menu of the items in that
|
||||
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
7669b056e8fdfac23cf680bce156f9e5458102f5606d972c46563b75af96e90c
|
||||
fbaa75cf43cf1188b6b5f7621a94739a0f91ba4c8bd13b94fe78a2e8aa17bcc9
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
0482fcab4ffa4ec70dbe1e27d6498cf6a6511cdac2c2effe2547f50b5fc051fe
|
||||
1949060673bb04cc457f22af3a3013185da7fe29af593ca3896b6ce1e519819f
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
079e6faf15706581715b1916319f2e86c368dd728a78abc62269845a0e8f287b
|
||||
a1db2b630b6b91b4bad39d7e06f0808a7d50167a49dcc35adc9c77c031df541c
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
44218a9f34c15352af7351bda6a0e4530fdee0f5a22662452e7425fcc696671f
|
||||
cc6bc4b394758a6f7417d44b2ce1cd6444af26533e233850f92027b15a930a0e
|
||||
Бінарний файл не відображається.
@@ -1 +1 @@
|
||||
f47264da1f56bbccc582b5f5b9f6bd8545fdc94ee640423f262f394c7603f00e
|
||||
d84518ae53618a8762ba01f2ce1cd5d1edfbb020280543fa0fa4f5d86806fa78
|
||||
Бінарний файл не відображається.
Loaded 100 of 128 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Заблокувати користувача