extensions: Add support for snippets provided by extensions (#14020)
For now extensions can only register global snippets, but there'll be follow-up work to support scope attribute in snippets.json. Release Notes: - Extensions can now provide snippets by including `snippets.json` file next to the extension manifest. --------- Co-authored-by: Marshall <marshall@zed.dev> Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
This commit is contained in:
parent
2f2047ab22
commit
6f99399224
12 changed files with 129 additions and 16 deletions
3
Cargo.lock
generated
3
Cargo.lock
generated
|
@ -3932,6 +3932,7 @@ dependencies = [
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"serde_json_lenient",
|
"serde_json_lenient",
|
||||||
"settings",
|
"settings",
|
||||||
|
"snippet_provider",
|
||||||
"task",
|
"task",
|
||||||
"theme",
|
"theme",
|
||||||
"toml 0.8.10",
|
"toml 0.8.10",
|
||||||
|
@ -9867,6 +9868,7 @@ dependencies = [
|
||||||
"fs",
|
"fs",
|
||||||
"futures 0.3.28",
|
"futures 0.3.28",
|
||||||
"gpui",
|
"gpui",
|
||||||
|
"parking_lot",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"snippet",
|
"snippet",
|
||||||
|
@ -13654,6 +13656,7 @@ dependencies = [
|
||||||
"settings",
|
"settings",
|
||||||
"simplelog",
|
"simplelog",
|
||||||
"smol",
|
"smol",
|
||||||
|
"snippet_provider",
|
||||||
"supermaven",
|
"supermaven",
|
||||||
"tab_switcher",
|
"tab_switcher",
|
||||||
"task",
|
"task",
|
||||||
|
|
|
@ -11767,7 +11767,7 @@ fn snippet_completions(
|
||||||
let language = buffer.read(cx).language_at(buffer_position);
|
let language = buffer.read(cx).language_at(buffer_position);
|
||||||
let language_name = language.as_ref().map(|language| language.lsp_id());
|
let language_name = language.as_ref().map(|language| language.lsp_id());
|
||||||
let snippet_store = project.snippets().read(cx);
|
let snippet_store = project.snippets().read(cx);
|
||||||
let snippets = snippet_store.snippets_for(language_name);
|
let snippets = snippet_store.snippets_for(language_name, cx);
|
||||||
|
|
||||||
if snippets.is_empty() {
|
if snippets.is_empty() {
|
||||||
return vec![];
|
return vec![];
|
||||||
|
|
|
@ -42,6 +42,7 @@ semantic_version.workspace = true
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
settings.workspace = true
|
settings.workspace = true
|
||||||
|
snippet_provider.workspace = true
|
||||||
theme.workspace = true
|
theme.workspace = true
|
||||||
toml.workspace = true
|
toml.workspace = true
|
||||||
ui.workspace = true
|
ui.workspace = true
|
||||||
|
|
|
@ -526,6 +526,11 @@ fn populate_defaults(manifest: &mut ExtensionManifest, extension_path: &Path) ->
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let snippets_json_path = extension_path.join("snippets.json");
|
||||||
|
if snippets_json_path.exists() {
|
||||||
|
manifest.snippets = Some(snippets_json_path);
|
||||||
|
}
|
||||||
|
|
||||||
// For legacy extensions on the v0 schema (aka, using `extension.json`), we want to populate the grammars in
|
// For legacy extensions on the v0 schema (aka, using `extension.json`), we want to populate the grammars in
|
||||||
// the manifest using the contents of the `grammars` directory.
|
// the manifest using the contents of the `grammars` directory.
|
||||||
if manifest.schema_version.is_v0() {
|
if manifest.schema_version.is_v0() {
|
||||||
|
|
|
@ -78,6 +78,8 @@ pub struct ExtensionManifest {
|
||||||
pub slash_commands: BTreeMap<Arc<str>, SlashCommandManifestEntry>,
|
pub slash_commands: BTreeMap<Arc<str>, SlashCommandManifestEntry>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub indexed_docs_providers: BTreeMap<Arc<str>, IndexedDocsProviderEntry>,
|
pub indexed_docs_providers: BTreeMap<Arc<str>, IndexedDocsProviderEntry>,
|
||||||
|
#[serde(default)]
|
||||||
|
pub snippets: Option<PathBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Default, PartialEq, Eq, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Default, PartialEq, Eq, Debug, Deserialize, Serialize)]
|
||||||
|
@ -206,5 +208,6 @@ fn manifest_from_old_manifest(
|
||||||
language_servers: Default::default(),
|
language_servers: Default::default(),
|
||||||
slash_commands: BTreeMap::default(),
|
slash_commands: BTreeMap::default(),
|
||||||
indexed_docs_providers: BTreeMap::default(),
|
indexed_docs_providers: BTreeMap::default(),
|
||||||
|
snippets: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ use release_channel::ReleaseChannel;
|
||||||
use semantic_version::SemanticVersion;
|
use semantic_version::SemanticVersion;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
|
use snippet_provider::SnippetRegistry;
|
||||||
use std::ops::RangeInclusive;
|
use std::ops::RangeInclusive;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::{
|
use std::{
|
||||||
|
@ -115,6 +116,7 @@ pub struct ExtensionStore {
|
||||||
theme_registry: Arc<ThemeRegistry>,
|
theme_registry: Arc<ThemeRegistry>,
|
||||||
slash_command_registry: Arc<SlashCommandRegistry>,
|
slash_command_registry: Arc<SlashCommandRegistry>,
|
||||||
indexed_docs_registry: Arc<IndexedDocsRegistry>,
|
indexed_docs_registry: Arc<IndexedDocsRegistry>,
|
||||||
|
snippet_registry: Arc<SnippetRegistry>,
|
||||||
modified_extensions: HashSet<Arc<str>>,
|
modified_extensions: HashSet<Arc<str>>,
|
||||||
wasm_host: Arc<WasmHost>,
|
wasm_host: Arc<WasmHost>,
|
||||||
wasm_extensions: Vec<(Arc<ExtensionManifest>, WasmExtension)>,
|
wasm_extensions: Vec<(Arc<ExtensionManifest>, WasmExtension)>,
|
||||||
|
@ -193,6 +195,7 @@ pub fn init(
|
||||||
theme_registry,
|
theme_registry,
|
||||||
SlashCommandRegistry::global(cx),
|
SlashCommandRegistry::global(cx),
|
||||||
IndexedDocsRegistry::global(cx),
|
IndexedDocsRegistry::global(cx),
|
||||||
|
SnippetRegistry::global(cx),
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
@ -227,6 +230,7 @@ impl ExtensionStore {
|
||||||
theme_registry: Arc<ThemeRegistry>,
|
theme_registry: Arc<ThemeRegistry>,
|
||||||
slash_command_registry: Arc<SlashCommandRegistry>,
|
slash_command_registry: Arc<SlashCommandRegistry>,
|
||||||
indexed_docs_registry: Arc<IndexedDocsRegistry>,
|
indexed_docs_registry: Arc<IndexedDocsRegistry>,
|
||||||
|
snippet_registry: Arc<SnippetRegistry>,
|
||||||
cx: &mut ModelContext<Self>,
|
cx: &mut ModelContext<Self>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let work_dir = extensions_dir.join("work");
|
let work_dir = extensions_dir.join("work");
|
||||||
|
@ -259,6 +263,7 @@ impl ExtensionStore {
|
||||||
theme_registry,
|
theme_registry,
|
||||||
slash_command_registry,
|
slash_command_registry,
|
||||||
indexed_docs_registry,
|
indexed_docs_registry,
|
||||||
|
snippet_registry,
|
||||||
reload_tx,
|
reload_tx,
|
||||||
tasks: Vec::new(),
|
tasks: Vec::new(),
|
||||||
};
|
};
|
||||||
|
@ -1045,6 +1050,7 @@ impl ExtensionStore {
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
let mut grammars_to_add = Vec::new();
|
let mut grammars_to_add = Vec::new();
|
||||||
let mut themes_to_add = Vec::new();
|
let mut themes_to_add = Vec::new();
|
||||||
|
let mut snippets_to_add = Vec::new();
|
||||||
for extension_id in &extensions_to_load {
|
for extension_id in &extensions_to_load {
|
||||||
let Some(extension) = new_index.extensions.get(extension_id) else {
|
let Some(extension) = new_index.extensions.get(extension_id) else {
|
||||||
continue;
|
continue;
|
||||||
|
@ -1062,6 +1068,11 @@ impl ExtensionStore {
|
||||||
path.extend([Path::new(extension_id.as_ref()), theme_path.as_path()]);
|
path.extend([Path::new(extension_id.as_ref()), theme_path.as_path()]);
|
||||||
path
|
path
|
||||||
}));
|
}));
|
||||||
|
snippets_to_add.extend(extension.manifest.snippets.iter().map(|snippets_path| {
|
||||||
|
let mut path = self.installed_dir.clone();
|
||||||
|
path.extend([Path::new(extension_id.as_ref()), snippets_path.as_path()]);
|
||||||
|
path
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
self.language_registry
|
self.language_registry
|
||||||
|
@ -1097,6 +1108,7 @@ impl ExtensionStore {
|
||||||
let wasm_host = self.wasm_host.clone();
|
let wasm_host = self.wasm_host.clone();
|
||||||
let root_dir = self.installed_dir.clone();
|
let root_dir = self.installed_dir.clone();
|
||||||
let theme_registry = self.theme_registry.clone();
|
let theme_registry = self.theme_registry.clone();
|
||||||
|
let snippet_registry = self.snippet_registry.clone();
|
||||||
let extension_entries = extensions_to_load
|
let extension_entries = extensions_to_load
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|name| new_index.extensions.get(name).cloned())
|
.filter_map(|name| new_index.extensions.get(name).cloned())
|
||||||
|
@ -1117,6 +1129,15 @@ impl ExtensionStore {
|
||||||
.await
|
.await
|
||||||
.log_err();
|
.log_err();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for snippets_path in &snippets_to_add {
|
||||||
|
if let Some(snippets_contents) = fs.load(snippets_path).await.log_err()
|
||||||
|
{
|
||||||
|
snippet_registry
|
||||||
|
.register_snippets(snippets_path, &snippets_contents)
|
||||||
|
.log_err();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.await;
|
.await;
|
||||||
|
|
|
@ -19,6 +19,7 @@ use parking_lot::Mutex;
|
||||||
use project::{Project, DEFAULT_COMPLETION_CONTEXT};
|
use project::{Project, DEFAULT_COMPLETION_CONTEXT};
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use settings::{Settings as _, SettingsStore};
|
use settings::{Settings as _, SettingsStore};
|
||||||
|
use snippet_provider::SnippetRegistry;
|
||||||
use std::{
|
use std::{
|
||||||
ffi::OsString,
|
ffi::OsString,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
|
@ -160,6 +161,7 @@ async fn test_extension_store(cx: &mut TestAppContext) {
|
||||||
language_servers: BTreeMap::default(),
|
language_servers: BTreeMap::default(),
|
||||||
slash_commands: BTreeMap::default(),
|
slash_commands: BTreeMap::default(),
|
||||||
indexed_docs_providers: BTreeMap::default(),
|
indexed_docs_providers: BTreeMap::default(),
|
||||||
|
snippets: None,
|
||||||
}),
|
}),
|
||||||
dev: false,
|
dev: false,
|
||||||
},
|
},
|
||||||
|
@ -185,6 +187,7 @@ async fn test_extension_store(cx: &mut TestAppContext) {
|
||||||
language_servers: BTreeMap::default(),
|
language_servers: BTreeMap::default(),
|
||||||
slash_commands: BTreeMap::default(),
|
slash_commands: BTreeMap::default(),
|
||||||
indexed_docs_providers: BTreeMap::default(),
|
indexed_docs_providers: BTreeMap::default(),
|
||||||
|
snippets: None,
|
||||||
}),
|
}),
|
||||||
dev: false,
|
dev: false,
|
||||||
},
|
},
|
||||||
|
@ -258,6 +261,7 @@ async fn test_extension_store(cx: &mut TestAppContext) {
|
||||||
let theme_registry = Arc::new(ThemeRegistry::new(Box::new(())));
|
let theme_registry = Arc::new(ThemeRegistry::new(Box::new(())));
|
||||||
let slash_command_registry = SlashCommandRegistry::new();
|
let slash_command_registry = SlashCommandRegistry::new();
|
||||||
let indexed_docs_registry = Arc::new(IndexedDocsRegistry::new(cx.executor()));
|
let indexed_docs_registry = Arc::new(IndexedDocsRegistry::new(cx.executor()));
|
||||||
|
let snippet_registry = Arc::new(SnippetRegistry::new());
|
||||||
let node_runtime = FakeNodeRuntime::new();
|
let node_runtime = FakeNodeRuntime::new();
|
||||||
|
|
||||||
let store = cx.new_model(|cx| {
|
let store = cx.new_model(|cx| {
|
||||||
|
@ -272,6 +276,7 @@ async fn test_extension_store(cx: &mut TestAppContext) {
|
||||||
theme_registry.clone(),
|
theme_registry.clone(),
|
||||||
slash_command_registry.clone(),
|
slash_command_registry.clone(),
|
||||||
indexed_docs_registry.clone(),
|
indexed_docs_registry.clone(),
|
||||||
|
snippet_registry.clone(),
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
@ -345,6 +350,7 @@ async fn test_extension_store(cx: &mut TestAppContext) {
|
||||||
language_servers: BTreeMap::default(),
|
language_servers: BTreeMap::default(),
|
||||||
slash_commands: BTreeMap::default(),
|
slash_commands: BTreeMap::default(),
|
||||||
indexed_docs_providers: BTreeMap::default(),
|
indexed_docs_providers: BTreeMap::default(),
|
||||||
|
snippets: None,
|
||||||
}),
|
}),
|
||||||
dev: false,
|
dev: false,
|
||||||
},
|
},
|
||||||
|
@ -396,6 +402,7 @@ async fn test_extension_store(cx: &mut TestAppContext) {
|
||||||
theme_registry.clone(),
|
theme_registry.clone(),
|
||||||
slash_command_registry,
|
slash_command_registry,
|
||||||
indexed_docs_registry,
|
indexed_docs_registry,
|
||||||
|
snippet_registry,
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
@ -477,6 +484,7 @@ async fn test_extension_store_with_test_extension(cx: &mut TestAppContext) {
|
||||||
let theme_registry = Arc::new(ThemeRegistry::new(Box::new(())));
|
let theme_registry = Arc::new(ThemeRegistry::new(Box::new(())));
|
||||||
let slash_command_registry = SlashCommandRegistry::new();
|
let slash_command_registry = SlashCommandRegistry::new();
|
||||||
let indexed_docs_registry = Arc::new(IndexedDocsRegistry::new(cx.executor()));
|
let indexed_docs_registry = Arc::new(IndexedDocsRegistry::new(cx.executor()));
|
||||||
|
let snippet_registry = Arc::new(SnippetRegistry::new());
|
||||||
let node_runtime = FakeNodeRuntime::new();
|
let node_runtime = FakeNodeRuntime::new();
|
||||||
|
|
||||||
let mut status_updates = language_registry.language_server_binary_statuses();
|
let mut status_updates = language_registry.language_server_binary_statuses();
|
||||||
|
@ -568,6 +576,7 @@ async fn test_extension_store_with_test_extension(cx: &mut TestAppContext) {
|
||||||
theme_registry.clone(),
|
theme_registry.clone(),
|
||||||
slash_command_registry,
|
slash_command_registry,
|
||||||
indexed_docs_registry,
|
indexed_docs_registry,
|
||||||
|
snippet_registry,
|
||||||
cx,
|
cx,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|
|
@ -14,6 +14,7 @@ collections.workspace = true
|
||||||
fs.workspace = true
|
fs.workspace = true
|
||||||
futures.workspace = true
|
futures.workspace = true
|
||||||
gpui.workspace = true
|
gpui.workspace = true
|
||||||
|
parking_lot.workspace = true
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
snippet.workspace = true
|
snippet.workspace = true
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
mod format;
|
mod format;
|
||||||
|
mod registry;
|
||||||
|
|
||||||
use std::{
|
use std::{
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
|
@ -12,8 +13,13 @@ use format::VSSnippetsFile;
|
||||||
use fs::Fs;
|
use fs::Fs;
|
||||||
use futures::stream::StreamExt;
|
use futures::stream::StreamExt;
|
||||||
use gpui::{AppContext, AsyncAppContext, Context, Model, ModelContext, Task, WeakModel};
|
use gpui::{AppContext, AsyncAppContext, Context, Model, ModelContext, Task, WeakModel};
|
||||||
|
pub use registry::*;
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
|
|
||||||
|
pub fn init(cx: &mut AppContext) {
|
||||||
|
SnippetRegistry::init_global(cx);
|
||||||
|
}
|
||||||
|
|
||||||
// Is `None` if the snippet file is global.
|
// Is `None` if the snippet file is global.
|
||||||
type SnippetKind = Option<String>;
|
type SnippetKind = Option<String>;
|
||||||
fn file_stem_to_key(stem: &str) -> SnippetKind {
|
fn file_stem_to_key(stem: &str) -> SnippetKind {
|
||||||
|
@ -168,28 +174,37 @@ impl SnippetProvider {
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn lookup_snippets<'a>(
|
fn lookup_snippets<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
language: &'a SnippetKind,
|
language: &'a SnippetKind,
|
||||||
) -> Option<impl Iterator<Item = Arc<Snippet>> + 'a> {
|
cx: &AppContext,
|
||||||
Some(
|
) -> Vec<Arc<Snippet>> {
|
||||||
self.snippets
|
let mut user_snippets: Vec<_> = self
|
||||||
.get(&language)?
|
.snippets
|
||||||
.iter()
|
.get(&language)
|
||||||
.flat_map(|(_, snippets)| snippets.iter().cloned()),
|
.cloned()
|
||||||
)
|
.unwrap_or_default()
|
||||||
|
.into_iter()
|
||||||
|
.flat_map(|(_, snippets)| snippets.into_iter())
|
||||||
|
.collect();
|
||||||
|
|
||||||
|
let Some(registry) = SnippetRegistry::try_global(cx) else {
|
||||||
|
return user_snippets;
|
||||||
|
};
|
||||||
|
|
||||||
|
let registry_snippets = registry.get_snippets(language);
|
||||||
|
user_snippets.extend(registry_snippets);
|
||||||
|
|
||||||
|
user_snippets
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn snippets_for(&self, language: SnippetKind) -> Vec<Arc<Snippet>> {
|
pub fn snippets_for(&self, language: SnippetKind, cx: &AppContext) -> Vec<Arc<Snippet>> {
|
||||||
let mut requested_snippets: Vec<_> = self
|
let mut requested_snippets = self.lookup_snippets(&language, cx);
|
||||||
.lookup_snippets(&language)
|
|
||||||
.map(|snippets| snippets.collect())
|
|
||||||
.unwrap_or_default();
|
|
||||||
if language.is_some() {
|
if language.is_some() {
|
||||||
// Look up global snippets as well.
|
// Look up global snippets as well.
|
||||||
if let Some(global_snippets) = self.lookup_snippets(&None) {
|
requested_snippets.extend(self.lookup_snippets(&None, cx));
|
||||||
requested_snippets.extend(global_snippets);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
requested_snippets
|
requested_snippets
|
||||||
}
|
}
|
||||||
|
|
53
crates/snippet_provider/src/registry.rs
Normal file
53
crates/snippet_provider/src/registry.rs
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
use std::{path::Path, sync::Arc};
|
||||||
|
|
||||||
|
use anyhow::Result;
|
||||||
|
use collections::HashMap;
|
||||||
|
use gpui::{AppContext, Global, ReadGlobal, UpdateGlobal};
|
||||||
|
use parking_lot::RwLock;
|
||||||
|
|
||||||
|
use crate::{file_stem_to_key, Snippet, SnippetKind};
|
||||||
|
|
||||||
|
struct GlobalSnippetRegistry(Arc<SnippetRegistry>);
|
||||||
|
|
||||||
|
impl Global for GlobalSnippetRegistry {}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
|
pub struct SnippetRegistry {
|
||||||
|
snippets: RwLock<HashMap<SnippetKind, Vec<Arc<Snippet>>>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl SnippetRegistry {
|
||||||
|
pub fn global(cx: &AppContext) -> Arc<Self> {
|
||||||
|
GlobalSnippetRegistry::global(cx).0.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn try_global(cx: &AppContext) -> Option<Arc<Self>> {
|
||||||
|
cx.try_global::<GlobalSnippetRegistry>()
|
||||||
|
.map(|registry| registry.0.clone())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn init_global(cx: &mut AppContext) {
|
||||||
|
GlobalSnippetRegistry::set_global(cx, GlobalSnippetRegistry(Arc::new(Self::new())))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
snippets: RwLock::new(HashMap::default()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn register_snippets(&self, file_path: &Path, contents: &str) -> Result<()> {
|
||||||
|
let snippets_in_file: crate::format::VSSnippetsFile = serde_json::from_str(contents)?;
|
||||||
|
let kind = file_path
|
||||||
|
.file_stem()
|
||||||
|
.and_then(|stem| stem.to_str().and_then(file_stem_to_key));
|
||||||
|
let snippets = crate::file_to_snippets(snippets_in_file);
|
||||||
|
self.snippets.write().insert(kind, snippets);
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn get_snippets(&self, kind: &SnippetKind) -> Vec<Arc<Snippet>> {
|
||||||
|
self.snippets.read().get(kind).cloned().unwrap_or_default()
|
||||||
|
}
|
||||||
|
}
|
|
@ -87,6 +87,7 @@ serde_json.workspace = true
|
||||||
settings.workspace = true
|
settings.workspace = true
|
||||||
simplelog = "0.9"
|
simplelog = "0.9"
|
||||||
smol.workspace = true
|
smol.workspace = true
|
||||||
|
snippet_provider.workspace = true
|
||||||
tab_switcher.workspace = true
|
tab_switcher.workspace = true
|
||||||
supermaven.workspace = true
|
supermaven.workspace = true
|
||||||
task.workspace = true
|
task.workspace = true
|
||||||
|
|
|
@ -206,6 +206,7 @@ fn init_ui(app_state: Arc<AppState>, cx: &mut AppContext) -> Result<()> {
|
||||||
markdown_preview::init(cx);
|
markdown_preview::init(cx);
|
||||||
welcome::init(cx);
|
welcome::init(cx);
|
||||||
extensions_ui::init(cx);
|
extensions_ui::init(cx);
|
||||||
|
snippet_provider::init(cx);
|
||||||
|
|
||||||
// Initialize each completion provider. Settings are used for toggling between them.
|
// Initialize each completion provider. Settings are used for toggling between them.
|
||||||
let copilot_language_server_id = app_state.languages.next_language_server_id();
|
let copilot_language_server_id = app_state.languages.next_language_server_id();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue