'VSCode "go to definition" not working
I installed Visual Studio Code 1.1 with the C/C++ extension, opened my C++ project and tried to use "Go to definition" in vain.
The "Go to definition" is not working at all. Example, go to definition of a class member:
int i = m_myVar;
(I opened a simpler project with one file and it was working for this one)
In the end, what I want is good indexation of my big project, is there a way to install Intellisense?
Solution 1:[1]
I recently came across this same issue and after trying all of the suggested solutions I could find with no success, I found this article:
Basically my project grew too large and VS code was no longer able to track all files, which messed up the "go to definition" functionality.
After following the steps on the link to increase the maximum number of files to be tracked, the issue was resolved.
The correction is pretty simple (tested on Ubuntu 18.04):
Add this line:
fs.inotify.max_user_watches=524288
to the end of the file /etc/sysctl.conf
After saving, run the following command:
sudo sysctl -p
Hopefully this will be useful to someone else, this has been bothering me for the last few days.
Solution 2:[2]
I had a similar problem except with Python and google searches for solutions kept bringing me back to this post so I figured I'd post my solution here in the hopes that it might help other people.
I was working on a remote cluster through VScode Remote and was getting similar errors to the original question(all 'go to ___' functionality was unavailable and was even getting a 'too large to track' error) and I thought I had to increase the number of watches, which didn't end up helping.
All I needed to do was install a python interpreter on the remote VScode server. This fixed my problem.
Solution 3:[3]
I believe vscode 1.1 (well, 1.1.1 actually) + the C++ extension (cpptools) is as much Intellisense as we can get for now.
You should load your big project with the "open folder" function to make vscode know about the other files.
https://blogs.msdn.microsoft.com/vcblog/2016/03/31/cc-extension-for-visual-studio-code/ warns about letting the indexing finish first (red icon in lower right corner during indexing) and mentions the current limitations on the source code parsing.
Solution 4:[4]
I have been trying to fix this for a long time. In the end, what worked for me was simply reinstalling VSCode, then installing the latest C/C++ extension (v0.18.1). Then, in your .vscode/c_cpp_properties.json
file, under includePath
, add your include folder which has all your header files.
Solution 5:[5]
I tried the methods mentioned in this thread none of them seemed to work for me. A simple solution that worked for me is that I closed the current workspace and created a new workspace, added the folders which I required(same as the old workspace), and saved the new workspace. Waited for a couple of minutes to index and IntelliSense is able to find definitions now.
Solution 6:[6]
It wasn't working on my laptop as well after installing a few VSCode extensions. I decided to close and re-open VSCode with administrator permission and suddenly it sorted out.
Solution 7:[7]
I am using VSCode 1.52.1 on Ubuntu 20.04.
In my case, for whatever reason,c_cpp_properties.json
has become set to Disabled
in ~/.config/Code/User/settings.json
.
Manually changing it to Enabled
solved the problem.
Solution 8:[8]
Just to inform if none of above works then In my case i was using Kite extension in my VS code, I just disabled it and it worked. I think kite extension is blocking this feature.
Solution 9:[9]
If you have multiple versions of a language on your PC, specify the exact language you are using in the VScode(in my case, I am using Python, so I must specify the version to the python Interpreter in VS Code)
If you could not do it whatsoever, then uninstall all the other versions that you don't use and then if you go to VS Code, it will ask the version to be used, and you would have only one version, so when you select the version, the "Go To Definition" will be activated.
Solution 10:[10]
I was having a similar issue with java on Ubuntu 20.04 using OpenJDK version 11 (openjdk-11-jdk
in apt). At first I didn't have the JRE installed, so I installed it and it still didn't work.
Afterwards, I went to the CTRL + SHIFT + P
menu and then to Java: Configure Java Runtime
, there I saw in the Java Tooling Runtime
tab that /usr/lib/jvm/java-11-openjdk-amd64
was selected, changed it to /usr/lib/jvm/java-1.11.0-openjdk-amd64
just to see if it would work, and after a restart it did. I'm not sure why this is, but I hope it may help somone else.
Solution 11:[11]
For python ensure your code analysis settings are correct. In my case the languageServer was accidentally set to 'None'. Reverting it to 'default' or 'pylance' did the trick.
Solution 12:[12]
I had a the same issue: F12 and Ctrl + Click and Right Click "Go To Definition" wasn't working. The fix for me was:
- Go to Extensions
- Click "Disable All Installed Extensions"
- Close and Reopen VS Code
- Back to Extensions and "Enable All Extensions"
Essentially enable/disable all extensions fixed the issue.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow