julia-vim 中的 Julia 语法高亮 [英] Julia syntax highlighting in julia-vim

查看:29
本文介绍了julia-vim 中的 Julia 语法高亮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 gvim 和 julia-vim 来编辑 julia 代码.我在 Mac 上使用 julia 0.5 并使用 vundle 安装了 julia-vim.

我的问题是带有 .jl 扩展名的文件没有适当的突出显示.例如,if 高亮显示,但 for 未高亮显示.有什么解决办法吗?

解决方案

.jl 文件有时被默认识别为 lisp 文件,(怪 Sawfish) 所以这可能是你得到的突出显示的语法.(输入 defunprogn 等,看看是否弹出漂亮的颜色)

当你说正确的解决方案是 :set syntax=julia 时你很接近,你需要设置 filetype 加上一些 autocmd每次打开 .jl 文件时都会使用魔法.

在你的 ftdetect 目录:

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

应该这样做.


<小时>

附录 1:根据问题的根源,可能需要更改 filetype 而不是 syntax 才能触发 LaTeX 扩展等附加功能,所以这就是我正在使用的.

<小时>

附录 2:请注意,这应该由 julia-vim 插件处理,但与其他脚本的冲突可能会造成混乱.您可以使用 :scriptnames 查看已加载的脚本以及加载顺序,并尝试调试可能导致冲突的原因,如果您认为值得麻烦的话.

<小时>

附录 3:另外相关的是 Vundle 在文件类型方面需要进行一些特定的配置,因此这也可能是造成这种情况的原因.但是,我已经看到在 Vundle 之外由于多种原因发生了这种和类似的问题,所以我仍然相信顶部的解决方案是最好的解决方案,并且可能会避免一些未来的麻烦.p>

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 extension do not have appropriate highlighting. For example, if is highlighted but for is not. Any solution for this?

解决方案

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

这篇关于julia-vim 中的 Julia 语法高亮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