Julia syntax highlighting in julia-vim

I found that the instructions here worked a treat. Namely

git clone git://github.com/JuliaEditorSupport/julia-vim.git
mkdir -p ~/.vim
cp -R julia-vim/* ~/.vim

Note: I realise that the OP claims to have already installed Julia-Vim using Vundle, but I came to this question because Vim was automatically using LISP syntax highlighting for me, and the above was enough for me. So I am sharing in case anyone comes from the same boat as me (i.e. the problem is not Vundle related) :)


After testing julia-vim I think the issue is likely with the color scheme you are using.

Try using a different one.

:colorscheme desert

I tried it with the built-in desert and both if and for were highlighted (see below).

enter image description here


.jl files are sometimes recognized as lisp files by default, (blame Sawfish) so that's probably the syntax highlighting you're getting. (type defun and progn and etc and see if the pretty colors pop up)

You were close when you said the correct solution was :set syntax=julia, what you need is to set filetype plus some autocmd magicks to make that happen every time you open a .jl file.

Put something like this in some file (e.g. jl.vim) in your ftdetect directory:

autocmd BufRead,BufNewFile *.jl :set filetype=julia

And that should do it.



Addendum 1: Changing filetype instead of syntax may be required to trigger additional features like the LaTeX expansions depending on the root of your problem, so that's what I am using.


Addendum 2: Note that this should've been handled by the julia-vim plugin, but conflicts with other scripts can mess with that. You can use :scriptnames to see what scripts have been loaded and in what order, and try to debug what could be causing the conflict, if you think that's worth the trouble.


Addendum 3: Also related is that Vundle has some specific configurations that need to be made when it comes to filetypes, so that could also be causing this. However, I've seen this and similar problems happen outside Vundle for any number of reasons so I still believe that the solution at the top is the best one, and will possibly prevent some future headaches.

Tags:

Vim

Julia