/kdev-zig

KDevelop plugin which provides Zig language support.

Primary LanguageC++GNU Lesser General Public License v2.1LGPL-2.1

Zig Language Support plugin

This a plugin for KDevelop that adds language support for Zig. It uses zig's builtin parser via a library.

Features

  • Syntax error messages
  • Syntax highlighting of structs, fns, enums. Rainbow colored local vars
  • Goto decl, view doc comments on hover.
  • Highlight usages on hover, lookup uses of fns, vars, etc..
  • Resolve imports from zig std lib and user defined packages
  • Evalutate some comptime expressions (enum switches, if exprs, basic math exprs)
  • Basic typed fn resolution for fns that return structs or typed params (still WIP)
  • Hints for type mismatches, missing args, invalid enum/struct fields, etc..

Screenshots

Resolving basic math expressions image

The following shows it is able to resolve methods of a USBCDC driver using zig's builtin buffered writer to print.

Compiling

First, build and install kdevelop from source so the test libraries are availble.

Build kdev-zig

mkdir build
cd build
cmake -G ninja ..
ninja install

Use zig test duchain/kdevzigastparser.zig to run zig tests. Run the duchaintest for kdev-zig tests.

In case you run into problems with it use ninja uninstall.

To enable debug logging set the following env var.

export QT_LOGGING_RULES="kdevelop.languages.zig.duchain.debug=true;"

Running

Then run KDevelop.

Dependencies

You must have zig 0.12 dev installed somewhere where FindZig.cmake will find it (eg ".local/bin").

License

It was forked from kdev-rust and borrows code from kdev-python so licensed under the GPL.