Skip to content

completion: only show ca65 keyword doc at correct places #36

@taylorplewe

Description

@taylorplewe

What's changing

Conditionally add the ca65 keyword CompletionItems to the completion provider, only when a ca65 keyword would actually be valid

Motivation for change

Currently the keywords are just always in the completion list, regardless of where the cursor is; this is poor quality

Background/Notes

A ca65 keyword is valid:

  • if it is a control command and is the lhs operand, that is, nothing should precede it on the same line.
    • the only thing that can precede it is a label:
    sintab: .byte $40, $32
    • the only exception to this rule is .set, which must follow an identifier:
    myVar .set 0
  • if it is a pseudo variable or pseudo function and is the rhs operand; i.e. it must follow an instruction or control command which requires a parameter (e.g. .if, .byte, .word, lda).
    • the one exception here is .ident, which essentially replaces itself with its arguments, creating an identifier, and thus is valid wherever an identifier would be valid:
    .ident(.concat("rice", "_patty")):
    ; is the same as:
    rice_patty:

so, put another way, there are four categories of valid places a ca65 keyword could be:

  • preceded by either nothing or a label
    • all control commands except .set
  • preceded by an instruction or other keyword which requires a parameter
    • all pseudo variables & pseudo functions except .ident
  • preceded by an identifier
    • .set
  • anywhere an identifier is valid
    • .ident

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    Status

    Ready

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions