PerlNavigator icon indicating copy to clipboard operation
PerlNavigator copied to clipboard

Automatically detect additional workspace

Open rabbiveesh opened this issue 2 years ago • 4 comments

I have a monorepo setup, where I have some code in the root of my repo, and other code in subdirectories.

RIght now, perlnavigator is only picking up that the root of my repo is the workspaceFolder, but not in my subdirectories. The subdir is just like any other standard perl dir, with lib/, t/, bin/ and the like. It even has a dist.ini.

Is there a way to automatically get perlnavigator to pick this up?

rabbiveesh avatar Dec 16 '22 10:12 rabbiveesh

Yes, this should work. The Navigator is not very workspace centric, but rather path centric. I suspect you just need lib on the path.

Something like "perlnavigator.includePaths": [ "$workspaceFolder/mySubFolder/lib" ] should work.

In general, most of the path resolution is done by perl itself using perl -c, so as long as individual perl files can find their dependencies via -I include paths, most of the features should work. Let me know if something doesn't work as expected with this setup.

bscan avatar Dec 16 '22 14:12 bscan

Well, that's what I'm doing now. So the workspace thing itself isn't quite supported, then.

On Fri, Dec 16, 2022 at 4:18 PM bscan @.***> wrote:

Yes, this should work. The Navigator is not very workspace centric, but rather path centric. I suspect you just need lib on the path.

Something like "perlnavigator.includePaths": [ "$workspaceFolder/mySubFolder/lib" ] should work.

In general, most of the path resolution is done by perl itself using perl -c, so as long as individual perl files can find their dependencies via -I include paths, most of the features should work. Let me know if something doesn't work as expected with this setup.

— Reply to this email directly, view it on GitHub https://github.com/bscan/PerlNavigator/issues/55#issuecomment-1354924805, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFURPKX5XVOFOMK7S626XFLWNR25BANCNFSM6AAAAAATAYKLQ4 . You are receiving this because you authored the thread.Message ID: @.***>

rabbiveesh avatar Dec 17 '22 16:12 rabbiveesh

Correct, the Navigator really isn't workspace oriented, it's oriented around single files. As long as each file does a use on any dependency it needs, perl resolves all the files it needs and the Navigator is able to work well. Is there anything workspace-specific that the Navigator isn't currently finding? I suppose the use module autocompletion will be missing things from subdirectories.

One thing that could help is automatically finding the root paths and adding them to the include path. For example, if I open lib/Bar/Baz.pm which has package Bar::Baz at the top, and it tries to use Bar::Qux, it's pretty clear that the user needs to include that base lib directory to get this to work. Adding it automatically would be a nice convenience feature. This would help for subdirectories in monorepos, and for users who simply open files without any workspace at all. However, this wouldn't work for any other files outside of that lib directory. For example, with two different projects as subdirectories with lib folders, one project would not be able to import from the other.

bscan avatar Dec 17 '22 17:12 bscan

Just curating tickets here and tagging this as "good first issue". Updating getAdjustedPerlCode in diagnostics.ts would be a nice feature. Essentially, it should detect packages and automatically add the base path from that package.

bscan avatar Jul 10 '23 20:07 bscan