Skip to content

Commit 6eb8236

Browse files
committed
Add Godot LSP support via netcat
This follows the same integration I use for helix editor which uses the netcat (nc) executable to connect to the running Godot LSP. At the moment the IP and Port are hardcoded, which isn't ideal, but in a standard setup this is working as a starting point.
1 parent 0c9dcda commit 6eb8236

File tree

5 files changed

+62
-1
lines changed

5 files changed

+62
-1
lines changed

.gitignore

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
.DS_Store
2+
23
gdscript.wasm
3-
test.gd
4+
extension.wasm
45
grammars
6+
test.gd
7+
8+
debug
9+
target
10+
Cargo.lock

Cargo.toml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[package]
2+
name = "zed_gdscript"
3+
version = "0.0.1"
4+
edition = "2021"
5+
publish = false
6+
license = "MIT"
7+
8+
# [lints]
9+
# workspace = true
10+
11+
[lib]
12+
path = "src/gdscript.rs"
13+
crate-type = ["cdylib"]
14+
15+
[dependencies]
16+
zed_extension_api = "0.0.6"

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
# Zed GDScript
22

33
This extension adds support for the [GDScript](https://docs.godotengine.org/en/stable/classes/index.html) language.
4+
5+
## Language Server Protocol
6+
7+
Support for the Godot Language Server Protocol (LSP) is provided via `nc` which is assumed to be in your `PATH`.
8+
9+
The language server is expected to be running on the default ip `127.0.0.1` and port `6005`.

extension.toml

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ authors = ["Mark Brand <[email protected]>"]
66
description = "GDScript language support for Zed"
77
repository = "https://github.com/grndctrl/zed-gdscript"
88

9+
[language_servers.gdscript]
10+
name = "GDScript Language Server"
11+
language = "GDScript"
12+
913
[grammars.gdscript]
1014
repository = "https://github.com/PrestonKnopp/tree-sitter-gdscript"
1115
commit = "b5dea4d852db65f0872d849c24533eb121e03c76"
16+

src/gdscript.rs

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
use zed::LanguageServerId;
2+
use zed_extension_api::{self as zed, Result};
3+
4+
struct GDScriptExtension;
5+
6+
impl zed::Extension for GDScriptExtension {
7+
fn new() -> Self {
8+
Self
9+
}
10+
11+
fn language_server_command(
12+
&mut self,
13+
_language_server_id: &LanguageServerId,
14+
worktree: &zed::Worktree,
15+
) -> Result<zed::Command> {
16+
let path = worktree
17+
.which("nc")
18+
.ok_or_else(|| "nc must be installed and available on your $PATH".to_string())?;
19+
20+
Ok(zed::Command {
21+
command: path,
22+
args: vec!["127.0.0.1".to_string(), "6005".to_string()],
23+
env: Default::default(),
24+
})
25+
}
26+
}
27+
28+
zed::register_extension!(GDScriptExtension);

0 commit comments

Comments
 (0)