Open xanderdunn opened 9 years ago
Then again, it looks like stable release is 5.8, which is what I have installed, which is from 2009. Wow
Maybe I should try trunk.
Hi Alex,
The README includes Objective-C in the list of languages that should be automatically supported upon installation.
Thanks for pointing out this documentation bug and sorry about the confusion it created. Until fairly recently the vim-easytags plug-in treated Objective-C source code as C source code (it did the same for C++ source code). This was changed in response to issue #91, but I forgot to remove the mention of Objective-C from the readme. I can resolve this issue in one of two ways:
If you can help me with option two that would be great, however if you don't have the time and are looking for a ready made solution I can understand that of course.
If you do try out the latest version of Exuberant Ctags and it turns out to properly generate tags for your Objective-C source code then it won't be difficult to add support for this to vim-easytags. In that case what I would need from you is a sample of Objective-C source code (a link to e.g. an open source project is also fine) and the (type of) tags that you expect to be highlighted by the plug-in. Given that information I can probably make it work with fairly little effort.
Thanks for this!
Yes, option 2 is definitely preferable. I've gotten exuberant ctags trunk installed. I'll test that it works with ObjC files.
I was able to verify that tags were successfully created in the tags
file by executing ctags --langmap=ObjectiveC:.m.h <file>
. Apparently, by default ctags maps the .m filetype to matlab and .h to C++, so I must specify the Objective-C filetype or it will fail to produce any tags. I haven't used exuberant ctags before, but reading through the tags it generated for one of my implementation files, they look correct and useful.
Here is an open source Objective-C project you could test with: https://github.com/magicalpanda/MagicalRecord
Finally, you asked which tags I'd be interested in seeing highlighted.
Executing ctags --list-kinds=all
on trunk gives :
ObjectiveC
i class interface
I class implementation
p Protocol
m Object's method
c Class' method
v Global variable
F Object field
f A function
p A property
t A type alias
s A type structure
e An enumeration
M A preprocessor macro
However, I'm not familiar with which tag types are typically highlighted. It looks like the tags available for Objective-C are fairly similar to those available for C++. What tags are typically highlighted via EasyTags? I can imagine at the very least, highlighting my custom defined classes, methods, functions, global variables, protocols, and type aliases would make sense.
Many thanks!
If I figure out how it works, I'll give a try at adding Objective-C functionality and giving a pull request.
It looks like the relevant code is here. I could probably copy the C++ code:
call xolox#easytags#define_tagkind({
\ 'filetype': 'cpp',
\ 'hlgroup': 'cType',
\ 'tagkinds': '[cgstu]'})
call xolox#easytags#define_tagkind({
\ 'filetype': 'cpp',
\ 'hlgroup': 'cEnum',
\ 'tagkinds': 'e'})
call xolox#easytags#define_tagkind({
\ 'filetype': 'cpp',
\ 'hlgroup': 'cPreProc',
\ 'tagkinds': 'd'})
call xolox#easytags#define_tagkind({
\ 'filetype': 'cpp',
\ 'hlgroup': 'cFunction',
\ 'tagkinds': '[fp]'})
For Objective-C it might look like:
call xolox#easytags#define_tagkind({
\ 'filetype': 'objc',
\ 'hlgroup': 'objcType',
\ 'tagkinds': '[ptIi]'})
call xolox#easytags#define_tagkind({
\ 'filetype': 'objc',
\ 'hlgroup': 'objcEnum',
\ 'tagkinds': 'e'})
call xolox#easytags#define_tagkind({
\ 'filetype': 'objc',
\ 'hlgroup': 'objcPreProc',
\ 'tagkinds': 'M'})
call xolox#easytags#define_tagkind({
\ 'filetype': 'objc',
\ 'hlgroup': 'objcMethod',
\ 'tagkinds': '[mcf]'})
Then, I think these objc hlgroups might need to be linked to existing hlgroups similar to this:
highlight def link cFunction Function
Objective-C is also a superset of C (You can have C functions in the same file that you have Objective-C methods, etc.), so I think that means any of the C tags could be present as well? I should test this.
Hi Alex,
Sorry for not following up on this earlier. It sounds like you're on the right track! I think the only thing missing apart from the code you showed would be a mapping between the names that Vim and Exuberant Ctags use to identify Objective C as a language. For this you can take a look at autoload/xolox/easytags/filetypes.vim
. Basically you would add a line like this to the end of the file:
call xolox#easytags#filetypes#add_mapping('objc', 'ObjectiveC')
Thanks! I'll fork and test all of this.
The README includes Objective-C in the list of languages that should be automatically supported upon installation.
However, I wasn't noticing any changes in my Objective-C .m files, so I tried :UpdateTags and it gave me the error:
It looks like as of 2011/2012 ctags didn't support Objective-C out of the box, but that it had been added to ctags trunk. I'd be very surprised if trunk from 2 years ago hand't made it into stable by now. Maybe there is some further configuration required?
Objective-C is not listed on exuberant ctags supported languages.