-
Notifications
You must be signed in to change notification settings - Fork 185
Excluding files from indexing #159
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
Comments
I would particularly like the ability to exclude certain directories from the Problems list (e.g. |
#164 |
Really need this feature hope it comes soon. to make the searching much quicker. |
@ryanbowden feel free to do a PR |
The main use case is to ignore the cache files. |
After seeing the code, the Indexer have to get the excluded path from options and give it to the FileFinder as second parameter. The FileFinder exclude files matching the given Globs. I think it's the simplest way to do it as trying to compile a glob pattern using the main pattern (which will be dynamically generated due to another feature request) and the excluding patterns seems complicated. I need to make a development environment and try to submit a PR! When I got free time... |
from #381: {
"php.excludeFiles": {
"**/node_modules": true"
}
} |
As soon as the large pr has been merged, I planned to do this, but there are some things that need to be implemented first. (For example the client needs to send the settings to the server.) |
For those who do not want to wait for an update and do not mind making a "in the hand" follows a simple and homely solution:
keep in mind: this solution I did in a few hours of this idle Saturday just because I found it fun, so I have no intention of providing a definitive or perfect solution but for the cases where I need it it worked perfectly I hope someone can enjoy it. |
@AeonDigital I appreciate the time you spent on writing this together, but why not invest that time into a PR? |
@felixfbecker Hello. sorry but I do not think it would be good for the project to make a PR of something that was not sufficiently tested. I confess that I know that the way I have resolved the issue is not the best. I just decided to publish the way in which I resolved something that was bothering me and I considered that other people could take advantage of it at their own risk. |
@felixfbecker Want me to take this code and try and get a pull request sorted? I can have a go tonight. Something I really need because otherwise, the CPU maxes out. |
Sure. Here's what it'd have to do:
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I am editing code over a network share and it seems like this LSP is crashing because there's a protected folder it shouldn't index.
|
Hi, |
I would like to know if it's possible as well. |
Same here!Hello, Thanks for the efforts to exclude files & folders from being indexed by the PHP Language Server. I'm using Intelephense so I wouldn't like overlapping features and their performances issues. I'd like to know how to exclude some cache or log files. Having read this issue, its duplicates and scrolled the related preferences settings I still could not figure it out. On a Symfony project, thousands of cache files are unnecessarily indexed, eventhough the "PHP › Validate: Enable" (php.validate.enable) or "PHP › Suggest: Basic" (php.suggest.basic) setting are unset. Folders have been globally excluded this way as well but that doesn't work:
I could not find some documentation either. Regards EDIT: After Felix's answer "No, that's why this issue is open", I would like to say good luck to the devs. |
I can't find the proper settings to exclude folders. Is this implemented yet? |
No, that's why this issue is open. |
@AeonDigital you instructions for the |
You can still modify the Indexer.php file to change the pattern used. The function to change is named public function index(): Promise
{
return coroutine(function () {
// Old code using the rootPath
//$pattern = Path::makeAbsolute('**/*.php', $this->rootPath);
// My new pattern
$pattern = Path::makeAbsolute('**/*.php', 'C:/Users/[USER]/Projects/sources/app/code');
$uris = yield $this->filesFinder->find($pattern);
// ... Restart VS Code after saving the changes and it will only index the needed path. |
This works, the only fix is to change the quoted line to:
two "//" instead of "///", works for me on vscodium 1.36.1 |
I've created some pull requests that might be solution for this (#749, felixfbecker/vscode-php-intellisense#437). I'm usinig language server initialization options for passing excludes derived from VSCode's workspace settings (files.exclude). The proper way I guess would be to synchronize configurations, but this is the easiest. User currently just has to remember to reload (restart language server) when the setting (files.exclude) is changed. |
Hey, gals and guys. I wanted to share a workaround I'm using that it maybe can help someone reading. Since I'm using Docker to run all my projects, and ONLY Docker, if I call If I want to update a dependency file (which should never happen) or I want to delete the So... If you set chmod 600 (not recursive) to This is different from using I went from 53.000+ files scanned along 8 projects with one of my CPU processors at 99% during 15/20 minutes, to 1560 files that actually belong to my applications.
Regards. |
The indexer is created in the LanguageServer::initialize method, but is not assigned to the language server, nor the Server\Workspace |
Thanks @pabloGillariCes |
@pabloGillariCes Thanks this worked for me - I had this error when accessing a repo stored on a mounted drive on MacOS. It was breaking on the system .Trashes folder. |
@pabloGillariCes that means if someone is developing an extension using the following settings in the
It wont scan those files, which is not someone would want as the composer extension development is more easier and time saving this way, where he/she can create a symlink to the folder where the files actually reside and the symlink is under the |
Hello guys. Only #159 (comment) helped, but it's not a good idea for me to edit vendor files. |
Its sad to see this is still open. I quickly hacked together a solution by editing vendor -> Indexer.php directly. I know its a bad solution. $uris = array_values(array_filter($uris, function( $v, $k ) {
return strpos($v, 'var/cache') === false;
}, ARRAY_FILTER_USE_BOTH));
$ignoredCount = $count - count($uris);
$count = count($uris);
$this->client->window->logMessage(MessageType::INFO, "$ignoredCount files ignored"); Before: It is symfony project, with very little actual code, the difference is mainly in time bcz the cache files are very big and and many of them fails due to big size, so either way they don't contribute much to memory, but initial scan takes very long time. 32 v 3 sec is a huge win. I've read the comments above, I'm opting for a separate php language server ignore files option, as I think using .gitignore or other settings would not be the perfect use case here. I'll try to make a PR, but no promises. |
I ended up moving to Intellephense, it indexes a lot better https://marketplace.visualstudio.com/items?itemName=bmewburn.vscode-intelephense-client |
Based on
diff --git a/src/Indexer.php b/src/Indexer.php
index 7ebff3f..ca30170 100644
--- a/src/Indexer.php
+++ b/src/Indexer.php
@@ -204,6 +204,15 @@ class Indexer
{
return coroutine(function () use ($files) {
foreach ($files as $i => $uri) {
+ // Skip paths
+ foreach ([
+ '/var/cache/',
+ ] as $skipPath) {
+ if (false !== strpos($uri, $skipPath)) {
+ continue 2;
+ }
+ }
+
// Skip open documents
if ($this->documentLoader->isOpen($uri)) {
continue; |
My solution is with REGEX: // ...
// Skip paths
foreach ([
'/\.history/',
'/\.git/',
'/\.vscode/',
'/\.data/',
] as $skipPath) {
if (!preg_match($skipPath, $uri)) {
continue 2;
}
}
// ... I'm working in a PR, using VSCode settings. |
For example, node_modules
The text was updated successfully, but these errors were encountered: