Interactive setup for Zig LSP development environment
Sets up Zig LSP with ZLS and essential tools for development. Use this when you need to configure a complete Zig coding environment with language server support.
/plugin marketplace add zircote/zig-lsp/plugin install zig-lsp@zircote-lspThis command will configure your Zig development environment with ZLS (Zig Language Server) and essential tools.
First, verify Zig is installed:
zig version
macOS (Homebrew):
brew install zig
Linux (Snap):
sudo snap install zig --classic --beta
Manual installation:
# Download from https://ziglang.org/download/
# Extract and add to PATH
wget https://ziglang.org/download/0.13.0/zig-linux-x86_64-0.13.0.tar.xz
tar -xf zig-linux-x86_64-0.13.0.tar.xz
sudo mv zig-linux-x86_64-0.13.0 /usr/local/zig
echo 'export PATH=$PATH:/usr/local/zig' >> ~/.bashrc
source ~/.bashrc
macOS (Homebrew):
brew install zls
Linux (Arch):
sudo pacman -S zls
Build from source:
git clone https://github.com/zigtools/zls
cd zls
zig build -Doptimize=ReleaseSafe
sudo cp zig-out/bin/zls /usr/local/bin/
zig version
zls --version
export ENABLE_LSP_TOOL=1
Test the LSP integration:
# Create a test project
mkdir -p /tmp/test-zig-lsp && cd /tmp/test-zig-lsp
zig init-exe
# Run checks
zig fmt --check src/main.zig
zig build
# Clean up
cd - && rm -rf /tmp/test-zig-lsp
Create a zls.json in your project root for custom settings:
cat > zls.json <<EOF
{
"enable_snippets": true,
"enable_ast_check_diagnostics": true,
"enable_autofix": true,
"warn_style": true,
"highlight_global_var_declarations": true
}
EOF