Neovim plugin for the Slang shader language.
- Fixed LSP support via slangd (code completion, diagnostics, hover)
- Core library navigation - Browse and search Slang's standard library (
slang-synth://URIs) - Go to definition - Jump to definitions in your code and the Slang core library
- Find references - Search-based reference finding in synthetic buffers
- Neovim ≥ 0.11
- slangd (from Vulkan SDK or Slang distribution)
VULKAN_SDKenvironment variable set (or configure manually)- Optional: blink.cmp for completion
{
'pixelsandpointers/slang.nvim',
dependencies = {
'neovim/nvim-lspconfig',
'nvim-treesitter/nvim-treesitter',
},
opts = {
-- slangd_path = '/path/to/vulkan-sdk/x86_64',
auto_format = true,
inlay_hints = true,
},
}require('slang').setup({
-- slangd_path = '/path/to/vulkan-sdk/x86_64',
auto_format = true,
inlay_hints = true,
})gd- Go to definition (shows picker with definitions sorted first)gr- Find references (only works on identifiers, not keywords)
When you use LSP "go to definition" on a Slang standard library function (like TraceRay), it will:
- Open the core library source code in a read-only buffer
- Jump to the definition
- Allow you to navigate within the library using
gdandgr
require('slang').setup({
-- Path to slangd or Vulkan SDK (searches for both in path)
-- slangd_path = '/path/to/vulkan-sdk/x86_64',
-- Enable auto-formatting on save (requires conform.nvim)
auto_format = true,
-- Enable inlay hints for types and parameters
inlay_hints = true,
})The plugin automatically installs the Slang treesitter parser. If you want to configure it manually:
require('nvim-treesitter.configs').setup({
ensure_installed = { 'slang' },
})Slang's core library is distributed as precompiled code, but slangd provides a way to view the source via --print-builtin-module. This plugin:
- Intercepts
slang-synth://URIs returned by slangd - Fetches the module source using
slangd --print-builtin-module <name> - Creates a read-only buffer with the content
- Provides search-based navigation since LSP features don't work in synthetic buffers
In synthetic buffers, the plugin implements smart search-based navigation:
- Recognizes common patterns (struct, class, function, typedef, etc.)
- Sorts results by type (definitions first, then references)
- Filters out keywords using Tree-sitter
- Shows results in a picker for easy selection
The plugin automatically disables semantic tokens for slangd due to known issues with synthetic buffers. You'll still have Tree-sitter syntax highlighting.
Developed for the Slang shader language community. Contributions welcome!
MIT