A focused VS Code extension for GNU-style RISC-V assembly: syntax-aware highlighting, alignment-aware formatting, navigation, completion, and useful snippets in one lightweight package.
Highlights
| Area | What you get |
|---|---|
| Syntax | GNU-style RISC-V syntax highlighting for instructions, directives, registers, CSRs, relocations, labels, comments, macros, and common extensions. |
#define |
A red directive, a teal bold macro name, and a purple macro value. These editor decorations are independent of global TextMate color customizations. |
| Formatting | Aligned #define sections, instruction mnemonics, operand columns, and inline # / // comments. Choose aligned comma columns or commas attached to operands. Structural directives and labels stay in column zero. |
| Navigation | Go to Definition for labels, numeric local labels (1f / 1b), macros, #defines, and .equ / .set symbols. |
| Productivity | Outline, workspace symbol search, text-boundary references, document highlights, completion, and 29 GNU RISC-V snippets. |
Install
From the Marketplace
- Open the Extensions view in VS Code.
- Search for Better RISC-V Support.
- Select Install.
Or install from the command line:
code --install-extension Esing.better-riscv-support
From a VSIX file
code --install-extension better-riscv-support-<version>.vsix
The extension requires VS Code 1.85 or later.
Quick start
- Open a
.s,.S,.asm, or.riscvfile. If another extension selected a different language mode, use Change Language Mode and choose RISC-V Assembly. - Run Format Document (
Shift+Alt+Fon Windows/Linux) or invoke Better RISC-V Support: Format Document from the Command Palette. - Use
F12for definitions,Shift+F12for references, and the Explorer's Outline view to navigate symbols. - Type a snippet prefix such as
r3,rfunc,rmacro,rdefine,load, orbranch, then accept the completion.
Formatting
Input:
#define SHORT 1
#define A_LONGER_NAME 42
.macro SAVE reg
addi x1,x0,1
add x10,x2,x3
.endm
Output:
#define SHORT 1
#define A_LONGER_NAME 42
.macro SAVE reg
addi x1 , x0, 1
add x10, x2, x3
.endm
Formatting is section-aware rather than file-global:
#definenames and values align within a define section. Comment-only lines and up tobetterRiscvSupport.maxBlankLinesWithoutBreakblank lines remain in the same section.- Ordinary assembly lines in one section share mnemonic, operand, and inline comment columns. Comma placement is configurable.
- Labels and structural directives such as
.macro,.endm,.option,.norvc, and.novncstart in column zero. - The formatter preserves the document's original line-ending style and final newline convention.
Choose the comma style with betterRiscvSupport.commaAlignment:
"aligned"(default) pads before commas, so comma columns align."afterOperand"keeps each comma adjacent to its operand and puts any additional padding after the comma, so subsequent operand columns still align. For example:addi a0, a0, 1.
Settings
All settings are available in Settings UI under Better RISC-V Support.
| Setting | Default | Description |
|---|---|---|
betterRiscvSupport.indentSize |
4 |
Spaces before ordinary assembly instructions. |
betterRiscvSupport.alignDefines |
true |
Align macro names and values in each #define section. |
betterRiscvSupport.defineNameFieldWidth |
24 |
Minimum macro-name field width after #define. |
betterRiscvSupport.maxBlankLinesWithoutBreak |
2 |
Maximum blank lines that keep a define or assembly alignment section connected. |
betterRiscvSupport.alignAssemblyColumns |
true |
Align instruction, operand, and inline-comment columns. |
betterRiscvSupport.commaAlignment |
"aligned" |
"aligned" aligns comma columns; "afterOperand" keeps commas next to operands while aligning later operand columns. |
betterRiscvSupport.instructionOperandSpacing |
1 |
Spaces between a mnemonic and its first operand. |
betterRiscvSupport.commaOperandSpacing |
1 |
Minimum spaces after an operand comma. In "afterOperand" mode, more spaces may follow shorter operands to preserve operand columns. |
betterRiscvSupport.commentSpacing |
1 |
Spaces before an inline # or // comment. |
betterRiscvSupport.maxWorkspaceFiles |
500 |
Maximum assembly-like files scanned for workspace symbols. |
Example:
{
"betterRiscvSupport.indentSize": 4,
"betterRiscvSupport.defineNameFieldWidth": 24,
"betterRiscvSupport.maxBlankLinesWithoutBreak": 2,
"betterRiscvSupport.commaAlignment": "afterOperand",
"betterRiscvSupport.instructionOperandSpacing": 1,
"betterRiscvSupport.commaOperandSpacing": 1,
"betterRiscvSupport.commentSpacing": 2
}
#define colors
The #define highlight uses extension-owned editor decorations, not the
global editor.tokenColorCustomizations array. This lets it coexist with
other language extensions that also use TextMate color rules.
Override the three colors through workbench.colorCustomizations:
{
"workbench.colorCustomizations": {
"betterRiscvSupport.define.directiveForeground": "#E53935",
"betterRiscvSupport.define.nameForeground": "#00897B",
"betterRiscvSupport.define.valueForeground": "#7E57C2"
}
}
Language support and limitations
- The extension targets GNU-style RISC-V assembly; it is not an assembler, linter, debugger, or complete preprocessor implementation.
- Whole-document formatting is supported. Range formatting is not currently provided.
- Backslash-continued preprocessor macros are highlighted, but their layout is intentionally preserved by the formatter.
- Reference search and document highlighting are identifier-based text matching, not full semantic or include-aware analysis. Numeric local labels are supported by Go to Definition.
- If another extension owns the same file suffix or formatting provider, select RISC-V Assembly as the language mode and choose Better RISC-V Support in Format Document With....
Contributing and support
Bug reports and feature requests are welcome in the issue tracker. For local development, run:
npm install
npm test
Press F5 in VS Code to launch an Extension Development Host.