pub enum CoreNotification {
Edit(EditCommand<EditNotification>),
Plugin(PluginNotification),
CloseView {
view_id: ViewId,
},
Save {
view_id: ViewId,
file_path: String,
},
SetTheme {
theme_name: String,
},
ClientStarted {
config_dir: Option<PathBuf>,
client_extras_dir: Option<PathBuf>,
},
ModifyUserConfig {
domain: ConfigDomainExternal,
changes: Table,
},
TracingConfig {
enabled: bool,
},
SaveTrace {
destination: PathBuf,
frontend_samples: Value,
},
SetLanguage {
view_id: ViewId,
language_id: LanguageId,
},
}
Expand description
The notifications which make up the base of the protocol.
§Note
For serialization, all identifiers are converted to “snake_case”.
§Examples
The close_view
command:
extern crate serde_json;
use crate::xi_core::rpc::CoreNotification;
let json = r#"{
"method": "close_view",
"params": { "view_id": "view-id-1" }
}"#;
let cmd: CoreNotification = serde_json::from_str(&json).unwrap();
match cmd {
CoreNotification::CloseView { .. } => (), // expected
other => panic!("Unexpected variant"),
}
The client_started
command:
extern crate serde_json;
use crate::xi_core::rpc::CoreNotification;
let json = r#"{
"method": "client_started",
"params": {}
}"#;
let cmd: CoreNotification = serde_json::from_str(&json).unwrap();
match cmd {
CoreNotification::ClientStarted { .. } => (), // expected
other => panic!("Unexpected variant"),
}
Variants§
Edit(EditCommand<EditNotification>)
The ‘edit’ namespace, for view-specific editor actions.
The params object has internal method
and params
members,
which are parsed into the appropriate EditNotification
.
§Note:
All edit commands (notifications and requests) include in their
inner params object a view_id
field. On the xi-core side, we
pull out this value during parsing, and use it for routing.
For more on the edit commands, see EditNotification
and
EditRequest
.
§Examples
#[macro_use]
extern crate serde_json;
use crate::xi_core::rpc::*;
let edit = EditCommand {
view_id: 1.into(),
cmd: EditNotification::Insert { chars: "hello!".into() },
};
let rpc = CoreNotification::Edit(edit);
let expected = json!({
"method": "edit",
"params": {
"method": "insert",
"view_id": "view-id-1",
"params": {
"chars": "hello!",
}
}
});
assert_eq!(serde_json::to_value(&rpc).unwrap(), expected);
Plugin(PluginNotification)
The ‘plugin’ namespace, for interacting with plugins.
As with edit commands, the params object has is a nested RPC,
with the name of the command included as the command
field.
(this should be changed to more accurately reflect the behaviour of the edit commands).
For the available commands, see PluginNotification
.
§Examples
#[macro_use]
extern crate serde_json;
use crate::xi_core::rpc::*;
let rpc = CoreNotification::Plugin(
PluginNotification::Start {
view_id: 1.into(),
plugin_name: "syntect".into(),
});
let expected = json!({
"method": "plugin",
"params": {
"command": "start",
"view_id": "view-id-1",
"plugin_name": "syntect",
}
});
assert_eq!(serde_json::to_value(&rpc).unwrap(), expected);
CloseView
Tells xi-core
to close the specified view.
Save
Tells xi-core
to save the contents of the specified view’s
buffer to the specified path.
SetTheme
Tells xi-core
to set the theme.
ClientStarted
Notifies xi-core
that the client has started.
Fields
ModifyUserConfig
Updates the user’s config for the given domain. Where keys in
changes
are null
, those keys are cleared in the user config
for that domain; otherwise the config is updated with the new
value.
Note: If the client is using file-based config, the only valid
domain argument is ConfigDomain::UserOverride(_)
, which
represents non-persistent view-specific settings, such as when
a user manually changes whitespace settings for a given view.
TracingConfig
Control whether the tracing infrastructure is enabled. This propagates to all peers that should respond by toggling its own infrastructure on/off.
SaveTrace
Save trace data to the given path. The core will first send CoreRequest::CollectTrace to all peers to collect the samples.
SetLanguage
Tells xi-core
to set the language id for the view.