Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve capture completions in capture context #773

Open
zachallaun opened this issue Jun 15, 2024 · 3 comments
Open

Improve capture completions in capture context #773

zachallaun opened this issue Jun 15, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@zachallaun
Copy link
Collaborator

zachallaun commented Jun 15, 2024

Completions in a capture context can be improved in a number of ways. In the following examples, consider that you have a function/1 and function/2 in scope.


Improve labels

If we're in a capture context, it would be nice if completions started with & to indicate that it is being considered in the completion responses.

&fun|

# desired completions:
# &function(arg1)
# &function/1
# &function(arg1, arg2)
# &function/2

Using additional &fun/arity context

When /arity is present, it should be used to improve completions.

&fun|/2

# current completions:
# function(arg1)
# function/1
# function(arg1, arg2)
# function/2

# desired completions:
# &function/2
# &function(arg1, arg2)
# &function/1
# &function(arg1)

Additionally:

  • Selecting function/2 inserts an additional /2, resulting in &function/2/2. It should emit a text edit resulting in &function/2. The same issue exists with function/1, which currently results in &function/1/2.
  • Selecting function(arg1, arg2) results in &function(arg1, arg2)/2. It should remove the /2.

Using additional &fun(arg) context

When (arg, ...) is present, it should be used to improve completions.

&fun|/(&1,  arg)

# current completions:
# function(arg1)
# function/1
# function(arg1, arg2)
# function/2

# desired completions:
# &function(arg1, arg2)
# &function/2
# &function(arg1)
# &function/1

Additionally:

  • Selecting &function(arg1, arg2) inserts additional args, resulting in &function(arg1, arg2)(&1, arg). It should emit a text edit resulting in &function(arg1, arg2).
@zachallaun zachallaun added the enhancement New feature or request label Jun 15, 2024
@zachallaun
Copy link
Collaborator Author

Regarding sorting: Currently function/2 and function(arg1, arg2) return the same sort text.

@zachallaun
Copy link
Collaborator Author

Regarding prefixing labels with &: maybe this shouldn't be done, as it confuses things somewhat for qualified captures:

&Enum.reduce_w|

# completions:
# reduce_while/3
# reduce_while(enumerable, acc fun)

It might be confusing for the completions to include &, e.g. &reduce_while/3, since what we're really completing is &Enum.reduce_while/3.

@zachallaun
Copy link
Collaborator Author

Some work-in-progress code can be found here: https://github.com/lexical-lsp/lexical/tree/za-capture-completions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant