helix icon indicating copy to clipboard operation
helix copied to clipboard

Add highlighting for assembler (.s)

Open kchibisov opened this issue 3 years ago • 6 comments
trafficstars

Would need a tree-sitter grammar for that.

kchibisov avatar Aug 04 '22 13:08 kchibisov

If I may; a problem with assembly 'language' suport is which? I have a tree-sitter-nasm which I used a fair amount for nasm assembly, but it probably won't handle eg. gas syntax well...

naclsn avatar Aug 04 '22 18:08 naclsn

I mainly see gas, since that's what everything dumps by default... Would be nice to have some primitive highlighting for both of them.

kchibisov avatar Aug 04 '22 20:08 kchibisov

It would also be nice to use the asm tree sitter for inline assembly in languages such as Rust, C/C++ ...

A-Walrus avatar Aug 05 '22 11:08 A-Walrus

I'm pretty sure that you can't do that with rust, given that its syntax is a bit different from what I remember or has a different more usable for form compared to C/C++.

kchibisov avatar Aug 05 '22 11:08 kchibisov

Yeah you're right, it has a different syntax:

unsafe {
    asm!(
        "mov {tmp}, {x}",
        "shl {tmp}, 1",
        "shl {x}, 2",
        "add {x}, {tmp}",
        x = inout(reg) x,
        tmp = out(reg) _,
    );
}

I suppose a tree-sitter parser for rust-inline-assembly could be written and used, but that's a separate feature.

A-Walrus avatar Aug 05 '22 14:08 A-Walrus

If I may; a problem with assembly 'language' suport is which? I have a tree-sitter-nasm which I used a fair amount for nasm assembly, but it probably won't handle eg. gas syntax well...

I would be highly interested in having nasm support. IIRC, it's also highly used out there. Separate gas support would also be nice.

jtepe avatar Oct 23 '22 12:10 jtepe

Gas syntax is not yet included, correct? If that's the case, should this issue be reopened until it is or should another issue be created?

kdwarn avatar Mar 21 '23 10:03 kdwarn

Yep only nasm is currently supported. I think a new issue for gas is perferrable

the-mikedavis avatar Mar 21 '23 14:03 the-mikedavis