erlang-ls / erlang_ls

The Erlang Language Server
https://erlang-ls.github.io/
Apache License 2.0
626 stars 136 forks source link

Either add functions to existing export attribute or create a new export attribute #1462

Open fridayy opened 11 months ago

fridayy commented 11 months ago

Is your feature request related to a problem? Please describe. Currently, the export_function/4 code action on unused functions always adds a new -export([some_fun/0]) module attribute. Which is totally fine from a functional perspective.

-module(some).

-export([some_fun/0]).
-export([some_fun/1]).
-export([another_fun/3]).
...

However I prefer the -export([[Name1/Arity1, ..., NameN/ArityN]). style of doing exports thus I catch myself manually merging the generated exports into a single export all the time.

-module(some).
-export([
    some_fun/0,
    some_fun/1,
    another_fun/3
]).

Describe the solution you'd like Alternatively create a new -export() or add the unused function to an existing -export().

Additional context From my limited experience there are many -export() styles and of course all of this is highly subjective. An implementation satisfying all possible scenarios just add lots of accidental complexity. However I think a simple implementation like either add a new export or add it to "last" existing export would suffice and still be helpful.

I did a quick experiment here.

Happy to hear your opinion on this and I hope my remarks make sense. Thank you for for erlang_ls and have a nice day :+1: