The C++ code I work with has a lot of typedefs and Goto Definition doesn’t detect them. At all.
Goto Definition not going to typedef
I’m having the same issue. There is no indexing of typedefs in C or C++.
Dear Sublime Text 3 developers, please index all typedefs in C and C++.
Assuming there is some unique identifier on the typedefs you can include them in your symbol list yourself. Take a look at “Symbol List - .tmPreferences” in the C++ package.
skuroda, thanks for the reply. Apparently I have no idea how to get into a package that came with ST3. I see the Cache folder has a copy of the C++ package, but I can’t read the contents of those files which you listed to look for.
It’s pretty clear that the Cache folder with the C++ package does not contain the index file for my particular project.
So, I guess I have two questions:
1 - How do I get into a package that shipped with ST3? It’s showing as a file and not a directory.
2 - Where is the index file when ST3 indexes a project (or anything for that matter)?
I don’t recall where they are off the top of my head. In ST3, plugins/packages are run directly from the “*.sublime-package” files, which are just renamed zips. You can go hunt them down, manually extract them to look at them. Alternatively (and what I recommend) is using the plugin I wrote to help with this.Though I wrote a plugin to help with that (link). This also helps with overriding the contents of packages in ST3, but you don’t really need that. So be sure not to save the files upon closing them (though if they have the same contents I guess it doesn’t really matter).
I’m going to make an assumption that you are familiar with how scopes/syntax highlighting is applied in ST. The symbol list is generated based on some specified scope. For example, the default list includes
entity.name.function, entity.name.type, meta.toc-list
So anything that has the “entity.name.function”, “entity.name.type” or “meta.toc-list” scopes will be included in the symbol list by default. Languages can extend this (as you will see in the C++ package. So you will be doing them same, extending what is included in a similar fashion.
skuroda, again, thanks for the reply. I’m sorry this is turning into a tutorial, but I can’t find this anywhere.
When I look at the C++ default package, I see a good example: “Symbol List Hide Forward Decls.tmPreferences”.
It appears I could copy this and change one line to get typedefs properly indexed.
However, this only brings up rather larger questions. For example, is there a way I can just add a file named “Symbol List Typdefs.tmPreferences” to the C++ package? It doesn’t appear so without replacing the entire package with a new package with the added file. So, creating a new package that is named differently, yet is the exact same as the C++ package with my added file should work. But, if I had two separate packages for C++, how do I chose which one will get used in a C++ project (or file) by default?
Again, sorry for the many questions. Any help would be greatly appreciated.
It doesn’t have to be in the C++ package. In fact, I would put it in your user package. It’s looking for scopes using all of the tmPreferences files, so the location doesn’t matter. I did a little further investigation for you and came to the conclusion this isn’t as simple as I was hoping. There are no scopes applied for the typedef that are useful out of the box. To overcome this limitation, you will need to extend the current C++ tmLanguage file. I’m not an expert at those so I don’t know how much help I will be. With all that being said, here is a quick example of how you can extend the symbol list. Save the following in a tmPreferences file.
[code]<?xml version="1.0" encoding="UTF-8"?>
name Symbol List: Typedef scope source.c++ storage.type.c settings showInSymbolList 1 uuid 7a9f6bf6-f9be-43c2-854a-7bdc84f79ead [/code]I think the trickiest thing moving forward is getting a proper definition set up to identify typedefs in the various forms (think the multi line version used with structs would be the most challenging).
Thanks for all the information. Using all of your information I’ll experiment and see what happens.
Hi,
I had the same issue. Installed this package, sublime.wbond.net/packages/C%20Improved
and now jumping to typedefs work
@wintermelon-- great plugin! Thanks!
Is there anyway to get c/c++ variables indexed as well?