Package 'languageserversetup'

Title: Automated Setup and Auto Run for R Language Server
Description: Allows to install the R 'languageserver' with all dependencies into a separate library and use that independent installation automatically when R is instantiated as a language server process. Useful for making language server seamless to use without running into package version conflicts.
Authors: Jozef Hajnala [aut, cre]
Maintainer: Jozef Hajnala <[email protected]>
License: AGPL-3
Version: 0.1.2.900
Built: 2024-10-31 22:09:47 UTC
Source: https://github.com/jozefhajnala/languageserversetup

Help Index


Add language server initialization to .Rprofile

Description

Add language server initialization to .Rprofile

Usage

languageserver_add_to_rprofile(
  rlsLib = getOption("langserver_library"),
  rprofilePath = locate_rprofile(),
  confirmBeforeChanging = TRUE,
  code = append_code(rlsLib = rlsLib)
)

Arguments

rlsLib

character(1), path to the library where the languageserver package will be installed.

rprofilePath

character(1), path to the file where to add the initialization code, or NULL. By default, adds the code to a .Rprofile file in the home directory of the current user. Please refer to ?Startup for more details around .Rprofile files.

Notably, if the R_PROFILE_USER environment variable is set, the .Rprofile located in the home directory is ignored, therefore we may want to place the initialization code into the file specified by that variable using the rprofilePath argument in that case.

confirmBeforeChanging

logical(1), if TRUE, asks for user confirmation before changing the file. For non-interactive use, FALSE will skip the confirmation.

code

character(), the code to be added to the file. Defaults to the value of append_code().

Value

side-effects


Detect whether a process relates to the R Language Server

Description

Detect whether a process relates to the R Language Server

Usage

languageserver_detect(pid, os, langServerProcessPatt, checkParents = TRUE)

Arguments

pid

integer(1), id of the process to investigate, usually retrieved by Sys.getpid

os

character(1), name of the OS, usually retrieved as the "sysname" element of Sys.info, all lowercase.

langServerProcessPatt

character(1), pattern to recognize the process created by languageserver.

checkParents

logical(1), if TRUE, parent processes are also checked in case when pid is not the R Language Server process. This is needed as the linting processes are created with callr as sub-processes of the main Language Server process.

Value

logical(1), TRUE if the process with pid (or, optionally, any of its parents) is detected as the R Language Server process. Otherwise FALSE.


Install the languageserver package to a separate library

Description

Install the languageserver package to a separate library

Usage

languageserver_install(
  rlsLib = getOption("langserver_library"),
  strictLibrary = TRUE,
  fullReinstall = TRUE,
  fromGitHub = TRUE,
  confirmBeforeInstall = TRUE,
  dryRun = FALSE,
  ref = "master",
  Ncpus = max(1L, getOption("Ncpus")),
  ...
)

Arguments

rlsLib

character(1), path to the library where the languageserver package will be installed.

strictLibrary

logical(1), if TRUE, all the dependencies of languageserver will be installed into rlsLib, otherwise only those that are needed but not present in other libraries in .libPaths() will be installed.

fullReinstall

logical(1). If TRUE, rlsLib will be recursively removed to re-install all the packages cleanly.

fromGitHub

logical(1), if TRUE, will use the remotes package to install the current development version from GitHub. Otherwise install.packages() is used to install the languageserver package from CRAN.

confirmBeforeInstall

logical(1) if TRUE, will ask the user to confirm the steps before installation. For non-interactive use, FALSE will skip the confirmation.

dryRun

logical(1), if TRUE, most actions will only be reported, not taken - nothing will be removed, created or installed.

ref

character(1), when fromGitHub is TRUE, ref is the desired git reference. Usually a commit, tag, or branch name.

Ncpus

integer(1), number of the number of parallel processes to use for a parallel install of more than one source package. Values greater than one are supported if the make command specified by Sys.getenv("MAKE", "make") accepts argument ⁠-k -j Ncpus⁠.

...

further arguments passed to install.packages() in case fromGitHub is set to FALSE.

Value

side-effects

See Also

utils::install.packages()


Remove language server initialization from .Rprofile

Description

Remove language server initialization from .Rprofile

Usage

languageserver_remove_from_rprofile(
  rlsLib = getOption("langserver_library"),
  rprofilePath = locate_rprofile(),
  code = append_code(rlsLib = rlsLib),
  confirmBeforeChanging = TRUE
)

Arguments

rlsLib

character(1), path to the library where the languageserver package will be installed.

rprofilePath

character(1), path to the file where to add the initialization code, or NULL. By default, adds the code to a .Rprofile file in the home directory of the current user. Please refer to ?Startup for more details around .Rprofile files.

Notably, if the R_PROFILE_USER environment variable is set, the .Rprofile located in the home directory is ignored, therefore we may want to place the initialization code into the file specified by that variable using the rprofilePath argument in that case.

code

character(), the code to be added to the file. Defaults to the value of append_code().

confirmBeforeChanging

logical(1), if TRUE, asks for user confirmation before changing the file. For non-interactive use, FALSE will skip the confirmation.

Value

side-effects


Prepare language server to be started

Description

Prepare language server to be started

Usage

languageserver_startup(
  rlsLib = getOption("langserver_library"),
  langServerProcessPatt = getOption("langserver_processPatt"),
  strictLibrary = TRUE,
  os = tolower(Sys.info()[["sysname"]]),
  pid = Sys.getpid()
)

Arguments

rlsLib

character(1), path to the library where the languageserver package will be installed.

langServerProcessPatt

character(1), pattern to recognize the process created by languageserver.

strictLibrary

logical(1), if TRUE, all the dependencies of languageserver will be installed into rlsLib, otherwise only those that are needed but not present in other libraries in .libPaths() will be installed.

os

character(1), name of the OS, usually retrieved as the "sysname" element of Sys.info, all lowercase.

pid

integer(1), id of the process to investigate, usually retrieved by Sys.getpid

Value

side-effects