Detailed changes
@@ -17247,13 +17247,6 @@ dependencies = [
"zed_extension_api 0.1.0",
]
-[[package]]
-name = "zed_zig"
-version = "0.3.3"
-dependencies = [
- "zed_extension_api 0.1.0",
-]
-
[[package]]
name = "zeno"
version = "0.2.3"
@@ -181,7 +181,6 @@ members = [
"extensions/test-extension",
"extensions/toml",
"extensions/uiua",
- "extensions/zig",
#
# Tooling
@@ -1,6 +1,6 @@
# Zig
-Zig support is available through the [Zig extension](https://github.com/zed-industries/zed/tree/main/extensions/zig).
+Zig support is available through the [Zig extension](https://github.com/zed-extensions/zig).
- Tree-sitter: [tree-sitter-zig](https://github.com/tree-sitter-grammars/tree-sitter-zig)
- Language Server: [zls](https://github.com/zigtools/zls)
@@ -1,16 +0,0 @@
-[package]
-name = "zed_zig"
-version = "0.3.3"
-edition.workspace = true
-publish.workspace = true
-license = "Apache-2.0"
-
-[lints]
-workspace = true
-
-[lib]
-path = "src/zig.rs"
-crate-type = ["cdylib"]
-
-[dependencies]
-zed_extension_api = "0.1.0"
@@ -1 +0,0 @@
-../../LICENSE-APACHE
@@ -1,15 +0,0 @@
-id = "zig"
-name = "Zig"
-description = "Zig support."
-version = "0.3.3"
-schema_version = 1
-authors = ["Allan Calix <contact@acx.dev>"]
-repository = "https://github.com/zed-industries/zed"
-
-[language_servers.zls]
-name = "zls"
-language = "Zig"
-
-[grammars.zig]
-repository = "https://github.com/tree-sitter-grammars/tree-sitter-zig"
-commit = "eb7d58c2dc4fbeea4745019dee8df013034ae66b"
@@ -1,3 +0,0 @@
-("(" @open ")" @close)
-("[" @open "]" @close)
-("{" @open "}" @close)
@@ -1,12 +0,0 @@
-name = "Zig"
-grammar = "zig"
-path_suffixes = ["zig", "zon"]
-line_comments = ["// ", "/// ", "//! "]
-autoclose_before = ";:.,=}])"
-brackets = [
- { start = "{", end = "}", close = true, newline = true },
- { start = "[", end = "]", close = true, newline = true },
- { start = "(", end = ")", close = true, newline = true },
- { start = "\"", end = "\"", close = true, newline = false, not_in = ["string"] },
- { start = "'", end = "'", close = true, newline = false, not_in = ["string", "comment"] },
-]
@@ -1,295 +0,0 @@
-; Variables
-
-(identifier) @variable
-
-; Parameters
-
-(parameter
- name: (identifier) @variable.parameter)
-
-; Types
-
-(parameter
- type: (identifier) @type)
-
-((identifier) @type
- (#match? @type "^[A-Z_][a-zA-Z0-9_]*"))
-
-(variable_declaration
- (identifier) @type
- "="
- [
- (struct_declaration)
- (enum_declaration)
- (union_declaration)
- (opaque_declaration)
- ])
-
-[
- (builtin_type)
- "anyframe"
-] @type.builtin
-
-; Constants
-
-((identifier) @constant
- (#match? @constant "^[A-Z][A-Z_0-9]+$"))
-
-[
- "null"
- "unreachable"
- "undefined"
-] @constant.builtin
-
-(field_expression
- .
- member: (identifier) @constant)
-
-(enum_declaration
- (container_field
- type: (identifier) @constant))
-
-; Labels
-
-(block_label (identifier) @label)
-
-(break_label (identifier) @label)
-
-; Fields
-
-(field_initializer
- .
- (identifier) @variable.member)
-
-(field_expression
- (_)
- member: (identifier) @property)
-
-(field_expression
- (_)
- member: (identifier) @type (#match? @type "^[A-Z_][a-zA-Z0-9_]*"))
-
-(container_field
- name: (identifier) @property)
-
-(initializer_list
- (assignment_expression
- left: (field_expression
- .
- member: (identifier) @property)))
-
-; Functions
-
-(builtin_identifier) @function.builtin
-
-(call_expression
- function: (identifier) @function.call)
-
-(call_expression
- function: (field_expression
- member: (identifier) @function.call))
-
-(function_declaration
- name: (identifier) @function)
-
-; Modules
-
-(variable_declaration
- (identifier) @module
- (builtin_function
- (builtin_identifier) @keyword.import
- (#any-of? @keyword.import "@import" "@cImport")))
-
-; Builtins
-
-[
- "c"
- "..."
-] @variable.builtin
-
-((identifier) @variable.builtin
- (#eq? @variable.builtin "_"))
-
-(calling_convention
- (identifier) @variable.builtin)
-
-; Keywords
-
-[
- "asm"
- "defer"
- "errdefer"
- "test"
- "error"
- "const"
- "var"
-] @keyword
-
-[
- "struct"
- "union"
- "enum"
- "opaque"
-] @keyword.type
-
-[
- "async"
- "await"
- "suspend"
- "nosuspend"
- "resume"
-] @keyword.coroutine
-
-"fn" @keyword.function
-
-[
- "and"
- "or"
- "orelse"
-] @keyword.operator
-
-"return" @keyword.return
-
-[
- "if"
- "else"
- "switch"
-] @keyword.conditional
-
-[
- "for"
- "while"
- "break"
- "continue"
-] @keyword.repeat
-
-[
- "usingnamespace"
- "export"
-] @keyword.import
-
-[
- "try"
- "catch"
-] @keyword.exception
-
-[
- "volatile"
- "allowzero"
- "noalias"
- "addrspace"
- "align"
- "callconv"
- "linksection"
- "pub"
- "inline"
- "noinline"
- "extern"
- "comptime"
- "packed"
- "threadlocal"
-] @keyword.modifier
-
-; Operator
-
-[
- "="
- "*="
- "*%="
- "*|="
- "/="
- "%="
- "+="
- "+%="
- "+|="
- "-="
- "-%="
- "-|="
- "<<="
- "<<|="
- ">>="
- "&="
- "^="
- "|="
- "!"
- "~"
- "-"
- "-%"
- "&"
- "=="
- "!="
- ">"
- ">="
- "<="
- "<"
- "&"
- "^"
- "|"
- "<<"
- ">>"
- "<<|"
- "+"
- "++"
- "+%"
- "-%"
- "+|"
- "-|"
- "*"
- "/"
- "%"
- "**"
- "*%"
- "*|"
- "||"
- ".*"
- ".?"
- "?"
- ".."
-] @operator
-
-; Literals
-
-(character) @string
-
-([
- (string)
- (multiline_string)
-] @string
- (#set! "priority" 95))
-
-(integer) @number
-
-(float) @number.float
-
-(boolean) @boolean
-
-(escape_sequence) @string.escape
-
-; Punctuation
-
-[
- "["
- "]"
- "("
- ")"
- "{"
- "}"
-] @punctuation.bracket
-
-[
- ";"
- "."
- ","
- ":"
- "=>"
- "->"
-] @punctuation.delimiter
-
-(payload "|" @punctuation.bracket)
-
-; Comments
-
-(comment) @comment
-
-((comment) @comment.documentation
- (#match? @comment.documentation "^//(/|!)"))
@@ -1,17 +0,0 @@
-[
- (block)
- (switch_expression)
- (initializer_list)
-] @indent.begin
-
-(block
- "}" @indent.end)
-
-(_ "[" "]" @end) @indent
-(_ "{" "}" @end) @indent
-(_ "(" ")" @end) @indent
-
-[
- (comment)
- (multiline_string)
-] @indent.ignore
@@ -1,10 +0,0 @@
-((comment) @injection.content
- (#set! injection.language "comment"))
-
-; TODO: add when asm is added
-; (asm_output_item (string) @injection.content
-; (#set! injection.language "asm"))
-; (asm_input_item (string) @injection.content
-; (#set! injection.language "asm"))
-; (asm_clobbers (string) @injection.content
-; (#set! injection.language "asm"))
@@ -1,50 +0,0 @@
-(test_declaration
- "test" @context
- [
- (string)
- (identifier)
- ] @name) @item
-
-(function_declaration
- "pub"? @context
- [
- "extern"
- "export"
- "inline"
- "noinline"
- ]? @context
- "fn" @context
- name: (_) @name) @item
-
-(source_file
- (variable_declaration
- "pub"? @context
- (identifier) @name
- "=" (_) @context) @item)
-
-(struct_declaration
- (variable_declaration
- "pub"? @context
- (identifier) @name
- "=" (_) @context) @item)
-
-(union_declaration
- (variable_declaration
- "pub"? @context
- (identifier) @name
- "=" (_) @context) @item)
-
-(enum_declaration
- (variable_declaration
- "pub"? @context
- (identifier) @name
- "=" (_) @context) @item)
-
-(opaque_declaration
- (variable_declaration
- "pub"? @context
- (identifier) @name
- "=" (_) @context) @item)
-
-(container_field
- . (_) @name) @item
@@ -1,27 +0,0 @@
-(function_declaration
- body: (_
- "{"
- (_)* @function.inside
- "}")) @function.around
-
-(test_declaration
- (block
- "{"
- (_)* @function.inside
- "}")) @function.around
-
-(variable_declaration
- (struct_declaration
- "struct"
- "{"
- [(_) ","]* @class.inside
- "}")) @class.around
-
-(variable_declaration
- (enum_declaration
- "enum"
- "{"
- (_)* @class.inside
- "}")) @class.around
-
-(comment)+ @comment.around
@@ -1,171 +0,0 @@
-use std::fs;
-use zed_extension_api::{self as zed, serde_json, settings::LspSettings, LanguageServerId, Result};
-
-struct ZigExtension {
- cached_binary_path: Option<String>,
-}
-
-#[derive(Clone)]
-struct ZlsBinary {
- path: String,
- args: Option<Vec<String>>,
- environment: Option<Vec<(String, String)>>,
-}
-
-impl ZigExtension {
- fn language_server_binary(
- &mut self,
- language_server_id: &LanguageServerId,
- worktree: &zed::Worktree,
- ) -> Result<ZlsBinary> {
- let mut args: Option<Vec<String>> = None;
-
- let (platform, arch) = zed::current_platform();
- let environment = match platform {
- zed::Os::Mac | zed::Os::Linux => Some(worktree.shell_env()),
- zed::Os::Windows => None,
- };
-
- if let Ok(lsp_settings) = LspSettings::for_worktree("zls", worktree) {
- if let Some(binary) = lsp_settings.binary {
- args = binary.arguments;
- if let Some(path) = binary.path {
- return Ok(ZlsBinary {
- path: path.clone(),
- args,
- environment,
- });
- }
- }
- }
-
- if let Some(path) = worktree.which("zls") {
- return Ok(ZlsBinary {
- path,
- args,
- environment,
- });
- }
-
- if let Some(path) = &self.cached_binary_path {
- if fs::metadata(path).map_or(false, |stat| stat.is_file()) {
- return Ok(ZlsBinary {
- path: path.clone(),
- args,
- environment,
- });
- }
- }
-
- zed::set_language_server_installation_status(
- language_server_id,
- &zed::LanguageServerInstallationStatus::CheckingForUpdate,
- );
-
- // Note that in github releases and on zlstools.org the tar.gz asset is not shown
- // but is available at https://builds.zigtools.org/zls-{os}-{arch}-{version}.tar.gz
- let release = zed::latest_github_release(
- "zigtools/zls",
- zed::GithubReleaseOptions {
- require_assets: true,
- pre_release: false,
- },
- )?;
-
- let arch: &str = match arch {
- zed::Architecture::Aarch64 => "aarch64",
- zed::Architecture::X86 => "x86",
- zed::Architecture::X8664 => "x86_64",
- };
-
- let os: &str = match platform {
- zed::Os::Mac => "macos",
- zed::Os::Linux => "linux",
- zed::Os::Windows => "windows",
- };
-
- let extension: &str = match platform {
- zed::Os::Mac | zed::Os::Linux => "tar.gz",
- zed::Os::Windows => "zip",
- };
-
- let asset_name: String = format!("zls-{}-{}-{}.{}", os, arch, release.version, extension);
- let download_url = format!("https://builds.zigtools.org/{}", asset_name);
-
- let version_dir = format!("zls-{}", release.version);
- let binary_path = match platform {
- zed::Os::Mac | zed::Os::Linux => format!("{version_dir}/zls"),
- zed::Os::Windows => format!("{version_dir}/zls.exe"),
- };
-
- if !fs::metadata(&binary_path).map_or(false, |stat| stat.is_file()) {
- zed::set_language_server_installation_status(
- language_server_id,
- &zed::LanguageServerInstallationStatus::Downloading,
- );
-
- zed::download_file(
- &download_url,
- &version_dir,
- match platform {
- zed::Os::Mac | zed::Os::Linux => zed::DownloadedFileType::GzipTar,
- zed::Os::Windows => zed::DownloadedFileType::Zip,
- },
- )
- .map_err(|e| format!("failed to download file: {e}"))?;
-
- zed::make_file_executable(&binary_path)?;
-
- let entries =
- fs::read_dir(".").map_err(|e| format!("failed to list working directory {e}"))?;
- for entry in entries {
- let entry = entry.map_err(|e| format!("failed to load directory entry {e}"))?;
- if entry.file_name().to_str() != Some(&version_dir) {
- fs::remove_dir_all(entry.path()).ok();
- }
- }
- }
-
- self.cached_binary_path = Some(binary_path.clone());
- Ok(ZlsBinary {
- path: binary_path,
- args,
- environment,
- })
- }
-}
-
-impl zed::Extension for ZigExtension {
- fn new() -> Self {
- Self {
- cached_binary_path: None,
- }
- }
-
- fn language_server_command(
- &mut self,
- language_server_id: &LanguageServerId,
- worktree: &zed::Worktree,
- ) -> Result<zed::Command> {
- let zls_binary = self.language_server_binary(language_server_id, worktree)?;
- Ok(zed::Command {
- command: zls_binary.path,
- args: zls_binary.args.unwrap_or_default(),
- env: zls_binary.environment.unwrap_or_default(),
- })
- }
-
- fn language_server_workspace_configuration(
- &mut self,
- _language_server_id: &zed::LanguageServerId,
- worktree: &zed::Worktree,
- ) -> Result<Option<serde_json::Value>> {
- let settings = LspSettings::for_worktree("zls", worktree)
- .ok()
- .and_then(|lsp_settings| lsp_settings.settings.clone())
- .unwrap_or_default();
- Ok(Some(settings))
- }
-}
-
-zed::register_extension!(ZigExtension);