Code Monkey home page Code Monkey logo

asm-lsp's Introduction

Hi there, 👋👋 I'm Nikos,


GH Followers Website Linkedin

Twitter Followers Photography


I'm a Robotics Product Engineer, currently situated in London and working at SLAMcore 🤖

  • 🛠 I’m working on Open-Source Robotics, Automation tools, Anki, Albert, Vim plugins, and lots more!
  • 📖 I’m currently learning about Rust, 🦀, Embedded Systems, Photography 📸, Spanish 🇪🇸,
  • 📢 Ask me about my Linux setup 🐧
  • 💬 Pronouns: He/Him

Stats

asm-lsp's People

Contributors

bergercookie avatar c-cube avatar decodetalkers avatar enriquefft avatar maratyszcza avatar mquigley avatar notashelf avatar promyloph avatar pwaller avatar willlillis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

asm-lsp's Issues

Hi i am getting an error

i get this error:
thread 'main' panicked at 'byte index 5 is out of bounds of ', library/core/src/str/mod.rs:107:9
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

i think it is when i tab over very much to comment a line but i am not sure.

Add support for arm / arm64 instruction sets

This is a placeholder ticket to look at extending asm-lsp to also output information for arm/arm64 instructions

ARM is publishing architecture specification documentation in PDF/HTML and XML forms so we should be able to parse that info and populate our Instruction / InstructionForm instances.

Here's some resources to learn more about it

https://developer.arm.com/downloads/-/exploration-tools
https://github.com/alastairreid/mra_tools
https://alastairreid.github.io/dissecting-ARM-MRA/
https://alastairreid.github.io/ARM-v8a-xml-release/
https://alastairreid.github.io/arm-v8_3/
https://alastairreid.github.io/specification_languages/

Int3 Instruction Missing

Hey!

I noticed that the int3 (and flavours) is missing. Should I create an PR to add this instruction? Or what is the process to add instruction?

Better Autocomplete Labels

Currently, register suggestions are labeled as Variable and instruction suggestions are labeled as Operator. This is because we're limited by the types defined in the LSP spec. As the spec may be expanded in the future to allow for other completion type labels, this issue can be a placeholder for if/when this happens. See: gluon-lang/lsp-types#270

Add support for Z80 instruction sets

The Zilog Z80 is a legendary 8-bit microprocessor renowned for its versatility and widespread use in the retro computing era. Introduced in the late 1970s, it became a cornerstone in various iconic systems of that time, notably the MSX, Amstrad CPC, Sinclair ZX80, ZX81, ZX Spectrum, Gameboy, Enterprise, Sam Coupe, and the CP/M-based computers like the Osborne 1 and Kaypro.

The Z80 assembly language continues to inspire a vibrant community of developers who craft remarkable games and applications for retro platforms. Despite the passage of time, these dedicated programmers harness the Z80's capabilities to create engaging content that captivates audiences on classic systems like the Sinclair ZX Spectrum, the Amstrad CPC, MSX and more.

Here are some references about the cpu and its instruction set:

asm-lsp doesn't attach to a buffer

I've set up the language server like this after installing it with cargo on Arch Linux (AUR's version breaks during installation for some reason, but that's a different issue):

require'lspconfig'.asm_lsp.setup{}

And added this to my coc-settings.json:

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

:LspInfo shows the server is there but it's not attached:

image

What am I doing wrong? Should the root directory be set up somehow?

:LspLog shows ancient logs from last year, for some reason.

LSP server error: `Invalid request fromat`

LSP-Server: asm-lsp 0.6.0
IDE: Kate 23.08.4
OS: openSUSE Tumbleweed 20231228 (x86_64)
Assembly Type: NASM

Note: The title does not contain a typo, this is a typo in the code.

I've added an example with code and the corrosponding output to reproduce the bug:

Code
section .bss
    input_char resb 1   ; Reserve 1 byte for the input character

; registers
; r12 num a

section .data
    total dq 0    ; the total sum
    num dq 0      ; entry integer
    print_char db 0

section .text
    global _start

is_digit:
    ; check if value of input_char is a digit
    cmp byte [input_char], '0'
    jl not_digit
    cmp byte [input_char], '9'
    jg not_digit

    mov rax, 1
    ret

not_digit:
    xor rax, rax; set 0
    ret

error:
    mov rax, 60
    mov rdi, 1
    syscall

