scalameta / metals-feature-requests

Issue tracker for Metals feature requests
37 stars 4 forks source link

Allow exclusion of some classes when considering imports #370

Open udalrich opened 8 months ago

udalrich commented 8 months ago

Is your feature request related to a problem? Please describe.

There are certain packages from which I never want to make an import, even though they are on my class path. For example, Akka has various *.javadsl and *.scaladsl packages, intended for use with java and scala. Obviously, if I'm using metals, I'm programming in scala and never want the javadsl version.

Other common names, like Logger or Node often appear in multiple packages. Being able to exclude that packages that I never want to import makes the interface easier to use: sometimes there is only one surviving option and I do not have to choose. Even if there are multiple options, fewer of them mean that the one that I want is likely easier to get to.

Describe the solution you'd like

The ability to specify a list of regular expressions to metals would be ideal. When metals attempts to find possible imports, and import that matches one of the regexes would be filtered out.

One corner case to consider is what to do if all of the matches are filtered out. In that case, I think returning no results would be best, but I can see the argument for returning the full, unfiltered list.

Describe alternatives you've considered

I use metals via lsp-metals in emacs. The filtering could be implemented there, but if it is added in metals, then people who use it via another interface would also benefit.

Additional context

No response

Search terms

filter import package

tgodzik commented 8 months ago

Thanks for reporting, did you try metals.excludedPackages setting?