vyperlang / vyper-lsp

A Vyper LSP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tab Completion

z80dev opened this issue · comments

commented

Tab Completion is a bottomless rabbithole. At its simplest implementation, we could just return a list of built-in types when a new variable is declared. At its most complex, we'd be recreating Github Copilot.

The purpose of this ticket is to find the right spot along this spectrum to target, and then track completion of our progress towards this point.

NOTE: In examples of in-editor code, the | symbol will be used to indicate cursor position|.

LSP API Methods

  • textDocument/completion

Variable Declaration Type Completion

When a user is declaring a new variable, whether at contract or local scope, we can provide a list of types, ordered by some opinionated usage-likelihood metric. For example, the most common types used are likely address, uint256, and bool. After these, its probably "custom types" (i.e. structs) used the most.

So when a user is declaring a new variable, we can present this list of types, containing any number of types, whether built-in or user-defined.

Contract Scope

# Foo.vy

owner: |

Local Scope

owner: address

@external
def foo():
    x: |