Open hhstore opened 2 years ago
zig 标准库
补全, 不支持第三方包
.
步骤说明:
✅ 1. 安装 zig. ✅ 2. 安装 zls, 用于 vscode 解析/索引 zig 代码. ✅ 3. 安装 vscode/clion 相关 zig 插件 ✅ 4. 更改 vscode 插件设置, 配置 zls 参数. ✅ 5. 配置结束, 愉快写代码.
setup zig development environment.
install:
zls 安装脚本
挑出来, 单独安装 zls.
# for macos + m1:
install:zig:dev:
cmds:
- mkdir -p $HOME/.local/bin/;
- cd $HOME/.local/bin/; curl -L https://ziglang.org/builds/zig-macos-aarch64-0.10.0-dev.2617+47c4d4450.tar.xz | tar -xJ --strip-components=1 -C .;
- chmod +x $HOME/.local/bin/zig;
- zig version
install:zig:
cmds:
- brew install zig
- zig version
- brew install xz # for zig zls
- mkdir $HOME/zls && cd $HOME/zls && curl -L https://github.com/zigtools/zls/releases/download/0.9.0/x86_64-macos.tar.xz | tar -xJ --strip-components=1 -C .
- chmod +x $HOME/zls/zls
- sudo $HOME/zls/zls configure
ignore_error: true
➤ which zig
/Users/dev/.local/bin/zig
➤ zig version
0.10.0-dev.2617+47c4d4450
➤ zig env
{
"zig_exe": "/Users/dev/.local/bin/zig",
"lib_dir": "/Users/dev/.local/bin/lib/zig",
"std_dir": "/Users/dev/.local/bin/lib/zig/std",
"global_cache_dir": "/Users/dev/.cache/zig",
"version": "0.10.0-dev.2617+47c4d4450"
}
install:zls:
cmds:
- brew install xz # for zig zls
- mkdir $HOME/zls && cd $HOME/zls && curl -L https://github.com/zigtools/zls/releases/download/0.9.0/x86_64-macos.tar.xz | tar -xJ --strip-components=1 -C .
- chmod +x $HOME/zls/zls
- sudo $HOME/zls/zls configure
ignore_error: true
Welcome to the ZLS configuration wizard!
*
|\
/* \
| *\
_/_*___|_ x
| @ @ /
@ \ /
\__-/ /
? Should this configuration be system-wide? (y/n) > y
Found zig executable '/Users/dev/.local/bin/zig' in PATH.
? Which code editor do you use? (select one)
- VSCode
- Sublime
- Kate
- Neovim
- Vim8
- Emacs
- Doom
- Other
> vscode
? Do you want to enable snippets? (y/n) > y
? Do you want to enable style warnings? (y/n) > y
? Do you want to enable semantic highlighting? (y/n) > y
? Do you want to enable .* and .? completions? (y/n) > y
Writing config to /Library/Preferences/zls.json ... successful.
To use ZLS in Visual Studio Code, install the 'ZLS for VSCode' extension from
'https://github.com/zigtools/zls-vscode/releases' or via the extensions menu.
Then, open VSCode's 'settings.json' file, and add:
"zigLanguageClient.path": "[command_or_path_to_zls]"
Thank you for choosing ZLS!
vscode 下载:
vscode 插件安装:
参考:
clion / IntelliJ IDEA
配置:IDE: clion
IntelliJ IDEA 社区版
, 也支持 zig 插件. 基本够用.插件: intellij-zig
zls-vscode
新版插件炸了, 回退上一个版本(v1.1.2):
# vscode 设置, 搜索 zls, 添加对应的 zls 安装路径
/Users/dev/zls/zls
vscode 设置:
之后, 就可以愉快的写 zig 了.
IntelliJ IDEA
并不 work. 1
zls 配置:
步骤:
- 下载安装 Sublime Text 4.
- 安装 LSP 插件: https://github.com/sublimelsp/LSP
- 设置中, 添加 LSP 配置段:
- 注意
zls
的路径, 填写自己机器对应的路径.- 结束. (如果不生效, 重启一下编辑器)
// Settings in here override those in "LSP/LSP.sublime-settings"
{
"clients": {
"zig": {
"command": ["/Users/dev/zls/zls"],
"enabled": true,
"selector": "source.zig"
}
}
}
配置成功效果:
theme 插件:
必装插件:
v1.1.2
. 如果用最新版本的 zls-vscode, 安装方式:zig + zls-vscode + zls,最好看下 zls-vscode 提示的编译 zls 的 zig 版本,下载一个一样的版本 zig 就可以了。
related:
386