Skip to content

Commit

Permalink
Merge pull request #8 from radu-relantin/main
Browse files Browse the repository at this point in the history
Added windows compatibility
  • Loading branch information
grndctrl authored Jul 14, 2024
2 parents fed0307 + 8a07f05 commit 3c90fff
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 8 deletions.
37 changes: 32 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,36 @@
# Zed GDScript
# Zed GDScript Extension

This extension adds support for the [GDScript](https://docs.godotengine.org/en/stable/classes/index.html) language.
This extension adds support for [GDScript](https://docs.godotengine.org/en/stable/classes/index.html), the scripting language used in the Godot game engine, to the Zed editor.

## Language Server Protocol
## Requirements

Support for the Godot Language Server Protocol (LSP) is provided via `nc` which is assumed to be in your `PATH`.
- Zed Editor
- Godot Engine (version 3.x or 4.x)
- `nc` (netcat) or `ncat` available in your system PATH

The language server is expected to be running on the default ip `127.0.0.1` and port `6005`.
## Installation

1. Install this extension in Zed (instructions specific to Zed's extension installation process)
2. Ensure Godot is installed on your system
3. Set up the Godot language server (see below)

## Setting Up the Godot Language Server

The Godot Language Server should be running separately. Here are the steps to set it up:

1. Open your Godot project
2. Go to Editor > Editor Settings > Text Editor > External
3. Enable "Use External Editor"
4. Set "Exec Path" to the path of your Zed executable
5. Set "Exec Flags" to `{file}`

Then, to start the language server:

1. Go to Editor > Editor Settings > Network > Language Server
3. Set "Remote Host" to `127.0.0.1`
4. Set "Remote Port" to `6005`
5. Restart Godot

## Configuration

This extension assumes the Godot Language Server is running on the default IP `127.0.0.1` and port `6005`. If you need to change these settings, you'll need to modify the extension code (for now...)
11 changes: 8 additions & 3 deletions src/gdscript.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@ impl zed::Extension for GDScriptExtension {
_language_server_id: &LanguageServerId,
worktree: &zed::Worktree,
) -> Result<zed::Command> {
let path = worktree
.which("nc")
.ok_or_else(|| "nc must be installed and available on your $PATH".to_string())?;
let nc_command = if cfg!(target_os = "windows") {
worktree.which("ncat").or_else(|| worktree.which("nc"))
} else {
worktree.which("nc").or_else(|| worktree.which("ncat"))
};

let path = nc_command
.ok_or_else(|| "nc or ncat must be installed and available on your PATH".to_string())?;

Ok(zed::Command {
command: path,
Expand Down

0 comments on commit 3c90fff

Please sign in to comment.