-
-
Notifications
You must be signed in to change notification settings - Fork 39
Neovim configuration for RISC-V Assembly #261
Description
Discussed in #260
Originally posted by irtaza-10x October 5, 2025
Hi there, I recently started working with riscv asm and have been facing issues configuring the asm-lsp properly with my project.
Issues
Autocompletion and Reference
Pseudo Instructions
The Autocompletion for RISC-V pseudo-instructions does not seem to work. I tried to print reference for the la command but it threw the following error. A problem is also observed with macro completion and definition, the LSP error with id=46 when trying to print macro reference.

However running it on a RISC-V base command displays the desired result.
ABI Register Names
The LSP only seems to autocomplete and show definition of registers using the x0-x31 format. Names such as zero or mcause do not generate a diagnostic error but cause issues when trying to see their reference.
Error Message Indentation
The diagnostic messages appear at a weird offset from the actual erroneous line

Goto Definitions
Using gd on the label .L_test_failed gives the following error. A similar error is thrown when trying to goto macro definition with id=45

Cannot open file
Even though I have specified my path = "src/" in .asm-lsp.toml, it gives me the following error message: Cannot open macro.S for reading, No such file or directory found. But when change the .include macro.S to .include src/macro.S is seems to work.
Environment
I have installed asm-lsp on Neovim using :Mason. It shows that that version 0.10.0 is installed. Using :LspInfo shows the following:
vim.lsp: Active Clients ~
- asm_lsp (id: 1)
- Version: ? (no serverInfo.version response)
- Root directory: <PATH_TO_CURRENT_DIR>
- Command: { "asm-lsp" }
- Settings: {}
- Attached buffers:
My .asm-lsp.toml generated using the asm-lsp gen-config for the project is as follows:
[[project]]
path = "src"
version = "0.10.0"
assembler = "gas"
instruction_set = "riscv"
[project.opts]
compiler = "riscv64-unknown-elf-gcc"
compile_flags_txt = [
'"-T riscv.ld"',
"-nostdlib",
"-march=rv32im_zicsr",
"-mabi=ilp32",
]
diagnostics = true
default_diagnostics = false
The following is my directory structure based on the specification I have to work with:
.
├── Makefile
├── README.md
└── src
├── lib.s
├── macro.s
├── main.s
├── regs.s
├── riscv.ld
├── startup.s
├── syscalls.s
└── trap.s
My git directory is 2 stages above the projects root directory. I did try to do git init in my current project directory but the above issues still persist.
Let me know if any additional information such as the :LspLog or my global .asm-lsp.toml is required.
Update: I have also added a compile_commands.json using bear -- riscv64-unknown-elf-gcc -T src/riscv.ld -nostdlib -march=rv32im_zicsr -mabi-ilp32 src/* -o build/main. The contents of the ./compile_commands.json are as follows:
[
{
"arguments": [
"~/Desktop/Tests/RISCV64/riscv64-unknown-elf-toolchain/bin/riscv64-unknown-elf-gcc",
"-c",
"-mabi=ilp32",
"-march=rv32im_zicsr",
"-o",
"build/main",
"src/lib.S"
],
"directory": "~/Desktop/Tests/current_dir",
"file": "~/Desktop/Tests/current_dir/src/lib.S",
"output": "~/Desktop/Tests/current_dir/build/main"
},
{
"arguments": [
"~/Desktop/Tests/RISCV64/riscv64-unknown-elf-toolchain/bin/riscv64-unknown-elf-gcc",
"-c",
"-mabi=ilp32",
"-march=rv32im_zicsr",
"-o",
"build/main",
"src/macro.S"
],
"directory": "~/Desktop/Tests/current_dir",
"file": "~/Desktop/Tests/current_dir/src/macro.S",
"output": "~/Desktop/Tests/current_dir/build/main"
},
{
"arguments": [
"~/Desktop/Tests/RISCV64/riscv64-unknown-elf-toolchain/bin/riscv64-unknown-elf-gcc",
"-c",
"-mabi=ilp32",
"-march=rv32im_zicsr",
"-o",
"build/main",
"src/main.S"
],
"directory": "~/Desktop/Tests/current_dir",
"file": "~/Desktop/Tests/current_dir/src/main.S",
"output": "~/Desktop/Tests/current_dir/build/main"
},
{
"arguments": [
"~/Desktop/Tests/RISCV64/riscv64-unknown-elf-toolchain/bin/riscv64-unknown-elf-gcc",
"-c",
"-mabi=ilp32",
"-march=rv32im_zicsr",
"-o",
"build/main",
"src/regs.S"
],
"directory": "~/Desktop/Tests/current_dir",
"file": "~/Desktop/Tests/current_dir/src/regs.S",
"output": "~/Desktop/Tests/current_dir/build/main"
},
{
"arguments": [
"~/Desktop/Tests/RISCV64/riscv64-unknown-elf-toolchain/bin/riscv64-unknown-elf-gcc",
"-c",
"-mabi=ilp32",
"-march=rv32im_zicsr",
"-o",
"build/main",
"src/startup.S"
],
"directory": "~/Desktop/Tests/current_dir",
"file": "~/Desktop/Tests/current_dir/src/startup.S",
"output": "~/Desktop/Tests/current_dir/build/main"
},
{
"arguments": [
"~/Desktop/Tests/RISCV64/riscv64-unknown-elf-toolchain/bin/riscv64-unknown-elf-gcc",
"-c",
"-mabi=ilp32",
"-march=rv32im_zicsr",
"-o",
"build/main",
"src/syscalls.S"
],
"directory": "~/Desktop/Tests/current_dir",
"file": "~/Desktop/Tests/current_dir/src/syscalls.S",
"output": "~/Desktop/Tests/current_dir/build/main"
},
{
"arguments": [
"~/Desktop/Tests/RISCV64/riscv64-unknown-elf-toolchain/bin/riscv64-unknown-elf-gcc",
"-c",
"-mabi=ilp32",
"-march=rv32im_zicsr",
"-o",
"build/main",
"src/trap.S"
],
"directory": "~/Desktop/Tests/current_dir",
"file": "~/Desktop/Tests/current_dir/src/trap.S",
"output": "~/Desktop/Tests/current_dir/build/main"
}
]
```</div>