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

Support hdl-prj.json in multi-root workspaces #11

Open
eine opened this issue Jul 12, 2019 · 1 comment
Open

Support hdl-prj.json in multi-root workspaces #11

eine opened this issue Jul 12, 2019 · 1 comment

Comments

@eine
Copy link
Contributor

eine commented Jul 12, 2019

Ref: Multi-root workspaces where mentioned in #5.

Currently, multi-root workspaces seem not to be supported. I added the following hdl-prj.json to VUnit's examples/vhdl/array_axis_vcs:

{
    "options": {
        "ghdl_analysis": [
            "--std=08",
            "-Pvunit_out/ghdl/libraries/osvvm",
            "-Pvunit_out/ghdl/libraries/vunit_lib"
        ]
    },
    "files": [
        { "file": "src/fifo.vhd", "language": "vhdl" },
        { "file": "src/axis_buffer.vhd", "language": "vhdl" },
        { "file": "src/test/tb_axis_loop.vhd", "language": "vhdl" }
    ]
}

If I open the folder, everything works as expected:

Args: ['/usr/local/bin/ghdl-ls', '-v']
Current directory: /src/vunit/vunit/examples/vhdl/array_axis_vcs
2019-07-12 00:39:49,129 [INFO] Args: ['/usr/local/bin/ghdl-ls', '-v']
2019-07-12 00:39:49,129 [INFO] Current directory is /src/vunit/vunit/examples/vhdl/array_axis_vcs
2019-07-12 00:39:49,131 [INFO] reading project file /src/vunit/vunit/examples/vhdl/array_axis_vcs/hdl-prj.json
2019-07-12 00:39:49,132 [INFO] Using options: ['--std=08', '-Pvunit_out/ghdl/libraries/osvvm', '-Pvunit_out/ghdl/libraries/vunit_lib']
2019-07-12 00:39:49,134 [INFO] loading src/fifo.vhd
2019-07-12 00:39:49,135 [INFO] loading src/axis_buffer.vhd
2019-07-12 00:39:49,137 [INFO] loading src/test/tb_axis_loop.vhd

However, when a workspace which contains the folder is opened, the project file is searched for in the first folder only. Hence, if the file which is being browsed belongs to the first folder, everything works ok. But, when it does correspond to a different folder, the project file is not used.

Example of 'valid' workspace:

{
	"folders": [
		{
			"path": "array_axis_vcs"
		},
		{
			"path": "axi_dma"
		},
	]
}
Args: ['/usr/local/bin/ghdl-ls', '-v']
Current directory: /src/vunit/vunit/examples/vhdl/array_axis_vcs
2019-07-12 00:44:51,539 [INFO] Args: ['/usr/local/bin/ghdl-ls', '-v']
2019-07-12 00:44:51,539 [INFO] Current directory is /src/vunit/vunit/examples/vhdl/array_axis_vcs
2019-07-12 00:44:51,541 [INFO] reading project file /src/vunit/vunit/examples/vhdl/array_axis_vcs/hdl-prj.json
2019-07-12 00:44:51,542 [INFO] Using options: ['--std=08', '-Pvunit_out/ghdl/libraries/osvvm', '-Pvunit_out/ghdl/libraries/vunit_lib']
2019-07-12 00:44:51,543 [INFO] loading src/fifo.vhd
2019-07-12 00:44:51,545 [INFO] loading src/axis_buffer.vhd
2019-07-12 00:44:51,547 [INFO] loading src/test/tb_axis_loop.vhd

Example of 'not valid' workspace:

{
	"folders": [
		{
			"path": "axi_dma"
		},
		{
			"path": "array_axis_vcs"
		},
	]
}
Args: ['/usr/local/bin/ghdl-ls', '-v']
Current directory: /src/vunit/vunit/examples/vhdl/axi_dma
2019-07-12 00:46:15,229 [INFO] Args: ['/usr/local/bin/ghdl-ls', '-v']
2019-07-12 00:46:15,230 [INFO] Current directory is /src/vunit/vunit/examples/vhdl/axi_dma
2019-07-12 00:46:15,230 [INFO] project file /src/vunit/vunit/examples/vhdl/axi_dma/hdl-prj.json does not exist

As explained in code.visualstudio.com/api/references/vscode-api#workspace, vscode.workspace.workspaceFolders provides:

List of workspace folders or undefined when no folder is open. Note that the first entry corresponds to the value of rootPath.

Therefore, I think that this could be fixed by letting ghdl-ls manage multiple projects/folders in parallel, and assuming that a single file will not be mapped to multiple project files. Note that vscode.workspace.getWorkspaceFolder(Uri) can be used to get the folder from the path of a file.

Moreover, it is possible to add settings to the workspace itself, apart form individual settings for each folder. See https://code.visualstudio.com/docs/editor/multi-root-workspaces#_settings. Hence, it should probably be supported to set a --std parameter in the workspace, which is then overriden by some folders, or by the hdl-prj.json files inside them.

@eine
Copy link
Contributor Author

eine commented Aug 5, 2019

LSP Multi Server Example: https://github.com/Microsoft/vscode-extension-samples/tree/master/lsp-multi-server-sample

A language server example that demonstrates how to start a server per workspace folder. If the workspace has nested workspace folders only a server for the outer most workspace folder is started assuming that the language service handles nested code.


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

1 participant