Also a bug but exported functions aren't listed neither read from the dependencies' composer.json files
QoL prioritise autocompletion suggestion result list
d8vjork we can assign priorities like that, good idea!
d8vjork what is an exported function? The LS is processing all the .php
files and functions inside the workspace, it actually does not care much about the composer at this point.
JakubMisek I've a package full of them, basically all non-methods (not being part of a class or PHP object)
Here's an example:
https://github.com/open-southeners/laravel-helpers/blob/main/src/Enums/functions.php
I use this package all over my other projects and it seems like it doesn't get functions suggested by their names (I need to manually import them with use function OpenSoutheners\LaravelHelpers\Enums\has_case;
)
Probably for that functions thing will be to raise a different issue (more like a bug not a suggestion) but to include this future suggested item into the prioritisation
d8vjork Thanks, I see; so maybe if the function is from an unimported namespace it won't get listed in code completion.
The LS is processing all the .php files and all the functions ... but it may not list inaccessible functions so the list isn't insanely long.
We have the auto-import feature of inaccessibles enabled only for class names yet.
JakubMisek They're mentioned on the PSR autoloading (the files part) of the composer.json:
https://github.com/open-southeners/laravel-helpers/blob/main/composer.json#L23
Maybe this could help
d8vjork this might help, it makes sense to always list declarations from those files I guess!
- Edited
JakubMisek Yes, weird thing tho is that PHP Tools works great with the helpers.php of Laravel (global functions) which is somewhat similar to this other, only thing is that these functions are behind a namespace and that prevent from redefine any PHP globals
I saw this approach in some other symfony/phpleague packages
- Edited
d8vjork it seems it's because functions in helpers.php
are not namespaced - so they're always accessible (no use
is necessary)
The upcoming 1.27.12115
makes some prioritizing in the code completion list!
- We have fixed and improved how local variables are listed when the user does not type the leading
$
character. - Improved how type names are listed after
use
keyword. - Fixed sorting of classes that are out of the current naming context.
There are many workarounds because VS Code does this sorting primarily by itself and ignores language-server suggestions. So I hope it will work at least better than before!
JakubMisek 🔥 🔥🔥
continuing on https://github.com/DEVSENSE/phptools-docs/issues/252
Thank you @d8vjork for all the ideas! We're on it