0

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

2 Answers 2

2

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.

4

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.


Edit:

Since I won't maintain the above repository anymore, I recommend the following vim syntax plugin: https://github.com/SolaWing/vim-objc-syntax

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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