1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
local server = require "nvim-lsp-installer.server"
local path = require "nvim-lsp-installer.path"
return function(name, root_dir)
local function create_install_script(install_dir)
return ([[
options(langserver_library = %q);
options(repos = list(CRAN = "http://cran.rstudio.com/"));
rlsLib <- getOption("langserver_library");
install.packages("languageserversetup", lib = rlsLib);
loadNamespace("languageserversetup", lib.loc = rlsLib);
languageserversetup::languageserver_install(
fullReinstall = TRUE,
confirmBeforeInstall = FALSE,
strictLibrary = TRUE
);
]]):format(install_dir, install_dir, install_dir)
end
local server_script = ([[
options("langserver_library" = %q);
rlsLib <- getOption("langserver_library");
.libPaths(new = rlsLib);
loadNamespace("languageserver", lib.loc = rlsLib);
languageserver::run();
]]):format(root_dir)
return server.Server:new {
name = name,
root_dir = root_dir,
homepage = "https://github.com/REditorSupport/languageserver",
languages = { "R" },
async = true,
---@param ctx InstallContext
installer = function(ctx)
ctx.spawn.R {
"--no-save",
on_spawn = function(_, stdio)
local stdin = stdio[1]
stdin:write(create_install_script(ctx.cwd:get()))
stdin:close()
end,
}
ctx.fs:write_file("server.R", server_script)
ctx.receipt:with_primary_source(ctx.receipt.r_package "languageserver")
end,
default_options = {
cmd = { "R", "--slave", "-f", path.concat { root_dir, "server.R" } },
},
}
end
|