EmmyLua / IntelliJ-EmmyLua

Lua IDE/Debugger Plugin for IntelliJ IDEA
https://emmylua.github.io
Apache License 2.0
1.74k stars 293 forks source link

Contents of init.lua not indexed for packages #415

Closed posborne closed 1 year ago

posborne commented 3 years ago

Environment(环境)

name version
IDEA version CLion 2020.3.3
EmmyLua version 1.3.5.194-IDEA203
OS Ubuntu 20.04

What are the steps to reproduce this issue?(重现步骤?)

  1. Define package with contents in an init.lua file under the directory
  2. Attempt to use code intelligence features that should detect functions, etc. defined in the init.lua file.

For instance, consider the following directory structure:

test.lua
mypkg/
   init.lua

In mypkg/init.lua, let's say we have the following:

-- mypkg/init.lua
local module = {}
module.greting = "hi"
return module
-- test.lua
local mypkg = require "mypkg"

print("mypkg says: ", mypkg.greeting)

What happens?(出现什么问题?)

Going to definition on the require target and on mypkg.greeting do not work. The default package.path used for lookups includes the pattern $base/?/init.lua which EmmyLua does not seem to consider.

Replacing test.lua with the following works but should not be necessary:

local mypkg = require "mypkg.init"

-- ...

What were you expecting to happen?(期望?)

EmmyLua should be aware of the init.lua lookup pattern and code intelligence features should look for this file.

Any logs, error output, etc?(有没有什么log, error输出?)

(If it’s long, please paste to https://ghostbin.com/ and insert the link here.)

Any other comments?(其它说明)

Thank you for building a great product! …

neopaf commented 1 year ago

Please? I got a big project full of those init.lua and I'm at a loss on my diving into this..