Skip to content
This repository has been archived by the owner on Jul 28, 2021. It is now read-only.

Modify config #64

Merged
merged 1 commit into from
Dec 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,29 @@
"contributes": {
"configuration": {
"type": "object",
"title": "R",
"title": "R LSP Client",
"properties": {
"r.rpath.windows": {
"type": "string",
"default": "",
"description": "Path to an R executable for Windows. Must be \"vanilla\" R, not radian etc.!"
},
"r.rpath.mac": {
"type": "string",
"default": "",
"description": "Path to an R executable for macOS. Must be \"vanilla\" R, not radian etc.!"
},
"r.rpath.linux": {
"type": "string",
"default": "",
"description": "Path to an R executable for Linux. Must be \"vanilla\" R, not radian etc.!"
},
"r.lsp.path": {
"type": "string",
"default": "",
"description": "Path to R binary for launching Language Server"
"description": "Path to R binary for launching Language Server",
"markdownDeprecationMessage": "Will be deprecated. Use `#r.rpath.windows#`, `#r.rpath.mac#`, or `#r.rpath.linux#` instead.",
"deprecationMessage": "Will be deprecated. Use r.rpath.windows, r.rpath.mac, or r.rpath.linux instead."
},
"r.lsp.args": {
"type": "array",
Expand Down
14 changes: 14 additions & 0 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,25 @@ import { WorkspaceConfiguration } from 'vscode';
import { existsSync } from "fs";

export async function getRPath(config: WorkspaceConfiguration) {

// use "old" setting to get path:
let path = config.get<string>("lsp.path");

// use "new" setting to get path:
if(!path){
const configEntry = (
process.platform === 'win32' ? 'rpath.windows' :
process.platform === 'darwin' ? 'rpath.mac' :
'rpath.linux'
);
path = config.get<string>(configEntry);
}

if (path && existsSync(path)) {
return path;
}

// get path from system if neither setting works:
if (process.platform === "win32") {
try {
const key = new winreg({
Expand Down