Skip to content

[Feature request] Class-based auto-require #3202

Open
@NyakoFox

Description

@NyakoFox

My project has some strict styling, and what we have is a system where:

  • MyClass is the sole returned class in myclass.lua, annotated and everything
  • Usage is local MyClass = import("src.myclass")

The language server has a setting for auto-requires. Unfortunately, it hardcodes the require function & is completely filename based.

I've just opened #3201 to add the import thing, but I'd like to request a setting which makes auto-requires work better with the class names, rather than being filename-based.

Ex. MyClass.something() suggests to require the file as local MyClass = import("src.myclass") rather than myclass.

We've considered either not caring (very ugly for code-style), manually fixing it every time (makes auto-requires kind of useless) or changing the filenames to be cased the same as the class (not a proper solution but a workaround -- one that would make the file structure look worse & fear for case sensitive filesystems)

As far as I can tell, this seems like a language server limitation rather than a design limitation. I would try to contribute this option myself, but this codebase seems too complicated for me to understand unfortunately...

(I just realized I opened a similar request a year ago -- I completely forgot and have closed it now.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions