Short info: I'm started to integrate the roc tree-sitter and the lang_server into the Zed editor code base, after forking and fixing the tree-sitter from https://github.com/faldor20/tree-sitter-roc to work with rust. I'm in the middle of adding the lang server and testing the stuff. BTW. I'm a total rust and zed newbie :sweat_smile: ...
Sweet!
image.png
First working version, zed needs to build from sources of my PR:
https://github.com/h2000/zed/tree/add-roc-lang%237378
Amazing :) hope it will be accepted so I can ditch vscode for my roc adventures :)
You can build it from my branch above in the meantime (rust and Xcode needed)
The official build of zed with roc will take longer, they only want main stream languages directly in their code base, and will provide a plugin api for the others => which is a very good idea for both sides :) . Thats why they closed my PR. I'll port our roc lang stuff to the new plugin api, when they publish these.
(https://github.com/zed-industries/zed/pull/7379)
In the meantime build zed from source is a option. When I have time I'll try generate an unoffical zed binary....
Here the ticket for the language extension plugin infrastructure in ZED https://github.com/zed-industries/zed/issues/7096
@Alf Richter looks like the've just merged that language plugin extension :smiley:
https://zed.dev/blog/language-extensions-part-1
I took a little crack at it... because I didn't see this thread :sweat_smile:
https://github.com/faldor20/zed-roc
but zed is pretty broken on my linux laptop so I can't really test it sadly
I also found your extension @Alf Richter which is a bit further along than my attempt.
I took a look, I think you just need to update the command to run the roc lsp to "roc_langauage_server" and update the tree-sitter queries and commit Id. :)
@Luke Boswell, cool finally.
@Eli Dowling thanks for looking into it. I'll continue with it in the next days and report back here, and will look into your attempt as well :)
Here my current progress:
https://github.com/zed-industries/extensions/pull/432
The extension for Zed is now working (syntax highlighting + language server) and pushed to zed/extensions github.
Until it is fully integrated with zed, it can be used:
git clone https://github.com/h2000/zed-roc
zed: extensions
with the button 'Install Dev Extension' (top right corner).awesome, thanks so much for making this! I've been using Zed for Rust development and I'm stoked to use it for Roc too now! :heart_eyes:
Same! That’s awesome
Hey @Alf Richter, did I perhaps miss a step? When I open the directory with “load dev extension”, a target directory appears with a wasm build, but Zed doesn’t register the extension.
The error reporting inside Zed for extensions is not really present at the moment.
See my question in github zed extensions roc PR:
image.png
Please take a look at the Zed log file:
less ~/Library/Logs/Zed/Zed.log
Zed: open log
(deleted)
I'm using Zed 0.132.3. MacOS 14.4.1.
Thanks for reminding me to check the log. I am seeing a failure to link with clang
error: linking with `clang` failed: exit status: 1
|
= note: LC_ALL="C" PATH="/Users/bryce/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/bin:/Users/bryce/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/bin/self-contained:/Users/bryce/.bun/bin:/Users/bryce/Library/pnpm:/Users/bryce/.deno/bin:/Users/bryce/.nvm/versions/node/v18.17.1/bin:/Users/bryce/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Library/Apple/usr/bin:/usr/local/MacGPG2/bin:/usr/local/go/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Users/bryce/.cargo/bin:/Users/bryce/.local/bin" VSLANG="1033" "clang" "-Wl,-z" "-Wl,stack-size=1048576" "-Wl,--stack-first" "-Wl,--allow-undefined" "-Wl,--no-demangle" "--target=wasm32-wasi" "/Users/bryce/zed-roc/target/wasm32-wasi/debug/deps/zed_roc.11plhyn6ipo7viar.rcgu.o" "/Users/bryce/zed-roc/target/wasm32-wasi/debug/deps/zed_roc.1vei4rcn7kbe74ac.rcgu.o" "/Users/bryce/zed-roc/target/wasm32-wasi/debug/deps/zed_roc.23yaky0p38ruxrxg.rcgu.o" "/Users/bryce/zed-roc/target/wasm32-wasi/debug/deps/zed_roc.254r9n57ez343j56.rcgu.o" "/Users/bryce/zed-roc/target/wasm32-wasi/debug/deps/zed_roc.2kmz0y3jv97t4r08.rcgu.o" "/Users/bryce/zed-roc/target/wasm32-wasi/debug/deps/zed_roc.36di8uldlfvo4x6c.rcgu.o" "/Users/bryce/zed-roc/target/wasm32-wasi/debug/deps/zed_roc.39fivxgqlqtbax5q.rcgu.o" "/Users/bryce/zed-roc/target/wasm32-wasi/debug/deps/zed_roc.4urcaxw6v76vys02.rcgu.o" "/Users/bryce/zed-roc/target/wasm32-wasi/debug/deps/zed_roc.5a8dm17b49z7ydzt.rcgu.o" "/Users/bryce/zed-roc/target/wasm32-wasi/debug/deps/zed_roc.5bpkyd1aajky4dsu.rcgu.o" "/Users/bryce/zed-roc/target/wasm32-wasi/debug/deps/zed_roc.5dsbjiiknb8b4mou.rcgu.o" "/Users/bryce/zed-roc/target/wasm32-wasi/debug/deps/zed_roc.98l8zabvrjnako2.rcgu.o" "/Users/bryce/zed-roc/target/wasm32-wasi/debug/deps/zed_roc.tlp9xsybxq6baya.rcgu.o" "/Users/bryce/zed-roc/target/wasm32-wasi/debug/deps/zed_roc.14gw6g7p6hxl6dk0.rcgu.o" "-L" "/Users/bryce/zed-roc/target/wasm32-wasi/debug/deps" "-L" "/Users/bryce/zed-roc/target/debug/deps" "-L" "/Users/bryce/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wit-bindgen-rt-0.22.0/src" "-L" "/Users/bryce/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/wasm32-wasi/lib" "/Users/bryce/zed-roc/target/wasm32-wasi/debug/deps/libzed_extension_api-4bc53ae7cc620fa7.rlib" "/Users/bryce/zed-roc/target/wasm32-wasi/debug/deps/libwit_bindgen-b3845b82bf0c8a26.rlib" "/Users/bryce/zed-roc/target/wasm32-wasi/debug/deps/libwit_bindgen_rt-4dbaedb4e9afa9b8.rlib" "/Users/bryce/zed-roc/target/wasm32-wasi/debug/deps/libbitflags-1cd067e7651c61cd.rlib" "/Users/bryce/zed-roc/target/wasm32-wasi/debug/deps/libserde_json-c8535d57a65918e3.rlib" "/Users/bryce/zed-roc/target/wasm32-wasi/debug/deps/libitoa-63e76c004c10bfd5.rlib" "/Users/bryce/zed-roc/target/wasm32-wasi/debug/deps/libryu-c70fca966f8d67f8.rlib" "/Users/bryce/zed-roc/target/wasm32-wasi/debug/deps/libserde-02e5f5569d41ac55.rlib" "/Users/bryce/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/wasm32-wasi/lib/libstd-de60da10c915f271.rlib" "/Users/bryce/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/wasm32-wasi/lib/libpanic_abort-2ff3720a26f3bfbc.rlib" "/Users/bryce/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/wasm32-wasi/lib/libwasi-a7797548ce4eeae6.rlib" "/Users/bryce/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/wasm32-wasi/lib/librustc_demangle-2d2a6dd59c5cf747.rlib" "/Users/bryce/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/wasm32-wasi/lib/libstd_detect-256dfe82108a7561.rlib" "/Users/bryce/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/wasm32-wasi/lib/libhashbrown-0fe0478abf0490d0.rlib" "/Users/bryce/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/wasm32-wasi/lib/librustc_std_workspace_alloc-d7e0e2199ba685f0.rlib" "/Users/bryce/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/wasm32-wasi/lib/libminiz_oxide-e3510031f5d59ded.rlib" "/Users/bryce/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/wasm32-wasi/lib/libadler-0a394d8b34770ed7.rlib" "/Users/bryce/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/wasm32-wasi/lib/libunwind-d5d9a1e3135ff952.rlib" "/Users/bryce/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/wasm32-wasi/lib/libcfg_if-0c0c37c26cde79c3.rlib" "/Users/bryce/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/wasm32-wasi/lib/liblibc-6bef7357988c68aa.rlib" "-lc" "/Users/bryce/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/wasm32-wasi/lib/liballoc-8034fbd05189bdbb.rlib" "/Users/bryce/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/wasm32-wasi/lib/librustc_std_workspace_core-c7c23a7c61c36be0.rlib" "/Users/bryce/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/wasm32-wasi/lib/libcore-c236af2463ff1d9c.rlib" "/Users/bryce/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/wasm32-wasi/lib/libcompiler_builtins-b7a1025e8669331b.rlib" "-lwit_bindgen_cabi_realloc" "-B/Users/bryce/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/bin/gcc-ld" "-fuse-ld=lld" "--target=wasm32-wasi" "-nostartfiles" "-L" "/Users/bryce/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/wasm32-wasi/lib" "-L" "/Users/bryce/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/wasm32-wasi/lib/self-contained" "-o" "/Users/bryce/zed-roc/target/wasm32-wasi/debug/deps/zed_roc.wasm" "-Wl,--gc-sections" "-static" "-shared" "-nodefaultlibs"
= note: clang: warning: argument unused during compilation: '-shared' [-Wunused-command-line-argument]
rust-lld: error: entry symbol not defined (pass --no-entry to suppress): _start
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: could not compile `zed_roc` (lib) due to 1 previous error
(Also a lot of 'apple-m1' is not a recognized processor for this target (ignoring processor)
)
@Bryce Miller: I had similar errors about apple-m1 before, my solution was to reinstall my rust installation:
e.g. (or using an other way)
rustup self uninstall
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Reinstalling rustup and the stable toolchain fixed the problem! Thanks!
Roc has (in Zed 0.133.5) an officially zed extension now:
image.png
I did not found a good zentral place to add zed to the official editors list. For the best onboarding experience I'd expect it near/in the installation guide? Should I make a PR to update the GettingStarted.md in roc-lang github, and add an editor section with links to all editors? Or here https://www.roc-lang.org/install ?
Go ahead and make a pr to that page :)
amazing, thank you so much for making this happen!!! :heart_eyes:
My PR for adding an editor section to the getting started readme is ready for review:
https://github.com/roc-lang/roc/pull/6706/files?short_path=15e1597#diff-15e15974446c709f371ea5c1041c2a5fb944f3f8de6ddfbae91a05ae93041255
I found a funny bug in the grammar: it doesn't know crash
is a keyword, but it does know as
is a keyword, resulting in...
Screenshot-2024-05-04-at-7.55.54PM.png
also it doesn't know about import
and exposing
but that's not surprising given how recently the PR for those landed! :big_smile:
I'll take a look at updating to the new suntax in the next week.
If I could get a heads up about when a new syntax is coming a week in advance I should be able to co-ordinate to get a change in so people have an immediate upgrade path :)
@Anton
I've created a new PR to update a second place for new editor exts (this page is linked to the roc website directly). Why do we've two different install pages :) , the tutorial pages links to both?
https://github.com/roc-lang/roc/pull/6735
Thanks @Alf Richter, I'll try to take a look today :)
Is there a way to turn off the auto formatting in zed for roc files?
There's a few issues that are kind of a pain rn. At some point I'd like to submit a fix for them, but if I can just turn of the auto formatting for now that would be nice.
Yes, you can have language-specific config, like:
// ...
"languages": {
"Roc": {
"format_on_save": "off"
},
}
// ...
Thank you
With Zed, I'd also recommend using a monospace font for the UI, because they use the UI font for LSP diagnostics and things don't line up otherwise.
Ideally, they would use the buffer_font_family
for diagnostics or have a distinct setting that defaults to it, so you can still use a proportional font in the rest of the UI.
@Agus Zubiaga can you open an issue on zed for that?
Done: https://github.com/zed-industries/zed/issues/11564
It’s a little subjective because ideally our diagnostics shouldn’t be trying to highlight things that are already visible in the buffer.
However, I still think monospace diagnostics allow more flexibility.
Why do we've two different install pages :) , the tutorial pages links to both?
Thanks for bringing this up @Alf Richter. I'm in favor of avoiding duplication and putting all getting started/install stuff on the Roc website only. Anybody have concerns with that?
does anyone know how to build the roc extension on nixos? am trying to learn how to contribute on zed extensions, can't find anything about building on nix though
Last updated: Jul 06 2025 at 12:14 UTC