Addresses #89.
This PR refactors the existing zig-mode to derive from a new generic major mode zig-base-mode that holds common zig major mode configuration and then introduces a new tree-sitter enabled zig-ts-mode major mode that makes use of the zig tree-sitter grammar from https://github.com/maxxnino/tree-sitter-zig.
At the moment zig-ts-mode is pretty usable and supports tree-sitter powered syntax highlighting and indentation. It also derives common functionality like reformatter support, electric indent config, etc. from zig-base-mode. Two notable missing features are navigation and imenu integration (I don't use these much day to day -- I'm also very new to zig and have only been playing around with the language on the side -- so I have not yet implemented them).
I wanted to create this draft PR to outline and share the approach that I've taken. If it's directionally sound, I'm happy to do the remaining work needed to get the PR across the finish line (e.g. readme updates, tests).
I've configured it for use as follows (using elpaca and use-package):
(use-package zig-mode
:elpaca (zig-mode :host github :repo "nanzhong/zig-mode" :branch "tree-sitter")
:demand t
:mode (("\\.zig\\'" . zig-ts-mode)
("\\.zon\\'" . zig-ts-mode))
:init
(add-to-list 'treesit-language-source-alist
'(zig "https://github.com/maxxnino/tree-sitter-zig"))
:hook (zig-ts-mode . (lambda ()
(setq treesit-font-lock-level 4))))