aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstephan-cr <stephan.cr@gmx.de>2024-11-02 15:10:46 +0100
committerGitHub <noreply@github.com>2024-11-02 16:10:46 +0200
commit9b466af28bac6d61fd0e717f1a4b0fcd2f18f37f (patch)
treedc910f6d419a9bdf2473612638d1ebbaaf569307
parent0d71b961663bf9e47f049b320f79a47bee6cc657 (diff)
Add Zig project discovery (#1918)
-rw-r--r--CHANGELOG.md1
-rw-r--r--doc/modules/ROOT/pages/projects.adoc3
-rw-r--r--projectile.el7
-rw-r--r--test/projectile-test.el11
4 files changed, 21 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8533750..40ab545 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -18,6 +18,7 @@
* [#1892](https://github.com/bbatsov/projectile/pull/1892): Add category metadata to `completing-read`. (it's used by packages like `marginalia` and `embark`)
* [#1899](https://github.com/bbatsov/projectile/pull/1899): Add support for xmake build utility.
* [#1895](https://github.com/bbatsov/projectile/pull/1895): Modify projectile-mode to add a hook to `buffer-list-update-hook` such that any change in the buffer list will update the selected project.
+* [#1918](https://github.com/bbatsov/projectile/pull/1895): Add Zig project discovery.
### Bugs fixed
diff --git a/doc/modules/ROOT/pages/projects.adoc b/doc/modules/ROOT/pages/projects.adoc
index d1726b7..f41586c 100644
--- a/doc/modules/ROOT/pages/projects.adoc
+++ b/doc/modules/ROOT/pages/projects.adoc
@@ -143,6 +143,9 @@ are the configuration files of various build tools. Out of the box the following
| `xmake.lua`
| xmake project
+
+| `build.zig.zon`
+| Zig project file
|===
There's also Projectile's own `.projectile` which serves both as a project marker
diff --git a/projectile.el b/projectile.el
index 4eda5d0..b849338 100644
--- a/projectile.el
+++ b/projectile.el
@@ -3626,6 +3626,13 @@ a manual COMMAND-TYPE command is created with
:compile "dune build"
:test "dune runtest")
+;; Zig
+(projectile-register-project-type 'zig '("build.zig.zon")
+ :project-file "build.zig.zon"
+ :compile "zig build"
+ :test "zig build test"
+ :run "zig build run")
+
(defvar-local projectile-project-type nil
"Buffer local var for overriding the auto-detected project type.
Normally you'd set this from .dir-locals.el.")
diff --git a/test/projectile-test.el b/test/projectile-test.el
index 472fb3a..d1d7695 100644
--- a/test/projectile-test.el
+++ b/test/projectile-test.el
@@ -1363,7 +1363,16 @@ Just delegates OPERATION and ARGS for all operations except for`shell-command`'.
"project/Project.toml")
(let ((projectile-indexing-method 'native))
(spy-on 'projectile-project-root :and-return-value (file-truename (expand-file-name "project/")))
- (expect (projectile-detect-project-type) :to-equal 'julia))))))
+ (expect (projectile-detect-project-type) :to-equal 'julia)))))
+ (it "detects project-type for Zig projects"
+ (projectile-test-with-sandbox
+ (projectile-test-with-files
+ ("project/"
+ "project/src/"
+ "project/build.zig.zon")
+ (let ((projectile-indexing-method 'native))
+ (spy-on 'projectile-project-root :and-return-value (file-truename (expand-file-name "project/")))
+ (expect (projectile-detect-project-type) :to-equal 'zig))))))
(describe "projectile-dirname-matching-count"
(it "counts matching dirnames ascending file paths"