Show HN: A Language Server Implementation for SystemD Unit Files
github.comA Language Server Protocol (LSP) implementation for systemd unit files, providing editing support with syntax highlighting, diagnostics, autocompletion, and documentation made with rust.
This is great! There's way too many arcane text file formats (configs, Dockerfiles, workflow definitions etc) without any sort of fast feedback loop on type-safety, documentation etc.
We need more projects like this and if a system is running SystemD, this needs to be enabled and integrated with any LSP-supported editors.
Thanks for the positive feedback! The documentation needs a bit of revision, but I agree there's a lot of configuration file formats that should be supported with language servers that might not necessarily have rich AST parsing as part of their contents.
Would be good to add support for custom units based on generates (e.g. Podman[0]).
[0] https://docs.podman.io/en/latest/markdown/podman-systemd.uni...
This is great, I will definitely try it out in emacs. We use systemd unit files for quite a few things. During holidays I'm planning to uprade my setup to use more lsp and llm! Thanks!
I made a Systemd competitor/aternative https://github.com/andrewbaxter/puteron that uses JSON for everything. The advantage to JSON is you can use a `$schema` key at the top and vscode will do autocompletion, error checking, and (I think) documentation from the jsonschema automatically without needing a custom language server. The power of standards at work!
I was trying to figure out why Systemd decided on their ini-like syntax instead of something like xml or json or whatever. I thought maybe it was some standard that existed at the time, but it does seem to be a custom format unique to systemd...
I was not involved in the decision, but my guess is:
- xml is too verbose
- yaml is too complex + suffers some notable ambiguity issues
- json isn't very human friendly (no comments)
- a lot of other linux software uses ini-style configs
Maybe also to add to that: If you start having things like arrays and dictionaries available, people will start using them in their configuration and then configuration starts becoming an issue. I don't think I've seen a product where the configuration is in YAML or JSON, where the configuration files haven't grown into a confusing mess.
systemd is a different kind of a mess though
That’s very interesting, but systemd is pretty pervasive I really don’t think it’s going anywhere anytime soon for better or for worse. Language servers aren't just adopted in vscode, other editors use them in fact. I am not a VS Code user myself, but I appreciate their implementation of the language server protocol, they did a fantastic job with that.
Yeah sorry, I didn't mean to imply that. Having a language server for systemd is great, I hate having to look things up and I fully expect to still be writing systemd unit files in the forseeable future...
Thanks for this!
the ini-like format was used a lot on DOS and Windows internals.
Which was a part of the argumentation that systemd is very “windows” in its design (hidden errors, monolithic design).
Definitely an established standard (though not as much on UNIX-likes) before TOML was popularised though.
Systemd was modelled after launchd, which is a process manager in macOS. It has nothing to do with Windows.
Launchd uses XML to describe unit files (actually, it uses plists which can be binary, but most of the files are stored in xml).
INI format a "custom format"? It dates back to the 80's, maybe before that. It was the configuration file format.
OTOH, JSON is not a configuration file format. XML might be, but when I see what some people do with XML (ant, maven builds are abysmal, although msbuild xml files are managable), then I want to click unsubscribe.
I'm happy they've chosen INI.
Since the context is systemd, one really should look to Unices in the 1980s rather than to Microsoft Windows in the 1980s. INI files were popularized by DOS+Windows, where there was no formal specification and whatever the Win16 API happened to do was gospel, but were largely nonexistent as a file format on contemporary Unices. Far from being "the" configuration file format, they were barely a blip on the radar and their introduction into Linux was somewhat akin to an invasive species as the Unix world had plenty of file formats and tooling for such formats before then, and the Linux-based operating system world had been busy cloning them all for years.
Things like rc files for shells and .mailrc for BSD Mail were simply scripts written in the program's own command language. The .newsrc used by ReadNews was an example of a common colon-separated key+value format, also seen in Xresources and others. The sendmail.cf used by BSD Sendmail was its own very special thing, indistinguishable from modem line noise.
BSD also widely used the "capabilities" file format, which still exists in many parts of FreeBSD, NetBSD, and OpenBSD to this day for various things such /etc/login.conf and /etc/gettytab and termcap. (In many cases nowadays, cap files are compiled into Berkeley DB or other constant database files by tools such as cap_mkdb and tic.)
Many configuration files in the Unix world were simply flat file tables, with colons, whitespace, or TAB as the field separator. phones(5) is one such TAB-separated table that is in FreeBSD to this day.
You mean you don't like INI because it's a Windows thing? But you also have it in .desktop files, git configs, php configs, samba configs, gtk config files, kde config files, it's a standard config file format for all Qt apps (QSettings).
JSON was popularized by web browsers, yet some people use it for configuration for system desktop apps, which have nothing to do with JavaScript. If usage of JSON is not a problem, then why popularization of INI by DOS+Windows should be a problem?
If you think INI files were a blip on a radar then you might not realise their real popularity. They even have support by the operating system api (WINAPI had support for INI natively, ReadPrivateProfileString). Unless you say that they were a blip on a radar on Unices in the 80s, then I probably would agree.
By the way,
> as the Unix world had plenty of file formats and tooling for such formats before then, and the Linux-based operating system world had been busy cloning them all for years
And that was probably a good motivation to use something established and standard, like an INI format.
this is great.
[flagged]
I think a user of _not_ neovim they'd have to implement their own js client. I honestly can't say much but with INI style formatting it's been mostly based on contstants rather than abstract syntax tree parsing which is unique and a bit of a problem in its own right. I haven't implemented a language server before so this was a learning experience, but I was very pleasantly surprised how adding it to my neovim configuration was. I am hoping at some point it's added to "mason" so it's even easier.
I would create a vscode client, but I am not really very familiar with that ecosystem. Welcoming anyone to implement this in any other editors. This is just the language server implementation with no assumption regarding clients.
I regret to inform you--you just responded to an LLM bot.
it's that bad these days? Yikes :( I will not be redeeming.