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

Allow support for variable and different file path notations in xml.FileAssociations #307

Closed
marsfan opened this issue Aug 9, 2020 · 7 comments · Fixed by #334
Closed
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@marsfan
Copy link

marsfan commented Aug 9, 2020

A number of things that are normally supported by configuration options in VS code JSON files do not seem to work when configuring xml.FileAssociations.
Namely:

  • Variable Substitution
  • Windows-Style file paths.

As an example, I have a test repository that has a schema in one folder, and an XML file in another folder.

Project Structure Photograph

image

    "xml.fileAssociations": [{
            "systemId": "schema/schema.xsd",
            "pattern": "testFile/*.xml"
        }]
} 

This works as expected, XML files in the testFile folder are checked against the schema document.

But if I instead refer to the files using the ${workspaceFolder} variable built into VS code like this:

    "xml.fileAssociations": [{
            "systemId": "${workspaceFolder}/schema/schema.xsd",
            "pattern": "${workspaceFolder}/testFile/*.xml"
        }]
}

The files are not being checked against the schema, and I do not get any warnings.

Furthermore, if I use windows style file path notation

    "xml.fileAssociations": [{
            "systemId": "schema\\schema.xsd",
            "pattern": "testFile\\*.xml"
        }]
}

I once again find that my XML files are not being checked against the schema file.

Both of these should be supported when configuring settings for the extension. Variable substitution is important for configuring paths in global settings that will change for each workspace, and Windows file path support is necessary to maintain consistency with other options that might be set in the same file.

@angelozerr
Copy link
Contributor

@fbricon what do you think about this idea?

@angelozerr
Copy link
Contributor

@marsfan do you see other variable substitution than ${workspaceFolder} ?

@angelozerr angelozerr added the enhancement New feature or request label Sep 16, 2020
@angelozerr
Copy link
Contributor

I wonder if this variable substitution must be done on vscode-xml side or LemMinx (LS server) side. If we could manage workspaceFolder on LemMinx side it should be nice because all LSP client could benefit with that. Need to investigate if we can retrieve workspaceFolder on LemMinx server side.

It will depends too if we need to manage another variable substitution which could be specific to vscode. I'm waiting for answer of @marsfan

@datho7561
Copy link
Contributor

Here is the list of all the supported variables.

  • I won't implement the ones that only apply to multi-root projects, since vscode-xml doesn't work with multiroot projects as of yet.
  • Currently investigating some of the other ones

@datho7561
Copy link
Contributor

datho7561 commented Sep 28, 2020

I think getting this working on the language server side could be helpful. Actually, it looks easier on the client side

These appear to be the most helpful variables to me:

  • workspaceFolder
  • fileBasenameNoExtension
  • relativeFileDirname

Another thing that I want to implement in this PR is using . in the file path to mean the same thing as workspaceFolder:

  • Refer to a path relative to the opened folder in single root projects
  • When/if we move to multiroot projects, we can take . to mean apply this rule to each workspace, using the root of each workspace as workspaceFolder

datho7561 added a commit to datho7561/vscode-xml that referenced this issue Oct 2, 2020
Adds three variables that can be used in `xml.fileAssociations`:
 * ${workspaceFolder}
 * ${fileDirname}
 * ${fileBasenameNoExtension}

 These variables can be used for both the `pattern` and the `systemId`.

 Closes redhat-developer#307

Signed-off-by: David Thompson <davthomp@redhat.com>
datho7561 added a commit to datho7561/vscode-xml that referenced this issue Oct 2, 2020
Adds three variables that can be used in `xml.fileAssociations`:
 * ${workspaceFolder}
 * ${fileDirname}
 * ${fileBasenameNoExtension}

 These variables can be used for both the `pattern` and the `systemId`.

 Closes redhat-developer#307

Signed-off-by: David Thompson <davthomp@redhat.com>
datho7561 added a commit to datho7561/vscode-xml that referenced this issue Oct 5, 2020
Adds three variables that can be used in `xml.fileAssociations`:
 * ${workspaceFolder}
 * ${fileDirname}
 * ${fileBasenameNoExtension}

These variables can be used for both the `pattern` and the `systemId`.

Closes redhat-developer#307

