bergercookie / asm-lsp

Language server for NASM/GAS/GO Assembly
https://crates.io/crates/asm-lsp
BSD 2-Clause "Simplified" License
269 stars 18 forks source link

[feature] Autocomplete for labels/ [question] NASM support? #104

Closed ChillerDragon closed 4 months ago

ChillerDragon commented 4 months ago

The README.md promised

Provide hovering, autocompletion, signature help, go to definition, and view references for assembly files written in the GAS/NASM or GO assembly flavors.

So I was hoping to get instruction autocomplete and documentation for the assembly that compiles fine with nasm -f elf64 foo.asm -o foo.o. But by default all the documentation annotations seem to be about the GAS assembler.

Then I tried only turning on nasm like this

version = "0.1"

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

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

Where nasm does not seem to be a supported option according to my broken lsp and this file.


foo:
        mov eax, 0

bar:
        call foo

With this snippet I was able to autocomplete "mov", "eax" and "call" where "mov" and "eax" where coming from gas which is technically wrong but thats good enough for me. Sadly I could not get the label "foo" to auto complete.

Should auto completing those labels be supported? If not is there some hack to make it do it anyways? xd I do not want to switch to AT&T syntax or the GAS assembler.

WillLillis commented 4 months ago

Hi! Nearly all of the instruction information (used for instruction hover and autocomplete support) is based off of the xml files produced by the opcodes python package, which indicates that NASM instruction names are supported here. Unfortunately the opcodes project doesn't provide any nasm documentation beyond instruction names. It might be worth filing an issue there to ask.

Regarding the autocomplete issue, the project doesn't currently support autocompletion of labels. I'm happy to look into implementing this, but there are some existing limitations that will likely make it unreliable. The project currently uses tree-sitter to parse source files. The tree-sitter grammar we use is tree-sitter-asm, which aims to be generic enough to provide highlighting for multiple assembly flavors, but as a result isn't very exact. The grammar correctly identifies the labels in your example code, so I'll give this a shot sometime soon :)

image

ChillerDragon commented 4 months ago

Amazing thanks @WillLillis! For now I installed https://github.com/ycm-core/YouCompleteMe to get at least the labels from the current file auto completed. But ycm is such a big and bloated thing combining that with my lsp based neovim config is such a mess.

Since this issue was just a question and it is now answered it can technically be closed. Up to you @WillLillis not sure if you want to keep it around as reminder to look into labels or rather have your issues cleaned.

WillLillis commented 4 months ago

Amazing thanks @WillLillis! For now I installed https://github.com/ycm-core/YouCompleteMe to get at least the labels from the current file auto completed. But ycm is such a big and bloated thing combining that with my lsp based neovim config is such a mess.

Glad you were able to find a workaround! I should have some time to implement autocomplete for labels soon. Hopefully that'll let you trim down your config a bit :)

Since this issue was just a question and it is now answered it can technically be closed. Up to you @WillLillis not sure if you want to keep it around as reminder to look into labels or rather have your issues cleaned.

I'm happy leaving this open until the labels portion is resolved.