Skip to content

[VS Code] Cannot use scoped workspace folder variables in multiroot workspaces to define paths #2987

Closed
@dljsjr

Description

@dljsjr

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Linux

What is the issue affecting?

Other

Expected Behaviour

It should be possible to configure the Lua.runtime.path and Lua.workspace.library, and other file path related options in a multi-root workspace using scoped workspace folder variables.


Additional Information

Take the following multi-root workspace JSON, for example:

{
  "folders": [
    {
      "name": "projectFoo",
      "path": "/home/dstephen/AppProject/foo"
    },
    {
      "name": "projectBar",
      "path": "/home/dstephen/LibProject/bar"
    }
  ]
}

We have two projects in two totally different directory trees that are part of the same workspace, one of which is a "library".

Furthermore, let's assume that the workspace .json file is in a completely separate, third directory tree.

VS Code provides workspace folder scoping via the syntax ${workspaceFolder:} and the value in the name field after the colon (or the basename of the path as a fallback).

Given all of this, I would expect to be able to do the following:

{
  "folders": [
    {
      "name": "projectFoo",
      "path": "/home/dstephen/AppProject/foo"
    },
    {
      "name": "projectBar",
      "path": "/home/dstephen/LibProject/bar"
    }
  ],
  "settings": {
    "Lua.runtime.path": [
      "?.lua",
      "?/init.lua",
      "${workspaceFolder:projectBar}/?.lua",
      "${workspaceFolder:projectBar}/?/init.lua"
    ],
    // and/or:
    "Lua.workspace.library": [
      "${workspaceFolder:projectBar}"
    ]
  }
}

However, this doesn't seem to work; the only way to work around this is to use absolute paths for the language server configurations.

Actual Behaviour

Files that should be resolved at require time in the referenced directories are not resolved when workspace folder scoped variables are used

Reproduction steps

See the context/explanation in Expected Behavior

Additional Notes

No response

Log File

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions