Is anybody using the Helix text editor with zig?

I don’t know much about Zig (yet), except that I have read about it a couple of times.
Is anybody familiar with the Helix text editor?
The two things which make it interesting for me are:

  1. Tree-sitter a parser generator tool and an incremental parsing library and

  2. The usage of the Language Server Protocol

Once you installed zig and its LSP zls you are ready to roll (:roller_coaster:) …

% hx --health zig    
Configured language server: zls
Binary for language server: /Users/jan/zls/zls
Configured debug adapter: None
Highlight queries: ✓
Textobject queries: ✘
Indent queries: ✓

Try hx --tutor first to get an impression about the text editing first, but I think it’s a very cool tool to check out the supported language servers and learn more about those languages.

Let me know if there are others out there interested in this topic and/or Helix :+1:

4 Likes

Paging @kristoff who has been using it in his livestreams, maybe he has some ideas to share!

I do use helix. Actually I maintain the tree-sitter config for zig, let me know if You encounter any misbehavior :slight_smile:

2 Likes

Hello @voroskoi :wave:

Good to know. I did see some strange behavior of helix, e.g. that I couldn’t save or leave the editor in case there were problems reported by the language server, but I guess that’s rather a problem of the editor. Zig’s syntax still seems to change a lot from release to release, so it will be important to update things (like the language server) accordingly. Otherwise, if you save the file while the syntax is OK, it’s really fun to play with Helix and zig. I’m also playing with the same language servers (for e.g. other languages) in Emacs (via lsp-mode and eglot), and it’s fun to see how the same messages can be used for different feedback to the user (interface wise). Helix is a good starting point to see what language server(s) are out there for different languages. I also like that you can turn language server support on and off (probably easier in Emacs, for Helix you have to make sure that the language server is not found in the $PATH to turn it off).

How about tree-sitter? Is it always on? Do you have to change the config for each zig release (I assume so), and where does it go?

Anyway, it would be good to hear back from more helix/zig/emacs users about this topic :ear:

1 Like

Hi,

I also encounter this “slow save on quit” problem sometimes. The reason behind this that zls is a bit fragile and when it fails helix tries waiting for a while for its reply (which never comes).
I have read somewhere from @andrewrk that zig will have its own official lsp implementation, in the meantime You can contribute to zls.

I have not tried to switch off tree-sitter in helix, no idea how to do that. The heavy lifting of writing the tree-sitter grammar for zig happens in this repo: GitHub - maxxnino/tree-sitter-zig
I just ported the nvim-based highlighting rules to helix. Which is about how to represent a type, not about the what to represent (and that changes more often). So it is not a big deal, You can find my patches in helix repo if You are interested in the details.

Have a nice day!

2 Likes

Thanks @voroskoi … I will have a look.

I just published a short overview of my tests with Helix (and Emacs) here:

Just to remember all the things I have done/investigated over the last couple of days. There might be more in the future (about this topic), but for me it’s just handy to have all the related links in one place. The only programming language I mentioned was zig :zap:

1 Like

Hello, I just switched to HELIX. I have some setbacks with vscode… I hope that you continue to maintain the LSP which for me works very well, I made a deposit to help those who want like me…

I have my own installation of zig and zls

with alias, Helix finds all his little ones

I would like to know if I didn’t make an error in my language configuration
At the moment, I have no feedback in the logs, on the contrary.

Now there remains the learning time, but since we don’t use that many combinations to program :wink: :wink: it should do it

Hello,
after a few hours, !!! to make a configuration worthy of the name and a lot of reading.
Then work with it, in fact I did some source restructuring, there I was able to gauge the validity of the configuration.
First, I relied on the existing one, then I started again with a basic theme where I could be sure that there was no error ex “dark_plus” close to that of vscode.
I also struggled to have a clean and consistent config.toml, again a lot of reading, and the same to start up the LSP and the language so that the log doesn’t stutter too much.

I posted this for those looking for a concrete example.

Maybe some other choices style color etc. but don’t forget the eyes, and the tips, some don’t want to see the spaces (.)
I tried to make it drinkable.

Now switch to a modal editor, in fact HELIX is more flexible than neovim or vim but also very secure and takes the mouse, the keyboard keys (home… delete etc.) and by configuring correctly, you can copy /past :
Selection (mouse), Y key, then position the cursor, then P key, all in NORMAL mode.

I’m not yet comfortable, but I’m starting to find my feet, I won’t go back, I keep Vscode for small things like md files and not even for debugging it, I prefer my terminal with CODELLDB

https://github.com/AS400JPLPC/zig-helix

I use Helix almost exclusively at this point. In all honesty, it wasn’t because I was invested in the project… I was tired of playing around with my vim config. What finally sold me was how easy it was to get ZLS up and running with it.

There’s certain things I liked about Neovim more - string replacement operations are closer to my personal intuition in Neovim. The only real problem I’ve had with Helix was one unexpected crash that bricked a file I was working on. That was fun :slight_smile:

Haven’t had any problems since - it’s a nice editor… it’s definitely snappy enough to handle large projects. I use it as my general text reader at this point too.

3 Likes

Hello, it could be put in the editors on the Zig page

Can you post a link to the Zig page you are referring to?

manjaro or arch

pacman -S helix

https://ziglang.org/fr/learn/tools/

2 Likes

Hello,
I made some utilities that will greatly simplify your life
Recovery of the last source saved with wbc,
and many other things look at Helix zig zls lldb-vscode needs

the config with the " wraps" for coding and more,
the theme without errors,
the definition of the language without formatting (you can still do it with the “fmt” order LSP is there for that)

I was able to reformat my sources and then make them readable (long parameters)
compilation etc.

1 Like

Sorry, but automatic recovery from “helix.log” is not reliable and especially not designed for that,
I therefore put together a trick to resolve this application tracking problem, hoping that this time it would be the right one.

I think that in a future version, we will have the possibility to obtain variables like filename etc.

I’ve been using Helix as my one and only editor both professionally and as a hobby for more than half a year now. Switched from neovim, because I liked the batteries included and compiled -approach better than (neo)vim’s scripts and Lua plugins which load a bit slow sometimes. So far Helix has supported Zig really well. Still, though, the completions could use more work (I think it is a zls issue).

2 Likes

hello, do you know how to hook the Json like vscode it asks and I don’t know how to do it, or where to find it, thank you

Honestly this editor looks very interesting, I’ll do some testing of it this weekend

2 Likes

Does anyone use helix to do debugging with Zig? I’m not finding a lot of helpful information on the subject (if this functionality for Zig even exists).

hello, there is someone talking about it there

I downloaded, “pacman -S lldb”, after the link with zig this does it automatically.
But I find more flexible, “codelldb-bin”, in an adjacent “terminal” window

1 Like

loock…