lua-language-server icon indicating copy to clipboard operation
lua-language-server copied to clipboard

Require of files from other workspaces

Open armbrmaSICKAG opened this issue 3 years ago • 1 comments

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Windows

What is the issue affecting?

Completion

Expected Behaviour

In VSCode with multiple workspaces, it is not possible to require files from other workspaces within a specific workspace.

Example: br-mw-require-expected From workspace/F.lua, no other Lua file (except the default ones) can be required.

Actual Behaviour

In workspaces whose names are the start of the names of other workspaces, files from the other workspaces can be required if they return something.

Example: br-mw-require1 The name of workspace w is the start of the workspaces w1, w2, w3, w35, and workspace. Therefore, all files from these workspaces can be required (because all files return 5). br-mw-require2 Within the workspace w3 whose name is the start of the workspace w35, w35/G.lua can be required.

Reproduction steps

  1. Open a new folder within VSCode.
  2. Add a new folder to VSCode to create a new VSCode workspace. The name of this second folder must be <name of the first folder><some characters>.
  3. Create a new Lua file within the second folder which returns something, e.g., a number, string or table.
  4. Create a new Lua file within the first folder, and type require(' within this file. The name of the file from the second folder should appear in the code completion.

Additional Notes

No response

Log File

No response

armbrmaSICKAG avatar Sep 20 '22 08:09 armbrmaSICKAG

Each workspace has its own private environment. You need use Lua.workspace.library.

sumneko avatar Sep 22 '22 10:09 sumneko

In the screenshots, every directory corresponds to one LSP workspace, and the directory called workspace has its own environment as I cannot require the files from the other directories. However, in the directories w and w3, I can require files from certain other directories although it should not be possible as I did not set the Lua.workspace.library setting and want to keep the files of the directories separate. It seems that it is possible in a directory/workspace to require files from other directories/workspaces whose names equal the name of the former directory/workspace appended by a suffix. In the example, from directory/workspace w3, the files in the directory/workspace w35 can be required.

ghost avatar Sep 26 '22 11:09 ghost