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

[Help] How to get completion from file in folder if functions exported in table? #657

Closed
B4rc1 opened this issue Aug 19, 2021 · 2 comments
Closed

Comments

@B4rc1
Copy link

B4rc1 commented Aug 19, 2021

Basically I have two files, lib.lua and main.lua.
lib.lua:

local lib = {}

--- This is a function :)
function lib.tst()
	print("test")
end

return lib

In here I get completion and hover Information just fine (using neovim but I also confirmed this in VSCode):
grafik

main.lua:

local lib = require("lib")

but I can get no hover Information or completion here:
grafik


If I remove the table containing the function and just export the function globally, It works as expected:
lib.lua:

--- This is a function :)
function tst()
	print("test")
end

main.lua:

require("lib")
tst()

grafik


Is it possible to also get completion in the first case? I'm only starting to learn lua, but this seems very doable. I tried messing around with Lua.runtime.path, Lua.workspace.ignoreSubmodules and Lua.workspace.library but sadly to no avail. To my understanding the defaults should do what I want. Especially Lua.runtime.path with a default value of { "?.lua", "?/init.lua", "?/?.lua" } should Include lib.lua in the current directory right? And because it works globally in the second case, I'm confident it is not an issue with my setup.

@sumneko
Copy link
Collaborator

sumneko commented Aug 20, 2021

Your usage is correct, but I cannot reproduce this problem in VSCode. Please provide your log.

@B4rc1
Copy link
Author

B4rc1 commented Aug 20, 2021

after checking the logs, it dawned on me, that ?.lua and ?/?.lua were not in my Lua.runtime.path. Then I remembered, I was using lua-dev to setup my language server for neovim plugin development. And it changes the default of Lua.runtime.path to lua/?.lua and lua/?/init.lua After adding ?.lua and ?/?.lua to my runtime path, it works as expected.

Thank you for your help!

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

No branches or pull requests

2 participants