lexical-lsp / lexical

Lexical is a next-generation elixir language server
874 stars 80 forks source link

Infer default `@spec` when completing above an existing `def`/`defp` #797

Closed zachallaun closed 2 months ago

zachallaun commented 2 months ago

This is essentially the inverse of #787.

The following:

@sp|
def my_function(arg) do
  ...
end

Completes to:

@spec
def my_function(arg) do
  ...
end

If the completion is immediately before a def, the function name and arity could be inferred:

@spec my_function(term()) :: term()
def my_function(arg) do

end
scohen commented 2 months ago

You can also infer the arg names

@spec my_function(arg :: term()) :: term