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