metal-analyzer is a language server that provides IDE functionality for writing Apple's Metal Shading Language programs. You can use it with any editor that supports the Language Server Protocol (VS Code, Zed, etc).
metal-analyzer features include real-time diagnostics (via xcrun metal),
auto-completion for built-in types, functions, and keywords, hover
documentation, and integrated formatting (with clang-format).
See Installation for setup instructions for VS Code and Zed.
metal-analyzer can also be used as a command-line formatter:
# Format files in-place
metal-analyzer format shader.metal compute.metal
# Check formatting without modifying files (exits 1 if changes needed)
metal-analyzer format --check shader.metal
# Format from stdin
cat shader.metal | metal-analyzer formatFormatting style is resolved in order:
metalfmt.toml— walks up from the source file looking for ametalfmt.toml(see Formatting)..clang-format— if nometalfmt.tomlis found, clang-format's built-in file discovery is used (.clang-format/_clang-format).- No config — if neither file is found, the file is left unchanged.
See metal-analyzer format --help for all options.
See Configuration for available settings.
This project is licensed under MIT license.