MATLAB-extension-for-vscode
MATLAB-extension-for-vscode copied to clipboard
Feature request: Specify custom MATLAB startup function within VS Code
Very nice to see a vscode extension by mathworks!
When using MATLAB, I have multiple addpath statements in my startup.m
for libraries or projects that I use daily. Could you add the possibility to add the .m files located in these paths to the indexed files? This will allow code navigation for files that are not in my current workspace, but that my code is dependent on.
Ideally by running/parsing the startup.m, but otherwise having a configuration with paths to add to the index would work as well.
Thanks!
I believe this should work - code navigation should pick up on files which are not in the VS Code workspace but are on the MATLAB path.
I was able to navigate to a file by adding its directory in the startup.m
script.
Are you seeing otherwise? Can you provide more information about your setup to help reproduce this?
ah indeed, the paths in the default startup.m work, my mistake.
Then my feature request would actually be to set the path to a custom startup file in the vscode configuration, since I work on a system with multiple users and I always start my session with running the command startup_myname
. This would not pollute the matlab session of other users with my paths.
Thanks for the suggestion! I'll update the issue name to better reflect this. Feel free to modify it if it does not capture quite what you are requesting.
@dklilley I'm not sure if I should create a new issue or not. I am trying to get the vscode extension to find some package folder on a different path.
ProjectRoot below is a Git repo and I am working on a file inside ToolDir. I would like vscode to find packfile.m when using go to definition in myfile.m
For Example
I have tried using vscode workspaces and adding both Packages and ToolDir in the code.workspace file. This however doesn't work. The only way I can vscode to recognize the Package folder is to add it to startup.m
For me this could be problematic if I wanted to work in a duplicate repo as I explore different changes.
Are there any other options? Am I missing something.
If startup.m is the only option today. Could the extension leverage the code.workspace file to help find dependencies?
Thanks Eric
Hi @eric-dishman-ctct,
In the latest version of the extension (v1.2.0), we have added execution support. As part of this, folders now have a "MATLAB: Add Folder To Path" option in the context menu. I believe you should be able to use this to add your "Packages" directory to the MATLAB path, which will enable navigation to the expected file.
If this does not work for you, please feel free to create a new issue for this.
@dklilley Thanks for responding. I just downloaded the latest extension. This is AMAZING! I can't wait to see what you guys have in store for the future. The latest update solves my problem!
Having access to the headless MATLAB makes a HUGE difference in what is possible now.