Skip to content

Commit

Permalink
feat: add support for slangd
Browse files Browse the repository at this point in the history
`slangd` is the language server for [slang](https://github.com/shader-slang/slang),
a shader language that extends HLSL with additional features.
  • Loading branch information
theHamsta committed Nov 19, 2023
1 parent 6516abf commit 7c57307
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions lua/lspconfig/server_configurations/slangd.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
local util = require 'lspconfig.util'
local bin_name = 'slangd'

if vim.fn.has 'win32' == 1 then
bin_name = 'slangd.exe'
end

return {
default_config = {
cmd = { bin_name },
filetypes = { 'hlsl', 'shaderslang' },
root_dir = util.find_git_ancestor,
single_file_support = true,
},
docs = {
description = [[
https://github.com/shader-slang/slang
The `slangd` binary can be downloaded as part of [slang releases](https://github.com/shader-slang/slang/releases) or
by [building `slang` from source](https://github.com/shader-slang/slang/blob/master/docs/building.md).
The server can be configured by passing a "settings" object to `slangd.setup{}`:
```lua
require('lspconfig').slangd.setup{
settings = {
slang = {
predefinedMacros = {"MY_VALUE_MACRO=1"},
inlayHints = {
deducedTypes = true,
parameterNames = true,
}
}
}
}
```
Available options are documented [here](https://github.com/shader-slang/slang-vscode-extension/tree/main?tab=readme-ov-file#configurations)
or in more detail [here](https://github.com/shader-slang/slang-vscode-extension/blob/main/package.json#L70).
]],
default_config = {
root_dir = [[util.find_git_ancestor]],
},
},
}

0 comments on commit 7c57307

Please sign in to comment.