read_char:
    ; Read a single character
    mov rax, 0          ; sys_read
    mov rdi, 0          ; fd 0 (standard input)
    mov rsi, input_char ; ptr to input
    mov rdx, 1          ; number of bytes to read
    syscall
    ret

sum:
    add [total], r12
    mov r12, 0
    ret

number_input:
    call read_char
    cmp byte [input_char], 10 ; \n
    je sum
    cmp byte [input_char], -1 ; EOF
    je error
    call is_digit
    cmp rax, 0
    je error
    call is_digit
    je append_number
append_number:
    imul r12, 10
    sub byte [input_char], '0' ; char to num
    movzx r13, byte [input_char] ; zero-extend the byte to 64 bits
    add r12, r13
    call number_input
    ret

reverse_number:
    mov r13, rdi ; r13 = input number
    xor r14, r14 ; r14 = 0
    call reverse_loop
    mov rax, r14
    ret
reverse_loop:
    imul r14, r14, 10
    mov rax, r13
    xor rdx, rdx
    mov rcx, 10
    div rcx
    add r14, rdx
    mov r13, rax
    cmp r13, 0
    jg reverse_loop    ; continue loop if r13 > 0
    ret

print_number:
    call reverse_number
    mov r13, rax ; number to print/decrement
    call print_number_loop
    ret
print_number_loop:
    ; divide r13 and puts it back with 1 less digit on right
    mov rax, r13
    mov rcx, 10
    mov rdx, 0
    div rcx
    mov r13, rax
    ; print remainder
    mov [print_char], rdx;
    add byte [print_char], '0'
    mov rax, 1          ; sys_write system call number
    mov rdi, 1          ; file descriptor 1 (stdout)
    mov rsi, print_char      ; pointer to the character
    mov rdx, 1          ; number of bytes to write
    syscall
    cmp r13, 0
    jg print_number_loop    ; continue loop if r13 > 0
    ret

_start:
    call number_input
    call number_input
    call sum

    mov rdi, [total]
    call print_number

    mov [print_char], byte 10 ; newline
    mov rax, 1
    mov rdi, 1
    mov rsi, print_char
    mov rdx, 1
    syscall

    mov rax, 60    ; System call number for sys_exit
    mov rdi, 0     ; Exit code 0
    syscall
Logs
[21:09:17  LSP Client Log] Started server asm-lsp@/home/user: /home/user/.cargo/bin/asm-lsp
[21:09:17  LSP Server Log] asm-lsp@/home/user
INFO [asm_lsp] Starting LSP server...
[21:09:17  LSP Server Log] asm-lsp@/home/user
INFO [asm_lsp] Populating register set -> x86...
INFO [asm_lsp] Populating register set -> x86_64...
INFO [asm_lsp] Populating instruction set -> x86...
[21:09:17  LSP Server Log] asm-lsp@/home/user
INFO [asm_lsp::x86_parser] Fetching html page containing further documentation, from the cache -> /home/user/.cache/asm-lsp/x86_instr_docs.html...
[21:09:17  LSP Server Log] asm-lsp@/home/user
INFO [asm_lsp] Populating instruction set -> x86_64...
[21:09:17  LSP Server Log] asm-lsp@/home/user
INFO [asm_lsp::x86_parser] Fetching html page containing further documentation, from the cache -> /home/user/.cache/asm-lsp/x86_instr_docs.html...
[21:09:18  LSP Server Log] asm-lsp@/home/user
INFO [asm_lsp] Populating register set -> x86...
INFO [asm_lsp] Populating register set -> x86_64...
[21:09:18  LSP Server Log] asm-lsp@/home/user
INFO [asm_lsp] Starting LSP loop...
[21:09:18  LSP Server Log] asm-lsp@/home/user
ERROR [asm_lsp] Invalid request fromat -> Request {
    id: RequestId(
        I32(
            2,
        ),
    ),
    method: "textDocument/documentSymbol",
    params: Object {
        "textDocument": Object {
            "uri": String("file:///home/user/Programming/ASM/Sum/sum.asm"),
        },
    },
}
[21:09:19  LSP Server Log] asm-lsp@/home/user
ERROR [asm_lsp] Invalid request fromat -> Request {
    id: RequestId(
        I32(
            3,
        ),
    ),
    method: "textDocument/documentSymbol",
    params: Object {
        "textDocument": Object {
            "uri": String("file:///home/user/Programming/ASM/Sum/sum.asm"),
        },
    },
}

