|
Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
#######
#
# E-scripts on zig.
#
# Note 1: use the eev command (defined in eev.el) and the
# ee alias (in my .zshrc) to execute parts of this file.
# Executing this file as a whole makes no sense.
# An introduction to eev can be found here:
#
# (find-eev-quick-intro)
# http://angg.twu.net/eev-intros/find-eev-quick-intro.html
#
# Note 2: be VERY careful and make sure you understand what
# you're doing.
#
# Note 3: If you use a shell other than zsh things like |&
# and the for loops may not work.
#
# Note 4: I always run as root.
#
# Note 5: some parts are too old and don't work anymore. Some
# never worked.
#
# Note 6: the definitions for the find-xxxfile commands are on my
# .emacs.
#
# Note 7: if you see a strange command check my .zshrc -- it may
# be defined there as a function or an alias.
#
# Note 8: the sections without dates are always older than the
# sections with dates.
#
# This file is at <http://angg.twu.net/e/zig.e>
# or at <http://angg.twu.net/e/zig.e.html>.
# See also <http://angg.twu.net/emacs.html>,
# <http://angg.twu.net/.emacs[.html]>,
# <http://angg.twu.net/.zshrc[.html]>,
# <http://angg.twu.net/escripts.html>,
# and <http://angg.twu.net/>.
#
#######
https://ziglang.org/
https://ziglang.org/learn/overview/
https://ziglang.org/download/
https://github.com/ziglang/zig/wiki/Install-Zig-from-a-Package-Manager
https://github.com/dryzig/zig-debian/blob/master/README.md
$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 379CE192D401AB61
# echo 'deb https://dl.bintray.com/dryzig/zig-debian buster main' | sudo tee -a /etc/apt/sources.list
# sudo apt update
# deb https://dl.bintray.com/dryzig/zig-debian buster main
# (find-asrootfile "/etc/apt/sources.list")
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 379CE192D401AB61
sudo apt-get update
apti zig
https://ziglang.org/learn/overview/#zig-is-also-a-c-compiler
# (find-status "zig")
# (find-vldifile "zig.list")
# (find-udfile "zig/")
# (find-fline "/usr/lib/zig/0.6.0/")
https://github.com/ratfactor/ziglings
https://andrewkelley.me/post/zig-cc-powerful-drop-in-replacement-gcc-clang.html
Zig language
https://ziglearn.org/
Source File
https://trendoceans.com/zig-programming-language/
- You don’t have to build or compile it, and it already comes in executable format. Just download and create a symbolic link for the binary file at the “/usr/bin” directory to make it executable from anywhere for that user, as shown below.
$ wget https://ziglang.org/builds/zig-linux-x86_64-0.10.0-dev.4560+828735ac0.tar.xz
After download, use the below command to extract the file.
$ tar -xf zig-linux-x86_64-0.10.0-dev.4560+828735ac0.tar.xz
- Now enter into the directory and link it to the user bin directory as shown below.
- Note: After linking do not remove the source file, otherwise it will be broken link and Zig command will not be executed.
$ cd zig-linux-x86_64-0.10.0-dev.898+b23f10b42
$ sudo ln -s $(pwd)/zig /usr/local/bin/
- Now you can use the below command after the installation to check whether it is working.
$ zig version
0.10.0-dev.4560+828735ac0
zig-mode for emacs
https://github.com/ziglang/zig-mode
In doom emacs init.el uncomment:
;; (zig +lsp)
zls lsp server
https://github.com/zigtools/zls/#linux
curl -L https://github.com/zigtools/zls/releases/download/0.9.0/x86_64-linux.tar.xz | tar -xJ --strip-components=1 -C .
chmod +x zls
$ sudo ln -s $(pwd)/zls /usr/local/bin/
============
Emacs and Doom configuration
============
Emacs
Install lsp-mode from melpa
zig mode is also useful
;; Setup lsp-mode as desired.
;; See https://emacs-lsp.github.io/lsp-mode/page/installation/ for more information.
(require 'lsp-mode)
;; Either place zls in your PATH or add the following:
(setq lsp-zig-zls-executable "/usr/local/bin/zls")
============
Doom Emacs
Note: you do not need this configuration in doom, if you have enabled it on
"init.el"
Enable the lsp module
Install the zig-mode package (add (package! zig-mode) to your packages.el file
Add the following to your config.el:
(use-package! zig-mode
:hook ((zig-mode . lsp-deferred))
:custom (zig-format-on-save nil)
:config
(after! lsp-mode
(add-to-list 'lsp-language-id-configuration '(zig-mode . "zig"))
(lsp-register-client
(make-lsp-client
:new-connection (lsp-stdio-connection "/usr/local/bin/zls")
:major-modes '(zig-mode)
:server-id 'zls))))
============
Compiling source codes
zig can compile c, cpp and zip source files
zig myprog.zig
zig cc myprog.c
zig c++ myprog.cpp
# Local Variables:
# coding: utf-8-unix
# End: