Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 authored Feb 21, 2024
2 parents 2f9b70a + 324ee9d commit 5d58b22
Show file tree
Hide file tree
Showing 8 changed files with 128 additions and 61 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: github-actions
directory: /
schedule:
interval: daily
56 changes: 40 additions & 16 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,53 @@
name: CI

on: [push, pull_request]
on:
push:
branches:
- master
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
emacs_version:
- 24.4
- 24.5
- 25.1
- 25.2
- 25.3
- 26.1
- 26.2
os: [ubuntu-latest, macos-latest, windows-latest]
emacs-version:
- 26.3
- 27.1
- 27.2
- 28.1
- 28.2
- 29.2
experimental: [false]
include:
- os: ubuntu-latest
emacs-version: snapshot
experimental: true
- os: macos-latest
emacs-version: snapshot
experimental: true

steps:
- uses: purcell/setup-emacs@master
- uses: jcs090218/setup-emacs@master
with:
version: ${{ matrix.emacs-version }}

- uses: emacs-eask/setup-eask@master
with:
version: ${{ matrix.emacs_version }}
- uses: actions/checkout@v2
version: 'snapshot'

- uses: actions/checkout@v4

- name: Run tests
run: ./run_tests.sh
run: |
eask install-deps
eask package
eask install
eask compile
eask test ert ./test/*.el
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
*.elc

# build tools
.eask/
dist/
18 changes: 18 additions & 0 deletions Eask
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
(package "zig-mode"
"0.0.8"
"A major mode for the Zig programming language")

(website-url "https://github.com/zig-lang/zig-mode")
(keywords "zig" "languages")

(package-file "zig-mode.el")

(script "test" "echo \"Error: no test specified\" && exit 1")

(source 'gnu)
(source 'melpa)

(depends-on "emacs" "26.1")
(depends-on "reformatter")

(setq network-security-level 'low) ; see https://github.com/jcs090218/setup-emacs-windows/issues/156#issuecomment-932956432
42 changes: 34 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,46 @@ Then add the following to your `.emacs` file:

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

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

```bash
./run_tests.sh
- [Eask](https://emacs-eask.github.io/)
- [Make](https://www.gnu.org/software/make/) (optional)

Install all dependencies and development dependencies:

```sh
$ eask install-deps --dev
```

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

```bash
EMACS=/usr/bin/emacs24 ./run_tests.sh
```sh
$ eask package
$ eask install
```

To test compilation:

```sh
$ eask compile
```

**🪧 The following steps are optional, but we recommend you follow these lint results!**

The built-in `checkdoc` linter:

```sh
$ eask lint checkdoc
```

The standard `package` linter:

```sh
$ eask lint package
```

*📝 P.S. For more information, find the Eask manual at https://emacs-eask.github.io/.*

## Optional Configuration

`zig-mode` used to enable coloration of the compilation buffer using
Expand Down
7 changes: 0 additions & 7 deletions appveyor.yml

This file was deleted.

File renamed without changes.
56 changes: 26 additions & 30 deletions zig-mode.el
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
;;; zig-mode.el --- A major mode for the Zig programming language -*- lexical-binding: t -*-

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

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

;;;###autoload
(defun zig-build-lib ()
"Create library from source or assembly."
(interactive)
(zig--run-cmd "build-lib" (buffer-file-name)))
(zig--run-cmd "build-lib" (file-local-name (buffer-file-name))))

;;;###autoload
(defun zig-build-obj ()
"Create object from source or assembly."
(interactive)
(zig--run-cmd "build-obj" (buffer-file-name)))
(zig--run-cmd "build-obj" (file-local-name (buffer-file-name))))

;;;###autoload
(defun zig-test-buffer ()
"Test buffer using `zig test`."
(interactive)
(zig--run-cmd "test" (buffer-file-name) "-O" zig-test-optimization-mode))
(zig--run-cmd "test" (file-local-name (buffer-file-name)) "-O" zig-test-optimization-mode))

;;;###autoload
(defun zig-run ()
"Create an executable from the current buffer and run it immediately."
(interactive)
(zig--run-cmd "run" (buffer-file-name) "-O" zig-run-optimization-mode))
(zig--run-cmd "run" (file-local-name (buffer-file-name)) "-O" zig-run-optimization-mode))

;; zig fmt

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

(defconst zig-keywords
'(
;; Storage
'(;; Storage
"const" "var" "extern" "packed" "export" "pub" "noalias" "inline"
"noinline" "comptime" "callconv" "volatile" "allowzero"
"align" "linksection" "threadlocal"
"align" "linksection" "threadlocal" "addrspace"

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

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

;; Floating types
"f16" "f32" "f64" "f128"
"f16" "f32" "f64" "f80" "f128"

;; C types
"c_short" "c_ushort" "c_int" "c_uint" "c_long" "c_ulong"
"c_char" "c_short" "c_ushort" "c_int" "c_uint" "c_long" "c_ulong"
"c_longlong" "c_ulonglong" "c_longdouble"

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

(defconst zig-constants
'(
;; Boolean
'(;; Boolean
"true" "false"

;; Other constants
"null" "undefined"))

(defconst zig-electric-indent-chars
'( ?\; ?\, ?\) ?\] ?\} ))
'(?\; ?\, ?\) ?\] ?\}))

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

(defvar zig-font-lock-keywords
(append
`(
;; Builtins (prefixed with @)
`(;; Builtins (prefixed with @)
(,(concat "@" zig-re-identifier) . font-lock-builtin-face)

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

;; Type annotations (both variable and type)
(,zig-re-type-annotation 1 font-lock-variable-name-face)
(,zig-re-type-annotation 2 font-lock-type-face)
)
(,zig-re-type-annotation 2 font-lock-type-face))

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

;;; Guarantee filesystem unix line endings
(defun zig-file-coding-system ()
"Guarantee filesystem unix line endings."
(with-current-buffer (current-buffer)
(if (buffer-file-name)
(if (string-match "\\.d?zig\\'" buffer-file-name)
(setq buffer-file-coding-system 'utf-8-unix)
nil))
))
nil))))

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

(defvar zig-mode-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "C-c C-b") 'zig-compile)
(define-key map (kbd "C-c C-f") 'zig-format-buffer)
(define-key map (kbd "C-c C-r") 'zig-run)
(define-key map (kbd "C-c C-t") 'zig-test-buffer)
map)
(define-key map (kbd "C-c C-b") #'zig-compile)
(define-key map (kbd "C-c C-f") #'zig-format-buffer)
(define-key map (kbd "C-c C-r") #'zig-run)
(define-key map (kbd "C-c C-t") #'zig-test-buffer)
map)
"Keymap for Zig major mode.")

;;;###autoload
Expand Down

0 comments on commit 5d58b22

Please sign in to comment.