[Feature request] Select assembler

For the specific project I am working on, I am only using the GNU assembler. I don't need to see the alternative NASM or GO opcodes. When looking at the list of alternative forms for a base opcode, this can be quite overwhelming.

It would be nice if we could choose which assembler we want to display documentation for/target.

On this same note, I feel displaying the hovered opcode's specific form in bold would make it easier to quickly find its specifics.

image

Regardless, thanks for putting this up there :)

Add github CI actions for repo

On new commit to master and on new pull-request there should be a github actions workflow that checks that:

  • cargo build, cargo run work as intended

Additionally, when new tags are created on the master branch we should issue cargo publish to generate and publish to crates.io new packages for asm-lsp

Correct Register Autocompletes

Currently when an completion request is received for a register, a list is sent with all available register names. Some simple translation code could filter this list to only suggest registers that match the type required for the given instruction. This can probably be done in the following manner:

  • Inside get_comp_resp, when a tree_sitter::Query matches, we get the instruction name by calling .utf8_text() on the @instr_name capture. We could then issue a lookup into the NamesToInstructions map, and iterate through the instruction forms to find valid operand types (This would require a translation between the OperandType and RegisterWidth enums). A quick filter on the vector of register completions so that only registers that match this criteria could then be done.

Utilize Tree-sitter incremental parsing

One of Tree-sitter's strengths is its incremental parsing. Currently the LSP doesn't take advantage of this and instead creates a fresh new tree every time parse is called. This is because it's difficult to find a good/ reliable way to map incremental edit information from the lsp_server's notifications to the format that Tree-sitter is expecting. This appears to be a known issue, see: tree-sitter/tree-sitter#210

  • To investigate this, change the text_document_sync in src/bin/main.rs from TextDocumentSyncKind::FULL to TextDocumentSyncKind::INCREMENTAL
  • Inside the main_loop in src/bin/main.rs, when a Message::Notification is received of type DidChangeTextDocument, a list of edits will be included. These edits will need to be applied to the local copy of curr_doc, and then translated into the form Tree-sitter is expecting for a .edit() call on the Tree object. Currently, the tree is constructed inside of get_comp_resp(). Edit information is expected to include both byte offsets and row/column coordinates. Edit information communicated according to the LSP spec is just communicated in terms of line/ character(row/column) ranges.

Utilizing incremental parsing (either following a change in the LSP spec or if a reliable workaround can be implemented) would help make autocompletion more responsive.

License?

There seems to be no license for this project.

Global configuration

How about let asm-lsp detect configuration by the following order?

  • ~/.config/asm-lsp/asm-lsp.toml
  • /the/path/of/project/.asm-lsp.toml

C++ assembly lsp not working in neovim

Hi,
thanks for this tool.
I generate C++ assembly using CMake using GCC . The file has an extension of "*.a" and I added that extension to filetypes in the config
image
However when I open the file , the filetype is not recognized as asm so I set the filetype both in the config and also manually using :set filetype=asm the file type is recognized but lsp still does not work
image
here is the lsp info
image
image
Also when I generate Rust asm then it generates assembly with a *.s" extension . I open the file both filetype is recognized and lsp / hoover works
I am using Arch and using GCC 13.2.1 and neovim 0.9.0

Autocompletion cannot work

Screenshot from 2023-12-20 00-53-48

Document hover can work for me, So I ensure the language server have been working. However, I cannot see any completion of asm-lsp. TIA!

[feature] Goto Defintions/Goto References

  .section .data
  .section .text
  .globl _start
_start:
  movl $1, %eax
  movl $0, %ebx
  int $0x80

When the cursor is in the .globl _start's _start, go to definition will go to _start:, then go to reference will jump return to .globl _start's _start.

TIA!

Add basic suite of unitests

Add unittests to verify that core functions of this package work as expected.

  • Can we mock reqwest::blocking::get and verify that populate_instructions does produce a valid vector of Instructions ?

Error in 0.3.2

Hi there, at first I was getting an error when trying to use asm-lsp with Neovim and would get an error:

Client quit with exit code 101 and signal 0

Then I tried to build it from source, and when I run the executable I get:

INFO [asm_lsp] Populating instruction set -> x86...
thread 'main' panicked at 'called Option::unwrap() on a None value', src/x86_parser.rs:236:38
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

I'm using the Nightly build of Rust

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.