#assembly #language-server #x86 #lsp #tooling

bin+lib asm-lsp

Language Server for x86/x86_64, ARM, RISCV, and z80 Assembly Code

14 releases (7 breaking)

0.9.0 Sep 4, 2024
0.7.4 Jul 30, 2024
0.6.0 Nov 26, 2023
0.3.2 Mar 30, 2023
0.2.0 Jul 27, 2020

#288 in Development tools

Download history 539/week @ 2024-08-03 460/week @ 2024-08-10 477/week @ 2024-08-17 639/week @ 2024-08-24 1086/week @ 2024-08-31 704/week @ 2024-09-07 545/week @ 2024-09-14 525/week @ 2024-09-21 486/week @ 2024-09-28 444/week @ 2024-10-05 468/week @ 2024-10-12 414/week @ 2024-10-19 400/week @ 2024-10-26 379/week @ 2024-11-02 310/week @ 2024-11-09 362/week @ 2024-11-16

1,511 downloads per month

BSD-2-Clause

3.5MB
7K SLoC

Language Server for GAS/GO Assembly

crates.io Tests

Goal

Provide hovering, autocompletion, signature help, go to definition, and view references for assembly files written in the GAS/NASM or GO assembly flavors. It supports assembly files for the x86, x86_64, ARM, RISCV, and z80 instruction sets.

This tool can serve as reference when reading the assembly output of a program. This way you can query what each command exactly does and deliberate about whether the compiler is producing the desired output or whether you have to tweak your code for optimisation.

Installation

Using cargo

Install using the cargo package manager, either from crates.io or from github:

cargo install asm-lsp
# or to get the latest version from github
cargo install --git https://github.com/bergercookie/asm-lsp

Set up as a language server

Add a section like the following in your settings.json file:

"asm-lsp": {
    "command": "asm-lsp",
    "filetypes": [
        "asm", "s", "S"
    ]
}

[OPTIONAL] Configure via .asm-lsp.toml

Add a .asm-lsp.toml file like the following to your project's root directory and/or ~/.config/asm-lsp/ (project configs will override global configs) to selectively target specific assemblers and/or instruction sets. Omitting an item from the assemblers or instruction_sets sections is equivalent to setting it to false. Be default, diagnostics are enabled and the server attempts to invoke gcc (and then clang) to generate them. If the compiler config field is specified, the server will attempt to use the specified path to generate diagnostics.

version = "0.1"

[assemblers]
gas = true
go = false
z80 = false
masm = false
nasm = false

[instruction_sets]
x86 = false
x86_64 = true
z80 = false
arm = false
riscv = false

[opts]
#compiler = "gcc"
diagnostics = true
default_diagnostics = true

[OPTIONAL] Extend functionality via compile_commands.json/compile_flags.txt

Add a compile_commands.json or compile_flags.txt file to your project's root or root build directory to enable inline diagnostic features, as well as to specify additional include directories for use in hover features. If a compile_commands.json or compile_flags.txt file isn't provided, the server will attempt to provide diagnostics with a default compile command. This feature can be disabled by setting the default_diagnostics config field to false.

VSCode Support

The project has not published any VSCode extension package yet. However, there is a development extension in the editors/code directory with setup instructions.

Root directory must contain .git

The lsp searches for a .git directory to locate the root of your project. Please be sure to run git init if your project is not already configured as a git repository.

Demos / Features Documentation

Hovering / Documentation support

Autocomplete

Diagnostics

Goto Definition

View References

Signature Help

  • Triggering signature help is dependent on your editor and LSP client.
    • Using Neovim's built in LSP client, this can be done via the command :lua vim.lsp.buf.signature_help().
    • Using coc, this issue comment suggests the remap inoremap <silent> ,s <C-r>=CocActionAsync('showSignatureHelp')<CR> to trigger signature help in insert mode.

Acknowledgements / Sources

Dependencies

~12–26MB
~399K SLoC