aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer/servers/spectral/init.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/nvim-lsp-installer/servers/spectral/init.lua')
-rw-r--r--lua/nvim-lsp-installer/servers/spectral/init.lua34
1 files changed, 15 insertions, 19 deletions
diff --git a/lua/nvim-lsp-installer/servers/spectral/init.lua b/lua/nvim-lsp-installer/servers/spectral/init.lua
index e308369c..61047942 100644
--- a/lua/nvim-lsp-installer/servers/spectral/init.lua
+++ b/lua/nvim-lsp-installer/servers/spectral/init.lua
@@ -1,9 +1,7 @@
local server = require "nvim-lsp-installer.server"
-local npm = require "nvim-lsp-installer.installers.npm"
-local std = require "nvim-lsp-installer.installers.std"
-local installers = require "nvim-lsp-installer.installers"
-local context = require "nvim-lsp-installer.installers.context"
local path = require "nvim-lsp-installer.path"
+local git = require "nvim-lsp-installer.core.managers.git"
+local npm = require "nvim-lsp-installer.core.managers.npm"
return function(name, root_dir)
return server.Server:new {
@@ -11,21 +9,19 @@ return function(name, root_dir)
root_dir = root_dir,
languages = { "openapi", "asyncapi" },
homepage = "https://stoplight.io/open-source/spectral/",
- installer = {
- std.git_clone "https://github.com/stoplightio/vscode-spectral",
- npm.install(),
- installers.branch_context {
- context.set_working_dir "server",
- npm.install(),
- },
- installers.always_succeed(npm.run "compile"),
- context.set_working_dir "server",
- context.receipt(function(receipt, ctx)
- receipt
- :mark_invalid() -- Due to the `context.set_working_dir` after clone, we essentially erase any trace of the cloned git repo, so we mark this as invalid.
- :with_primary_source(receipt.git_remote "https://github.com/stoplightio/vscode-spectral")
- end),
- },
+ async = true,
+ ---@param ctx InstallContext
+ installer = function(ctx)
+ git.clone({ "https://github.com/stoplightio/vscode-spectral" }).with_receipt()
+ local server_dir = path.concat { ctx.cwd:get(), "server" }
+ ctx.spawn.npm { "install" }
+ ctx.spawn.npm { "install", cwd = server_dir }
+ pcall(npm.run, { "compile" })
+
+ -- TODO: don't do this
+ ctx.cwd:set(server_dir)
+ ctx.receipt:mark_invalid() -- Due to the `context.set_working_dir` after clone, we essentially erase any trace of the cloned git repo, so we mark this as invalid.
+ end,
default_options = {
cmd = { "node", path.concat { root_dir, "out", "server.js" }, "--stdio" },
},