clangd / vscode-clangd

Visual Studio Code extension for clangd
https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd
MIT License
629 stars 106 forks source link

Disabling an intellisense for specific folders #185

Open arekzaluski opened 3 years ago

arekzaluski commented 3 years ago

Question: Is it possible to disable C/C++ intellisense for specific folders/files? I do not see that option in either vscode-clangd or clangd.

ChristianKuehnel commented 3 years ago

Hi @arekzaluski ,

to help us discuss the options: What's your use case for this feature?

arekzaluski commented 3 years ago

Thank you for an answer. Use case:

arekzaluski commented 3 years ago

I would personally expect an option for it in https://clangd.llvm.org/config.html. Unfortunately, I do not see any.

kadircet commented 3 years ago

As you've noted in clangd/clangd#342, currently clangd only supports disabling background indexing.

I suppose we can work on an option to ignore certain files, this would be especially useful for files making clang(d) crash-loop (thinking out loud, should we also ignore files depending on an ignored file?).

I'd like to learn more about your problem though, resource usage of clangd is something we care and would like to reduce when possible. Currently there are 3 main components consuming resources in clangd:

That being said, since you are on vscode, can you provide the output for memory usage (i think can be triggered through command palette by searching for clangd Memory Usage). Also verbose logs from one of the problematic sessions would again be helpful. See http://clangd.llvm.org/troubleshooting.html#gathering-logs for details.

arekzaluski commented 1 year ago

@kadircet My use-case is primary about running VSCode and Theia in the cloud. In that case you usually do not have much resources available. Especially RAM. I'm interested in a feature where I can specify for what paths (projects) C/C++ intellisense will be enabled.

For example: I have 5 projects in the workspace:

I expect to have a config option that allows to trigger C/C++ intellisense only for Proj1. After opening any file from Proj2-5 it should not trigger C/C++ intellisense features (background and dynamic indexing, AST). It should behave as if vscode-clangd and clangd is not even enabled.

Without this feature after opening any file from Proj2 it runs intellisense for Proj2 which increases memory used by clangd. Which may lead for example to a crash of container as clangd takes all available memory.

i-ky commented 1 year ago

After opening any file from Proj2-5 it should not trigger C/C++ intellisense features (background and dynamic indexing, AST). It should behave as if vscode-clangd and clangd is not even enabled.

This is a hack, but it does what you want:

If:
  PathMatch: Proj[2-5]
CompileFlags:
  Add:
  - --nonexistent

As a side effect every opened file from Proj2-5 will give you "Unsupported option '--nonexistent'" in Problems, but maybe it's the price you are willing to pay.

arekzaluski commented 1 year ago

Hi @i-ky, I've just tried it. Unfortuantely even with this hack it still runs C/C++ intellisense and clangd. The only difference is that indeed I see now:

Screenshot 2022-11-24 at 12 12 47
RichardLuo0 commented 5 months ago

Any updates on this? It has been two years and still no activity.

jackbullen commented 3 months ago

Any updates on this? It has been two years and still no activity.

I was able to get this behaviour by changing clangdDocumentSelector variable in clangd-context.ts. Could set includePath to **/path[2-5]/** then restart the language server.