Skip to content

Commit

Permalink
added wgsl_analyzer server (chipsalliance#719)
Browse files Browse the repository at this point in the history
  • Loading branch information
skwee357 authored Jun 1, 2022
1 parent 0d61e14 commit d19ea3c
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 1 deletion.
1 change: 1 addition & 0 deletions lua/nvim-lsp-installer/_generated/filetype_map.lua
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ return {
vlang = { "vls" },
vmasm = { "asm_lsp" },
vue = { "eslint", "stylelint_lsp", "tailwindcss", "volar", "vuels" },
wgsl = { "wgsl_analyzer" },
wxss = { "stylelint_lsp" },
xml = { "lemminx" },
xsd = { "lemminx" },
Expand Down
3 changes: 3 additions & 0 deletions lua/nvim-lsp-installer/_generated/metadata.lua
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,9 @@ return {
vuels = {
filetypes = { "vue" }
},
wgsl_analyzer = {
filetypes = { "wgsl" }
},
yamlls = {
filetypes = { "yaml", "yaml.docker-compose" }
},
Expand Down
12 changes: 11 additions & 1 deletion lua/nvim-lsp-installer/core/managers/cargo/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ function M.install(crate, opts)
assert(not opts.git, "Providing a version when installing a git crate is not allowed.")
end)

local final_crate = crate

if opts.git then
final_crate = { "--git" }
if type(opts.git) == "string" then
table.insert(final_crate, opts.git)
end
table.insert(final_crate, crate)
end

ctx.spawn.cargo {
"install",
"--root",
Expand All @@ -46,7 +56,7 @@ function M.install(crate, opts)
end)
:or_else(vim.NIL),
opts.features and { "--features", opts.features } or vim.NIL,
opts.git and { "--git", crate } or crate,
final_crate,
}

return {
Expand Down
1 change: 1 addition & 0 deletions lua/nvim-lsp-installer/servers/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ local CORE_SERVERS = _.set_of {
"vls",
"volar",
"vuels",
"wgsl_analyzer",
"yamlls",
"zk",
"zls",
Expand Down
19 changes: 19 additions & 0 deletions lua/nvim-lsp-installer/servers/wgsl_analyzer/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
local server = require "nvim-lsp-installer.server"
local cargo = require "nvim-lsp-installer.core.managers.cargo"

return function(name, root_dir)
local homepage = "https://github.com/wgsl-analyzer/wgsl-analyzer"

return server.Server:new {
name = name,
root_dir = root_dir,
languages = { "wgsl" },
homepage = homepage,
installer = cargo.crate("wgsl_analyzer", {
git = homepage,
}),
default_options = {
cmd_env = cargo.env(root_dir),
},
}
end
17 changes: 17 additions & 0 deletions tests/core/managers/cargo_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,23 @@ describe("cargo manager", function()
end)
)

it(
"should call cargo install with git source and a specific crate",
async_test(function()
installer.run_installer(ctx, cargo.crate("crate-name", { git = "https://my-crate.git" }))
assert.spy(ctx.spawn.cargo).was_called(1)
assert.spy(ctx.spawn.cargo).was_called_with {
"install",
"--root",
".",
"--locked",
vim.NIL,
vim.NIL, -- --features
{ "--git", "https://my-crate.git", "crate-name" },
}
end)
)

it(
"should respect options",
async_test(function()
Expand Down

0 comments on commit d19ea3c

Please sign in to comment.