r_languageserver.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. from .config import load_config_schema
  2. from .utils import ShellSpec
  3. TROUBLESHOOT = """\
  4. Please ensure that RScript executable is in the PATH; \
  5. this should happen automatically when using Linux, Mac OS or Conda, \
  6. but will require manual configuration when using the default R installer on Windows.
  7. For more details please consult documentation:
  8. https://cran.r-project.org/bin/windows/base/rw-FAQ.html#Rcmd-is-not-found-in-my-PATH_0021
  9. If Rscript is already in the PATH, you can check whether \
  10. the language server package is properly installed with:
  11. Rscript -e "cat(system.file(package='languageserver'))"
  12. which should return the path to the installed package.
  13. """
  14. class RLanguageServer(ShellSpec):
  15. package = "languageserver"
  16. key = "r-languageserver"
  17. cmd = "Rscript"
  18. @property
  19. def args(self):
  20. return ["--slave", "-e", f"{self.package}::run()"]
  21. @property
  22. def is_installed_args(self):
  23. return ["-e", f"cat(system.file(package='{self.package}'))"]
  24. languages = ["r"]
  25. spec = dict(
  26. display_name=key,
  27. mime_types=["text/x-rsrc"],
  28. urls=dict(
  29. home="https://github.com/REditorSupport/languageserver",
  30. issues="https://github.com/REditorSupport/languageserver/issues",
  31. ),
  32. install=dict(
  33. cran=f'install.packages("{package}")',
  34. conda="conda install -c conda-forge r-languageserver",
  35. ),
  36. config_schema=load_config_schema(key),
  37. troubleshoot=TROUBLESHOOT,
  38. )