Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I would like to have an excellent syntax highliter for obj-c that matches or beats the one in my xcode..

I've installed base16 through yadr, and i've also installed cocoa.vim to have better syntax highlighting.. but installing the latter didn't change much and this is what I have:

enter image description here

contrast that with the zenburn for xcode color highlighting on the same file:

enter image description here

apart from the difference in colors (which is a personal preference thing and is not what i'm asking about).. i noticed that the zenburn for xcode recognized a lot more stuff than the vim one.. how can i address that in vim? I really wanna do all my development on vim going forward.

p.s. i'm not sure if cocoa.vim above does the same job as what this repo does for javascript for example.. you can get a visual for that difference here

share|improve this question

2 Answers 2

up vote 1 down vote accepted

You will probably need to do rather large edits in these two files:

https://github.com/msanders/cocoa.vim/blob/master/after/syntax/objc_enhanced.vim
https://github.com/msanders/cocoa.vim/blob/master/after/syntax/cocoa_keywords.vim

to match XCode's syntax highlighting. That's a non-trivial task that you can't really expect anybody here to do for you. The facts that a) those files are 4 years old and b) their author has completely ceased to support his Vim stuff don't make it any simpler.

I'm not aware of a single comprehensive online tutorial on writing your own syntax script so you won't be able to escape reading :help syntax from top to bottom and back and taking a look at other syntax scripts in $VIMRUNTIME/syntax/.

FWIW, the highlight groups defined by cocoa.vim are all linked to these seven standard highlight groups (I've added their hex value taken from your colorscheme):

Keyword    #b48ead
Special    #96b5b4
Type       #d08770
Constant   #d08770
Error      no value
String     #a3be8c
Identifier #bf616a

You'll notice that, in base16, Type and Constant have the same colors which may not be a good thing. From your XCode screenshot, it doesn't seem that it uses more colors than base16 so adding a couple of syntax groups might be enough.

share|improve this answer

I've installed base16 through yadr, and i've also installed cocoa.vim to have better syntax highlighting.. but installing the latter didn't change much and this is what I have:

That is because cocoa.vim has not been maintained for years and the syntax file doesn't fit with the latest Vim.

I just fixed it in my fork: https://github.com/kentaroi/cocoa.vim

I don't have any intention to promote my fork. But, in view of the current official cocoa.vim ( https://github.com/msanders/cocoa.vim )'s situation, I put a link of my fork for your convenience.

share|improve this answer
    
Please be careful promoting your own content. This isn't spam, but please disclose your affiliation. (+1 for useful answer, though.) –  DragonLord Nov 16 at 6:41
    
Thank you for advising me! I edited my answer. Is it OK now? –  Kentaro Imai Nov 16 at 8:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.