Skip to content
This repository was archived by the owner on Nov 26, 2025. It is now read-only.

Commit 5d58b22

Browse files
authored
Merge branch 'master' into master
2 parents 2f9b70a + 324ee9d commit 5d58b22

File tree

8 files changed

+128
-61
lines changed

8 files changed

+128
-61
lines changed

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: /
5+
schedule:
6+
interval: daily

.github/workflows/main.yml

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,53 @@
11
name: CI
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
413

514
jobs:
615
build:
7-
runs-on: ubuntu-latest
16+
runs-on: ${{ matrix.os }}
17+
continue-on-error: ${{ matrix.experimental }}
818
strategy:
19+
fail-fast: false
920
matrix:
10-
emacs_version:
11-
- 24.4
12-
- 24.5
13-
- 25.1
14-
- 25.2
15-
- 25.3
16-
- 26.1
17-
- 26.2
21+
os: [ubuntu-latest, macos-latest, windows-latest]
22+
emacs-version:
1823
- 26.3
19-
- 27.1
2024
- 27.2
21-
- 28.1
2225
- 28.2
26+
- 29.2
27+
experimental: [false]
28+
include:
29+
- os: ubuntu-latest
30+
emacs-version: snapshot
31+
experimental: true
32+
- os: macos-latest
33+
emacs-version: snapshot
34+
experimental: true
35+
2336
steps:
24-
- uses: purcell/setup-emacs@master
37+
- uses: jcs090218/setup-emacs@master
38+
with:
39+
version: ${{ matrix.emacs-version }}
40+
41+
- uses: emacs-eask/setup-eask@master
2542
with:
26-
version: ${{ matrix.emacs_version }}
27-
- uses: actions/checkout@v2
43+
version: 'snapshot'
44+
45+
- uses: actions/checkout@v4
46+
2847
- name: Run tests
29-
run: ./run_tests.sh
48+
run: |
49+
eask install-deps
50+
eask package
51+
eask install
52+
eask compile
53+
eask test ert ./test/*.el

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
*.elc
2+
3+
# build tools
4+
.eask/
5+
dist/

Eask

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
(package "zig-mode"
2+
"0.0.8"
3+
"A major mode for the Zig programming language")
4+
5+
(website-url "https://github.com/zig-lang/zig-mode")
6+
(keywords "zig" "languages")
7+
8+
(package-file "zig-mode.el")
9+
10+
(script "test" "echo \"Error: no test specified\" && exit 1")
11+
12+
(source 'gnu)
13+
(source 'melpa)
14+
15+
(depends-on "emacs" "26.1")
16+
(depends-on "reformatter")
17+
18+
(setq network-security-level 'low) ; see https://github.com/jcs090218/setup-emacs-windows/issues/156#issuecomment-932956432

README.md

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,46 @@ Then add the following to your `.emacs` file:
3636

3737
[![CI](https://github.com/ziglang/zig-mode/actions/workflows/main.yml/badge.svg)](https://github.com/ziglang/zig-mode/actions/workflows/main.yml)
3838

39-
To run all unit tests with `emacs`, run:
39+
To run the test locally, you will need the following tools:
4040

41-
```bash
42-
./run_tests.sh
41+
- [Eask](https://emacs-eask.github.io/)
42+
- [Make](https://www.gnu.org/software/make/) (optional)
43+
44+
Install all dependencies and development dependencies:
45+
46+
```sh
47+
$ eask install-deps --dev
4348
```
4449

45-
Note that Emacs 24.3 or later is required. If you need to specify which Emacs
46-
binary to use, you can do that by setting the `EMACS` environment variable,
47-
e.g.:
50+
To test the package's installation:
4851

49-
```bash
50-
EMACS=/usr/bin/emacs24 ./run_tests.sh
52+
```sh
53+
$ eask package
54+
$ eask install
5155
```
5256

57+
To test compilation:
58+
59+
```sh
60+
$ eask compile
61+
```
62+
63+
**🪧 The following steps are optional, but we recommend you follow these lint results!**
64+
65+
The built-in `checkdoc` linter:
66+
67+
```sh
68+
$ eask lint checkdoc
69+
```
70+
71+
The standard `package` linter:
72+
73+
```sh
74+
$ eask lint package
75+
```
76+
77+
*📝 P.S. For more information, find the Eask manual at https://emacs-eask.github.io/.*
78+
5379
## Optional Configuration
5480

5581
`zig-mode` used to enable coloration of the compilation buffer using

appveyor.yml

Lines changed: 0 additions & 7 deletions
This file was deleted.
File renamed without changes.

zig-mode.el

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
;;; zig-mode.el --- A major mode for the Zig programming language -*- lexical-binding: t -*-
22

3+
;; Author: Andrea Orru <[email protected]>
4+
;; Andrew Kelley <[email protected]>
5+
;; Maintainer: Shen, Jen-Chieh <[email protected]>
6+
;; URL: https://github.com/zig-lang/zig-mode
37
;; Version: 0.0.8
4-
;; Author: Andrea Orru <[email protected]>, Andrew Kelley <[email protected]>
8+
;; Package-Requires: ((emacs "26.1") (reformatter "0.6"))
59
;; Keywords: zig, languages
6-
;; Package-Requires: ((emacs "24.3") (reformatter "0.6"))
7-
;; Homepage: https://github.com/zig-lang/zig-mode
810

911
;; This file is free software; you can redistribute it and/or modify
1012
;; it under the terms of the GNU General Public License as published by
@@ -91,31 +93,31 @@ If given a SOURCE, execute the CMD on it."
9193
(defun zig-build-exe ()
9294
"Create executable from source or object file."
9395
(interactive)
94-
(zig--run-cmd "build-exe" (buffer-file-name)))
96+
(zig--run-cmd "build-exe" (file-local-name (buffer-file-name))))
9597

9698
;;;###autoload
9799
(defun zig-build-lib ()
98100
"Create library from source or assembly."
99101
(interactive)
100-
(zig--run-cmd "build-lib" (buffer-file-name)))
102+
(zig--run-cmd "build-lib" (file-local-name (buffer-file-name))))
101103

102104
;;;###autoload
103105
(defun zig-build-obj ()
104106
"Create object from source or assembly."
105107
(interactive)
106-
(zig--run-cmd "build-obj" (buffer-file-name)))
108+
(zig--run-cmd "build-obj" (file-local-name (buffer-file-name))))
107109

108110
;;;###autoload
109111
(defun zig-test-buffer ()
110112
"Test buffer using `zig test`."
111113
(interactive)
112-
(zig--run-cmd "test" (buffer-file-name) "-O" zig-test-optimization-mode))
114+
(zig--run-cmd "test" (file-local-name (buffer-file-name)) "-O" zig-test-optimization-mode))
113115

114116
;;;###autoload
115117
(defun zig-run ()
116118
"Create an executable from the current buffer and run it immediately."
117119
(interactive)
118-
(zig--run-cmd "run" (buffer-file-name) "-O" zig-run-optimization-mode))
120+
(zig--run-cmd "run" (file-local-name (buffer-file-name)) "-O" zig-run-optimization-mode))
119121

120122
;; zig fmt
121123

@@ -174,11 +176,10 @@ If given a SOURCE, execute the CMD on it."
174176
table))
175177

176178
(defconst zig-keywords
177-
'(
178-
;; Storage
179+
'(;; Storage
179180
"const" "var" "extern" "packed" "export" "pub" "noalias" "inline"
180181
"noinline" "comptime" "callconv" "volatile" "allowzero"
181-
"align" "linksection" "threadlocal"
182+
"align" "linksection" "threadlocal" "addrspace"
182183

183184
;; Structure
184185
"struct" "enum" "union" "error" "opaque"
@@ -197,17 +198,16 @@ If given a SOURCE, execute the CMD on it."
197198
"fn" "usingnamespace" "test"))
198199

199200
(defconst zig-types
200-
'(
201-
;; Integer types
201+
'(;; Integer types
202202
"i2" "u2" "i3" "u3" "i4" "u4" "i5" "u5" "i6" "u6" "i7" "u7" "i8" "u8"
203203
"i16" "u16" "i29" "u29" "i32" "u32" "i64" "u64" "i128" "u128"
204204
"isize" "usize"
205205

206206
;; Floating types
207-
"f16" "f32" "f64" "f128"
207+
"f16" "f32" "f64" "f80" "f128"
208208

209209
;; C types
210-
"c_short" "c_ushort" "c_int" "c_uint" "c_long" "c_ulong"
210+
"c_char" "c_short" "c_ushort" "c_int" "c_uint" "c_long" "c_ulong"
211211
"c_longlong" "c_ulonglong" "c_longdouble"
212212

213213
;; Comptime types
@@ -218,15 +218,14 @@ If given a SOURCE, execute the CMD on it."
218218
"anyopaque"))
219219

220220
(defconst zig-constants
221-
'(
222-
;; Boolean
221+
'(;; Boolean
223222
"true" "false"
224223

225224
;; Other constants
226225
"null" "undefined"))
227226

228227
(defconst zig-electric-indent-chars
229-
'( ?\; ?\, ?\) ?\] ?\} ))
228+
'(?\; ?\, ?\) ?\] ?\}))
230229

231230
(defface zig-multiline-string-face
232231
'((t :inherit font-lock-string-face))
@@ -235,8 +234,7 @@ If given a SOURCE, execute the CMD on it."
235234

236235
(defvar zig-font-lock-keywords
237236
(append
238-
`(
239-
;; Builtins (prefixed with @)
237+
`(;; Builtins (prefixed with @)
240238
(,(concat "@" zig-re-identifier) . font-lock-builtin-face)
241239

242240
;; Keywords, constants and types
@@ -246,8 +244,7 @@ If given a SOURCE, execute the CMD on it."
246244

247245
;; Type annotations (both variable and type)
248246
(,zig-re-type-annotation 1 font-lock-variable-name-face)
249-
(,zig-re-type-annotation 2 font-lock-type-face)
250-
)
247+
(,zig-re-type-annotation 2 font-lock-type-face))
251248

252249
;; Definitions
253250
(mapcar (lambda (x)
@@ -470,24 +467,23 @@ This is written mainly to be used as `end-of-defun-function' for Zig."
470467
'("enum" "struct" "union"))
471468
`(("Fn" ,(zig-re-definition "fn") 1))))
472469

473-
;;; Guarantee filesystem unix line endings
474470
(defun zig-file-coding-system ()
471+
"Guarantee filesystem unix line endings."
475472
(with-current-buffer (current-buffer)
476473
(if (buffer-file-name)
477474
(if (string-match "\\.d?zig\\'" buffer-file-name)
478475
(setq buffer-file-coding-system 'utf-8-unix)
479-
nil))
480-
))
476+
nil))))
481477

482478
(add-hook 'zig-mode-hook 'zig-file-coding-system)
483479

484480
(defvar zig-mode-map
485481
(let ((map (make-sparse-keymap)))
486-
(define-key map (kbd "C-c C-b") 'zig-compile)
487-
(define-key map (kbd "C-c C-f") 'zig-format-buffer)
488-
(define-key map (kbd "C-c C-r") 'zig-run)
489-
(define-key map (kbd "C-c C-t") 'zig-test-buffer)
490-
map)
482+
(define-key map (kbd "C-c C-b") #'zig-compile)
483+
(define-key map (kbd "C-c C-f") #'zig-format-buffer)
484+
(define-key map (kbd "C-c C-r") #'zig-run)
485+
(define-key map (kbd "C-c C-t") #'zig-test-buffer)
486+
map)
491487
"Keymap for Zig major mode.")
492488

493489
;;;###autoload

0 commit comments

Comments
 (0)