Signed-off-by: David Thompson <davthomp@redhat.com>
datho7561 added a commit to datho7561/vscode-xml that referenced this issue Oct 5, 2020
Adds three variables that can be used in `xml.fileAssociations`:
 * ${workspaceFolder}
 * ${fileDirname}
 * ${fileBasenameNoExtension}

These variables can be used for both the `pattern` and the `systemId`.

Closes redhat-developer#307

Signed-off-by: David Thompson <davthomp@redhat.com>
datho7561 added a commit to datho7561/vscode-xml that referenced this issue Oct 7, 2020
Adds three variables that can be used in `xml.fileAssociations`:
 * ${workspaceFolder}
 * ${fileDirname}
 * ${fileBasenameNoExtension}

These variables can be used for both the `pattern` and the `systemId`.

Closes redhat-developer#307

Signed-off-by: David Thompson <davthomp@redhat.com>
datho7561 added a commit to datho7561/vscode-xml that referenced this issue Oct 7, 2020
Adds three variables that can be used in `xml.fileAssociations`:
 * ${workspaceFolder}
 * ${fileDirname}
 * ${fileBasenameNoExtension}

These variables can be used for both the `pattern` and the `systemId`.

Closes redhat-developer#307

Signed-off-by: David Thompson <davthomp@redhat.com>
datho7561 added a commit to datho7561/vscode-xml that referenced this issue Oct 13, 2020
Adds three variables that can be used in `xml.fileAssociations`:
 * ${workspaceFolder}
 * ${fileDirname}
 * ${fileBasenameNoExtension}

These variables can be used for both the `pattern` and the `systemId`.

Closes redhat-developer#307

Signed-off-by: David Thompson <davthomp@redhat.com>
datho7561 added a commit to datho7561/vscode-xml that referenced this issue Oct 13, 2020
Adds three variables that can be used in `xml.fileAssociations`:
 * ${workspaceFolder}
 * ${fileDirname}
 * ${fileBasenameNoExtension}

These variables can be used for both the `pattern` and the `systemId`.

Closes redhat-developer#307

Signed-off-by: David Thompson <davthomp@redhat.com>
@angelozerr angelozerr added this to the 0.14.0 milestone Oct 23, 2020
datho7561 added a commit to datho7561/vscode-xml that referenced this issue Oct 27, 2020
Adds three variables that can be used in `xml.fileAssociations`:
 * ${workspaceFolder}
 * ${fileDirname}
 * ${fileBasenameNoExtension}

These variables can be used for both the `pattern` and the `systemId`.

Closes redhat-developer#307

Signed-off-by: David Thompson <davthomp@redhat.com>
datho7561 added a commit to datho7561/vscode-xml that referenced this issue Oct 28, 2020
Adds three variables that can be used in `xml.fileAssociations`:
 * ${workspaceFolder}
 * ${fileDirname}
 * ${fileBasenameNoExtension}

These variables can be used for both the `pattern` and the `systemId`.

Closes redhat-developer#307

Signed-off-by: David Thompson <davthomp@redhat.com>
datho7561 added a commit to datho7561/vscode-xml that referenced this issue Oct 28, 2020
Adds three variables that can be used in `xml.fileAssociations`:
 * ${workspaceFolder}
 * ${fileDirname}
 * ${fileBasenameNoExtension}

These variables can be used for both the `pattern` and the `systemId`.

Closes redhat-developer#307

Signed-off-by: David Thompson <davthomp@redhat.com>
angelozerr pushed a commit that referenced this issue Oct 30, 2020
Adds three variables that can be used in `xml.fileAssociations`:
 * ${workspaceFolder}
 * ${fileDirname}
 * ${fileBasenameNoExtension}

These variables can be used for both the `pattern` and the `systemId`.

Closes #307

Signed-off-by: David Thompson <davthomp@redhat.com>
@swirle13
Copy link

It appears that environment variables are not supported in this, is that correct? My team has a bunch of different repos and each team have different environments (win, mac, linux) in which they work. So we all environment variables defined to point to the same repo, which is set individually. I was hoping to use the same variable we all use to reference in this so that every person doesn't have to manually change the systemId to match their own and instead could be the same

"systemId": "${env:REPO_LOC}/format.xsd"

I can open a new ticket for this request, if this is feasible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants