Skip to content

Commit

Permalink
feat: add rust-analyzer.reloadProcMacros
Browse files Browse the repository at this point in the history
related #256
  • Loading branch information
fannheyward committed May 6, 2023
1 parent 8f65480 commit bd049c9
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ You can use these commands by `:CocCommand XYZ`.
| rust-analyzer.runFlycheck | Run flycheck |
| rust-analyzer.cancelFlycheck | Cancel running flychecks |
| rust-analyzer.clearFlycheck | Clear flycheck diagnostics |
| rust-analyzer.rebuildProcMacros | Rebuild proc macros and build scripts |

## License

Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1290,6 +1290,11 @@
"title": "Clear flycheck diagnostics",
"category": "rust-analyzer"
},
{
"command": "rust-analyzer.rebuildProcMacros",
"title": "Rebuild proc macros and build scripts",
"category": "rust-analyzer"
},
{
"command": "rust-analyzer.explainError",
"title": "Explain the currently hovered diagnostic",
Expand Down
9 changes: 9 additions & 0 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -899,3 +899,12 @@ export function viewItemTree(ctx: Ctx): Cmd {
await nvim.resumeNotification(true);
};
}

export function rebuildProcMacros(ctx: Ctx): Cmd {
return async () => {
const { document } = await workspace.getCurrentState();
if (!isRustDocument(document)) return;

await ctx.client.sendRequest(ra.rebuildProcMacros);
};
}
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export async function activate(context: ExtensionContext): Promise<void> {
ctx.registerCommand('clearFlycheck', cmds.clearFlycheck);
ctx.registerCommand('analyzerStatus', cmds.analyzerStatus);
ctx.registerCommand('viewCrateGraph', cmds.viewCrateGraph);
ctx.registerCommand('rebuildProcMacros', cmds.rebuildProcMacros);
ctx.registerCommand('shuffleCrateGraph', cmds.shuffleCrateGraph);
ctx.registerCommand('viewFullCrateGraph', cmds.viewFullCrateGraph);
ctx.registerCommand('reloadWorkspace', cmds.reloadWorkspace);
Expand Down
2 changes: 2 additions & 0 deletions src/lsp_ext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export const relatedTests = new lc.RequestType<lc.TextDocumentPositionParams, Te
'rust-analyzer/relatedTests'
);
export const reloadWorkspace = new lc.RequestType0<null, void>('rust-analyzer/reloadWorkspace');
export const rebuildProcMacros = new lc.RequestType0<null, void>('rust-analyzer/rebuildProcMacros');

export const runFlycheck = new lc.NotificationType<{
textDocument: lc.TextDocumentIdentifier | null;
}>('rust-analyzer/runFlycheck');
Expand Down

0 comments on commit bd049c9

Please sign in to comment.