mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-28 09:54:33 +00:00
snippets: Read user settings for workspace configuration (#13356)
Fixes #13334 Use `settings` field in `lsp` subsettings to fix up the settings as wish: ``` "lsp": { "snippet-completion-server": { "settings": { "max_completion_items": 20, "snippets_first": false, "feature_words": true, "feature_snippets": true, "feature_paths": true, "feature_unicode_input": false } } } ``` Release Notes: - N/A
This commit is contained in:
parent
f69c8ca74e
commit
9bdb154a9b
4 changed files with 21 additions and 29 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -13587,7 +13587,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "zed_snippets"
|
||||
version = "0.0.3"
|
||||
version = "0.0.4"
|
||||
dependencies = [
|
||||
"serde_json",
|
||||
"zed_extension_api 0.0.6",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "zed_snippets"
|
||||
version = "0.0.3"
|
||||
version = "0.0.4"
|
||||
edition = "2021"
|
||||
publish = false
|
||||
license = "Apache-2.0"
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
id = "snippets"
|
||||
name = "Snippets"
|
||||
description = "Support for language-agnostic snippets, provided by simple-completion-language-server"
|
||||
version = "0.0.3"
|
||||
version = "0.0.4"
|
||||
schema_version = 1
|
||||
authors = []
|
||||
repository = "https://github.com/zed-industries/zed"
|
||||
|
||||
[language_servers.snippet-completion-server]
|
||||
name = "Snippet Completion Server"
|
||||
languages = ["Astro", "Clojure", "C", "C++", "C#", "Dart", "Elixir", "Elm", "ERB", "Erlang",
|
||||
"Gleam","GLSL", "Go", "Haskell", "HCL", "HEEX", "HTML", "JavaScript","JSDoc","Lua",
|
||||
languages = ["Astro", "Clojure", "C", "C++", "C#", "Dart", "Dockerfile", "Elixir", "Elm", "ERB", "Erlang",
|
||||
"Gleam","GLSL", "Go", "Haskell", "HCL", "HEEX", "HTML", "JavaScript","JSDoc", "JSON", "Lua",
|
||||
"Markdown","OCaml", "PHP", "Python", "Prisma", "PureScript", "Racket", "Ruby", "Rust", "Scheme",
|
||||
"Shell Script", "Svelte", "Terraform", "TOML", "TypeScript", "TSX", "Uiua", "Vue.js", "Zig"]
|
||||
language_ids = { TypeScript = "typescript", TSX = "typescriptreact", JavaScript = "javascript", "Vue.js" = "vue", Terraform = "terraform", "Terraform Vars" = "terraform-vars", PHP = "php", HTML = "html", CSS = "css" }
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use serde_json::json;
|
||||
use std::fs;
|
||||
use zed::LanguageServerId;
|
||||
use zed_extension_api::{self as zed, Result};
|
||||
use zed_extension_api::{self as zed, settings::LspSettings, Result};
|
||||
|
||||
struct SnippetExtension {
|
||||
cached_binary_path: Option<String>,
|
||||
|
@ -106,32 +106,24 @@ impl zed::Extension for SnippetExtension {
|
|||
})
|
||||
}
|
||||
|
||||
fn language_server_initialization_options(
|
||||
&mut self,
|
||||
_language_server_id: &LanguageServerId,
|
||||
_worktree: &zed_extension_api::Worktree,
|
||||
) -> Result<Option<zed_extension_api::serde_json::Value>> {
|
||||
Ok(Some(json!({
|
||||
"max_completion_items": 20,
|
||||
"snippets_first": true,
|
||||
"feature_words": false,
|
||||
"feature_snippets": true,
|
||||
"feature_paths": true
|
||||
})))
|
||||
}
|
||||
|
||||
fn language_server_workspace_configuration(
|
||||
&mut self,
|
||||
_language_server_id: &LanguageServerId,
|
||||
_worktree: &zed_extension_api::Worktree,
|
||||
server_id: &LanguageServerId,
|
||||
worktree: &zed_extension_api::Worktree,
|
||||
) -> Result<Option<zed_extension_api::serde_json::Value>> {
|
||||
Ok(Some(json!({
|
||||
"max_completion_items": 20,
|
||||
"snippets_first": true,
|
||||
"feature_words": false,
|
||||
"feature_snippets": true,
|
||||
"feature_paths": true
|
||||
})))
|
||||
let settings = LspSettings::for_worktree(server_id.as_ref(), worktree)
|
||||
.ok()
|
||||
.and_then(|lsp_settings| lsp_settings.settings.clone())
|
||||
.unwrap_or_else(|| {
|
||||
json!({
|
||||
"max_completion_items": 20,
|
||||
"snippets_first": true,
|
||||
"feature_words": false,
|
||||
"feature_snippets": true,
|
||||
"feature_paths": true
|
||||
})
|
||||
});
|
||||
Ok(Some(settings))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue