Julia syntax highlighting in julia-vim

前端 未结 3 1574
一生所求
一生所求 2021-02-19 16:01

I use gvim with julia-vim for editing julia code. I am using julia 0.5 on a mac and installed julia-vim with vundle.

My problem is that files with the .jl

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-19 16:32

    .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.

提交回复
热议问题