Anyone know of Objective-J syntax highlighting in vi?
Asked Answered
A

4

10

I have been looking at the new Objective-J / Cappuccino javascript framework from 280North. They provide plug-ins for SubEthaEdit and TextMate to handle syntax highlighting, but I primarily use vi. Does anyone know of a way to get Objective-J syntax highlighting in vi, or a good way to convert whatever format the other two editors use?

Aldaaldan answered 8/9, 2008 at 13:23 Comment(0)
U
7

The Objective-J Tools package (http://cappuccino.org/download) and the source on github now include a vim highlight module.

Unbar answered 15/9, 2008 at 19:3 Comment(0)
M
9

the source on github now include a vim highlight module.

I've found just doing what is suggested here is not enough:

  • download the file as Francisco suggests

  • unzip, cd Tools/ dir

  • run the shell, sh install-tools

  • copy the objj.vim file to vim dir, cp Tools/Editors/objj.vim /usr/share/vim/vim71/syntax/

Problem

I found no syntax highlighting worked for ".j" files. So the problem here is no file extension recognition. If you are using gvim as I am there is also no menu item.

Add Objective-J to gvim menu

To add a menu-item in gvim for Syntax->Ne-MO->Objective J:

  • sudo vim /usr/share/vim/vim71/synmenu.vim

add the following line.

  • an 50.70.465 &Syntax.Me-NO.Objective\ J :cal SetSyn("objj")<CR> below the objective-C entry.

save and quit

  • :wq!

then reload a ".j" file in gvim. If you then go:

  • Syntax->Ne-MO->Objective J

highlighting for your selected Objective-J file should occur.

Objective-J auto-highlighting?

But what about auto-highlighting when you load the file? There appears to be no file associations. So:

  • sudo vim /usr/share/vim/vim7.1/filetype.vim

In the file you will find a list of filetype associations. If you want an idea where to add the line, search for "setf ocaml" in filetype.vim. Add the line below above (alphabetical):

  • "" Objective J au BufNewFile,BufRead *.j setf objj

Save the result. You should now be able to load a file with a ".j" extension and syntax highlighting for Objective-J files works.

Result

Now you should get automatic recognition of the Objective-J files by file type ".j" and a way to set this filetype in gvim. This probably should be added by Bram or whoever does the official release of vim but for the moment this hack works for me. (Ubuntu 8.10, Vim 7.1)

Moitoso answered 5/3, 2009 at 4:18 Comment(1)
If you are using >Vim 7.1/7.2 take a look at Vimballs (vim install scripts - vba) ~ vim.org/scripts/script.php?script_id=1502 & installationwiki.org/Installing_Vim_Scripts#Installing_ScriptsMoitoso
U
7

The Objective-J Tools package (http://cappuccino.org/download) and the source on github now include a vim highlight module.

Unbar answered 15/9, 2008 at 19:3 Comment(0)
S
5

Here is another way to add Objective J highlighting with automatic file detection to (Mac)Vim and it is a lot cleaner and shorter than bootload’s version (it won’t add a menu to MacVim, but I don’t need it at all):

  1. Download the objj.vim file Francisco mentioned.
  2. Place it into ~/.vim/syntax/ (create folder if necessary)
  3. Add the line au BufNewFile,BufRead *.j setf objj to ~/.vim/filetype.vim
  4. Do not forget to turn on filetype detection in your ~/.vimrc configuration file: filetype plugin on
Selfcontradiction answered 12/9, 2010 at 12:49 Comment(0)
H
1

If regular javascript syntax highlighting is good enough, you can map that to .j files by adding something like this to your .vimrc file:

augroup objective-j
au! BufRead,BufNewFile *.j set filetype=objective-j
au! Syntax objective-j source /usr/share/vim/vim71/syntax/javascript.vim
augroup END

I haven't tried this exact code, but did something similar when mapping C# syntax to .vala files on my Linux machine. (NOTE: The javascript.vim file might be located somewhere else on your computer.) You could of course make a objective-j.vim file based on that javascript.vim syntax definition instead of using it as it is.

Hyperpituitarism answered 8/9, 2008 at 14:7 Comment(1)
Or you can change javascript.vim to objj.vim (after you've copied objj.vim to usr/share/vim/vim72/syntax/). Works for me using MacVim.Finedraw

© 2022 - 2024 — McMap. All rights reserved.