LuaLS / LuaLS/lua-language-server

Require paths not resolved when external library is loaded and using custom require path

Open
#2,992 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Lua
Stars
4.4k
Forks
442
PR merge metrics
No merged PRs in 30d

Description

How are you using the lua-language-server?

NeoVim

Which OS are you using?

Windows

What is the issue affecting?

Completion, Hover, Libraries

Expected Behaviour

Hovering above lib should find lua/lib.lua.

Actual Behaviour

Hovering above lib yields 3 bytes, and only finds the path if either the file has not been loaded or no extra workspace library directory has been found.

Reproduction steps
  1. Setup the files:
-- lua/lib.lua
return {
	test = "hello"
}
-- cmd/test.lua
local lib = require 'lib'

assert(lib.test == "hello")
-- .luarc.json
{
	"runtime.path": [
		"lua/?.lua",
		"lua/?/init.lua"
	],
	"workspace.library": [
		"${3rd}/love2d/library"
	]
}
  1. Close NeoVim.
  2. Reopen NeoVim and open only the file cmd/test.lua
  3. Hover above lib and see bug.
  4. Open lua/lib.lua
  5. Go back to cmd/test.lua
  6. Completion is now available again.
Additional Notes

I could not reproduce this behaviour in VSCode.

Log File

Log file generated using the reproduction steps: https://pastebin.com/4VXMJjjB

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue using .luarc.json with lua/lib.lua and cmd/test.lua, following the listed NeoVim steps and checking the linked log. Trace how the custom runtime.path and workspace.library are handled after the external library is loaded; done means hovering and completion resolve lib consistently without opening lua/lib.lua first.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.