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

Feature/auto require without init #1711

Merged
merged 4 commits into from
Dec 2, 2022

Conversation

sewbacca
Copy link
Contributor

@sewbacca sewbacca commented Nov 18, 2022

This pull request solves #875. In completion, it respects now custom require paths.
Consider this file strucuture:

  • mylib
    • init.lua with return { }
  • test.lua with myli
    And the package path: ?.lua;?/init.lua.
    It will now allow auto require mylib or mylib.init.
    As for nested modules, it will try do match the most specific module first:
  • mylib
    • inner
      • init.lua with return { }
    • init.lua with return { }
  • test.lua with inn
    inn will match to inner, but mylib won't point to mylib.inner but mylib.init.
    It didn't broke any tests and I tested it manually. I would have written tests, but I don't know how I can add additional package paths in crossfile/completion.lua.

@sumneko
Copy link
Collaborator

sumneko commented Nov 21, 2022

You can infer these tests: ./test/tclient/tests

@sewbacca
Copy link
Contributor Author

sewbacca commented Nov 23, 2022

Okay I've noticed I can just manipulate the config in place. To not bleed into other tests, I added a local function called WITH_CONFIG which essentially scopes the changes to the config for the given function.
I'm unsure if these tests suffice, but I think they cover all essential use cases (except the one module in one file ones - I think I already saw tests for those). See this commit for more details.

@sewbacca sewbacca marked this pull request as ready for review November 26, 2022 00:23
@sumneko
Copy link
Collaborator

sumneko commented Dec 1, 2022

Please resolve conflicts

@sewbacca sewbacca force-pushed the feature/auto-require-without-init branch from 387841c to d848fda Compare December 1, 2022 21:57
@sewbacca
Copy link
Contributor Author

sewbacca commented Dec 1, 2022

Oh this explains why I was having issues lately, I was just 799 commits behind.
Its done now :D

@sumneko sumneko merged commit 98efc56 into LuaLS:master Dec 2, 2022
@sewbacca sewbacca deleted the feature/auto-require-without-init branch December 7, 2022 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants