morloc icon indicating copy to clipboard operation
morloc copied to clipboard

Add morloc language support to Zed editor

Open sckott opened this issue 7 months ago • 12 comments

See https://zed.dev/docs/extensions/languages

Zed is my daily driver, so it'd be nice to have there

sckott avatar Jul 19 '25 18:07 sckott

Looks like the core for this would be a good Tree-sitter grammar. I need to make one anyway since this grammar is used in many of the newer editors (even my editor, neovim, supports it now). Looks like it has a great approach to grammars also.

arendsee avatar Jul 20 '25 23:07 arendsee

The tree-sitter grammar is a bit more complex than I originally thought. It is a full lexer and parser that builds a concrete syntax tree for the language. I have a partially complete grammar now, but as always the trickiest bit is getting the indentation to be handled correctly.

arendsee avatar Jul 28 '25 11:07 arendsee

Okay, thanks for working on this!

sckott avatar Jul 28 '25 18:07 sckott

OK, I've finally got the tree-sitter parser working. All code in the morloc test suite passes the parser without error.

arendsee avatar Aug 06 '25 02:08 arendsee

I've written a minimal extension: zed-morloc

But it is failing to build locally and raising only very vague error messages. This might be an issue with my Zed install (I hear the Linux Zed implementation is a bit janky). Could you try installing the extension @sckott ? Just clone the zed-morloc repo and then hit the "Install Dev Extension" in the Zed extensions tab.

arendsee avatar Aug 06 '25 12:08 arendsee

Thanks @arendsee ! Sorry for the delay. Tried just now. and I was able to install it in Zed (I use Zed Preview as daily driver). However, I was not able to select "Morloc" after installing it for some example code.

sckott avatar Sep 03 '25 21:09 sckott

Thanks @sckott for trying it out! Any helpful error messages by any chance?

arendsee avatar Sep 04 '25 22:09 arendsee

i'll take a look and report back

sckott avatar Sep 09 '25 18:09 sckott

2025-09-09T11:07:54-07:00 ERROR [language::language_registry] failed to load language Morloc:
Error loading brackets query

Caused by:
    Query error at 4:3. Invalid node type \"
2025-09-09T11:07:54-07:00 ERROR [language_selector] failed to load language Morloc: Error loading brackets query

sckott avatar Sep 09 '25 18:09 sckott

This looks like a problem in the brackets.scm file. The double quote matching expression, "\"", should probably be either "\\"" or '"'. I've pushed an update using the single-quotes solution.

On my Linux install, I still see a generic Failed to install grammar 'morloc' error message.

arendsee avatar Sep 11 '25 09:09 arendsee

i'll check

sckott avatar Sep 16 '25 21:09 sckott

tried the latest but it now doesn't have Morloc as an option when I go to select the language 🤔

sckott avatar Sep 16 '25 21:09 sckott