Skip to content

Commit

Permalink
feat(lsp_ext): runnables extension
Browse files Browse the repository at this point in the history
  • Loading branch information
fannheyward committed Jun 3, 2020
1 parent 2e1f709 commit d9e8102
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
10 changes: 4 additions & 6 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,10 @@ export function run(ctx: Ctx): Cmd {
}

const runnable = items[idx].runnable;
const cmd = `${runnable.bin} ${runnable.args.join(' ')}`;
const cmd = `${runnable.kind} ${runnable.args.cargoArgs.join(' ')}`;
const opt: TerminalOptions = {
name: runnable.label,
cwd: runnable.cwd!,
env: runnable.env,
cwd: runnable.args.workspaceRoot,
};
workspace.createTerminal(opt).then((t: Terminal) => {
t.sendText(cmd);
Expand All @@ -174,11 +173,10 @@ export function runSingle(): Cmd {
const { document } = await workspace.getCurrentState();
if (!runnable || !isRustDocument(document)) return;

const cmd = `${runnable.bin} ${runnable.args.join(' ')}`;
const cmd = `${runnable.kind} ${runnable.args.cargoArgs.join(' ')}`;
const opt: TerminalOptions = {
name: runnable.label,
cwd: runnable.cwd!,
env: runnable.env,
cwd: runnable.args.workspaceRoot,
};
workspace.createTerminal(opt).then((t: Terminal) => {
t.sendText(cmd);
Expand Down
15 changes: 8 additions & 7 deletions src/lsp_ext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,16 @@ export interface RunnablesParams {
position: lc.Position | null;
}
export interface Runnable {
range: lc.Range;
label: string;
bin: string;
args: string[];
extraArgs: string[];
env: { [key: string]: string };
cwd: string | null;
location?: lc.LocationLink;
kind: 'cargo';
args: {
workspaceRoot?: string;
cargoArgs: string[];
executableArgs: string[];
};
}
export const runnables = new lc.RequestType<RunnablesParams, Runnable[], void>('rust-analyzer/runnables');
export const runnables = new lc.RequestType<RunnablesParams, Runnable[], void>('experimental/runnables');

export type InlayHint = InlayHint.TypeHint | InlayHint.ParamHint | InlayHint.ChainingHint;

Expand Down

0 comments on commit d9e8102

Please sign in to comment.