Add editor::InsertSnippet action (#44428)
Closes #20036
This introduces new action `editor: insert snippet`. It supports three
modes:
```
["editor::InsertSnippet", {"name": "snippet_name"}]
["editor::InsertSnippet", {"language": "language_name", "name": "snippet_name"}]
["editor::InsertSnippet", {"snippet": "snippet with $1 tab stops"}]
```
## Example usage
### `keymap.json`
```json
{
"context": "Editor",
"bindings": {
// named global snippet
"cmd-k cmd-r": ["editor::InsertSnippet", {"name": "all rights reserved"}],
// named language-specific snippet
"cmd-k cmd-p": ["editor::InsertSnippet", {"language": "rust", "name": "debug-print a value"}],
// inline snippet
"cmd-k cmd-e": ["editor::InsertSnippet", {"snippet": "println!(\"This snippet has multiple lines.\")\nprintln!(\"It belongs to $1 and is very $2.\")"}],
},
},
```
### `~/.config/zed/snippets/rust.json`
```json
{
"debug-print a value": {
"body": "println!(\"$1 = {:?}\", $1)",
},
}
```
### `~/.config/zed/snippets/snippets.json`
```json
{
"all rights reserved": {
"body": "Copyright © ${1:2025} ${2:your name}. All rights reserved.",
},
}
```
## Future extensions
- Support multiline inline snippets using an array of strings using
something similar to `ListOrDirect` in
`snippet_provider::format::VsCodeSnippet`
- When called with no arguments, open a modal to select a snippet to
insert
## Release notes
Release Notes:
- Added `editor::InsertSnippet` action