prisma: Extract to zed-extensions/prisma repository (#23961)
This PR extracts the Prisma extension to the [zed-extensions/prisma](https://github.com/zed-extensions/prisma) repository. Release Notes: - N/A
This commit is contained in:
parent
429dbf7129
commit
d1b8fedc9c
10 changed files with 1 additions and 202 deletions
7
Cargo.lock
generated
7
Cargo.lock
generated
|
@ -16684,13 +16684,6 @@ dependencies = [
|
|||
"workspace",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zed_prisma"
|
||||
version = "0.0.4"
|
||||
dependencies = [
|
||||
"zed_extension_api 0.1.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zed_proto"
|
||||
version = "0.2.1"
|
||||
|
|
|
@ -170,7 +170,6 @@ members = [
|
|||
"extensions/lua",
|
||||
"extensions/php",
|
||||
"extensions/perplexity",
|
||||
"extensions/prisma",
|
||||
"extensions/proto",
|
||||
"extensions/purescript",
|
||||
"extensions/ruff",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# Prisma
|
||||
|
||||
Prisma support is available through the [Prisma extension](https://github.com/zed-industries/zed/tree/main/extensions/prisma).
|
||||
Prisma support is available through the [Prisma extension](https://github.com/zed-extensions/prisma).
|
||||
|
||||
- Tree Sitter: [victorhqc/tree-sitter-prisma](https://github.com/victorhqc/tree-sitter-prisma)
|
||||
- Language-Server: [prisma/language-tools](https://github.com/prisma/language-tools)
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
[package]
|
||||
name = "zed_prisma"
|
||||
version = "0.0.4"
|
||||
edition.workspace = true
|
||||
publish.workspace = true
|
||||
license = "Apache-2.0"
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[lib]
|
||||
path = "src/prisma.rs"
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[dependencies]
|
||||
zed_extension_api = "0.1.0"
|
|
@ -1 +0,0 @@
|
|||
../../LICENSE-APACHE
|
|
@ -1,15 +0,0 @@
|
|||
id = "prisma"
|
||||
name = "Prisma"
|
||||
description = "Prisma support."
|
||||
version = "0.0.4"
|
||||
schema_version = 1
|
||||
authors = ["Matthew Gramigna <matthewgramigna@gmail.com>", "Victor Quiroz <git@victorhqc.com>"]
|
||||
repository = "https://github.com/zed-industries/zed"
|
||||
|
||||
[language_servers.prisma-language-server]
|
||||
name = "Prisma Language Server"
|
||||
language = "Prisma"
|
||||
|
||||
[grammars.prisma]
|
||||
repository = "https://github.com/victorhqc/tree-sitter-prisma"
|
||||
commit = "beeac50812da9765e29cbb2af1324783033cdca3"
|
|
@ -1,14 +0,0 @@
|
|||
name = "Prisma"
|
||||
grammar = "prisma"
|
||||
path_suffixes = ["prisma"]
|
||||
line_comments = ["// "]
|
||||
brackets = [
|
||||
{ start = "{", end = "}", close = true, newline = true },
|
||||
{ start = "[", end = "]", close = true, newline = true },
|
||||
{ start = "(", end = ")", close = true, newline = true }
|
||||
]
|
||||
tab_size = 2
|
||||
word_characters = ["@"]
|
||||
|
||||
[overrides.string]
|
||||
word_characters = ["@"]
|
|
@ -1,37 +0,0 @@
|
|||
[
|
||||
"datasource"
|
||||
"enum"
|
||||
"generator"
|
||||
"model"
|
||||
"view"
|
||||
] @keyword
|
||||
|
||||
(comment) @comment
|
||||
(developer_comment) @comment
|
||||
|
||||
(number) @number
|
||||
(string) @string
|
||||
(false) @boolean
|
||||
(true) @boolean
|
||||
(arguments) @property
|
||||
(maybe) @punctuation
|
||||
(call_expression (identifier) @function)
|
||||
(enumeral) @constant
|
||||
(identifier) @variable
|
||||
(column_declaration (identifier) (column_type (identifier) @type))
|
||||
(attribute (identifier) @label)
|
||||
(attribute (call_expression (identifier) @label))
|
||||
(attribute (call_expression (member_expression (identifier) @label)))
|
||||
(block_attribute_declaration (identifier) @label)
|
||||
(block_attribute_declaration (call_expression (identifier) @label))
|
||||
(type_expression (identifier) @property)
|
||||
|
||||
"(" @punctuation.bracket
|
||||
")" @punctuation.bracket
|
||||
"[" @punctuation.bracket
|
||||
"]" @punctuation.bracket
|
||||
"{" @punctuation.bracket
|
||||
"}" @punctuation.bracket
|
||||
"=" @operator
|
||||
"@" @operator
|
||||
"@@" @operator
|
|
@ -1,25 +0,0 @@
|
|||
(model_declaration
|
||||
(statement_block
|
||||
"{"
|
||||
(_)* @class.inside
|
||||
"}")) @class.around
|
||||
|
||||
(datasource_declaration
|
||||
(statement_block
|
||||
"{"
|
||||
(_)* @class.inside
|
||||
"}")) @class.around
|
||||
|
||||
(generator_declaration
|
||||
(statement_block
|
||||
"{"
|
||||
(_)* @class.inside
|
||||
"}")) @class.around
|
||||
|
||||
(enum_declaration
|
||||
(enum_block
|
||||
"{"
|
||||
(_)* @class.inside
|
||||
"}")) @class.around
|
||||
|
||||
(developer_comment)+ @comment.around
|
|
@ -1,85 +0,0 @@
|
|||
use std::{env, fs};
|
||||
use zed_extension_api::{self as zed, Result};
|
||||
|
||||
const SERVER_PATH: &str = "node_modules/.bin/prisma-language-server";
|
||||
const PACKAGE_NAME: &str = "@prisma/language-server";
|
||||
|
||||
struct PrismaExtension {
|
||||
did_find_server: bool,
|
||||
}
|
||||
|
||||
impl PrismaExtension {
|
||||
fn server_exists(&self) -> bool {
|
||||
fs::metadata(SERVER_PATH).map_or(false, |stat| stat.is_file())
|
||||
}
|
||||
|
||||
fn server_script_path(&mut self, language_server_id: &zed::LanguageServerId) -> Result<String> {
|
||||
let server_exists = self.server_exists();
|
||||
if self.did_find_server && server_exists {
|
||||
return Ok(SERVER_PATH.to_string());
|
||||
}
|
||||
|
||||
zed::set_language_server_installation_status(
|
||||
language_server_id,
|
||||
&zed::LanguageServerInstallationStatus::CheckingForUpdate,
|
||||
);
|
||||
let version = zed::npm_package_latest_version(PACKAGE_NAME)?;
|
||||
|
||||
if !server_exists
|
||||
|| zed::npm_package_installed_version(PACKAGE_NAME)?.as_ref() != Some(&version)
|
||||
{
|
||||
zed::set_language_server_installation_status(
|
||||
language_server_id,
|
||||
&zed::LanguageServerInstallationStatus::Downloading,
|
||||
);
|
||||
let result = zed::npm_install_package(PACKAGE_NAME, &version);
|
||||
match result {
|
||||
Ok(()) => {
|
||||
if !self.server_exists() {
|
||||
Err(format!(
|
||||
"installed package '{PACKAGE_NAME}' did not contain expected path '{SERVER_PATH}'",
|
||||
))?;
|
||||
}
|
||||
}
|
||||
Err(error) => {
|
||||
if !self.server_exists() {
|
||||
Err(error)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.did_find_server = true;
|
||||
Ok(SERVER_PATH.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
impl zed::Extension for PrismaExtension {
|
||||
fn new() -> Self {
|
||||
Self {
|
||||
did_find_server: false,
|
||||
}
|
||||
}
|
||||
|
||||
fn language_server_command(
|
||||
&mut self,
|
||||
language_server_id: &zed::LanguageServerId,
|
||||
_worktree: &zed::Worktree,
|
||||
) -> Result<zed::Command> {
|
||||
let server_path = self.server_script_path(language_server_id)?;
|
||||
Ok(zed::Command {
|
||||
command: zed::node_binary_path()?,
|
||||
args: vec![
|
||||
env::current_dir()
|
||||
.unwrap()
|
||||
.join(&server_path)
|
||||
.to_string_lossy()
|
||||
.to_string(),
|
||||
"--stdio".to_string(),
|
||||
],
|
||||
env: Default::default(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
zed::register_extension!(PrismaExtension);
|
Loading…
Add table
Add a link
Reference in a new issue