简体   繁体   English

在 vim 中使用外部语法高亮

[英]Using an external syntax highlighter in vim

I have access to a syntax highlighting program for an internal-only language.我可以访问仅限内部语言的语法突出显示程序。 Is there any way in which I could get vim to call this program to perform syntax highlighting?有什么方法可以让 vim 调用这个程序来执行语法高亮显示? I figure that it's worth seeing if this is possible before I write my own syntax file, since it's quite complex (not to mention prone to change).我认为在我编写自己的语法文件之前,这是否可能值得一看,因为它非常复杂(更不用说容易更改)。 The program in question could be quite easily customized to output in a new intermediate format (it's only currently outputting HTML), if that would make things easier.有问题的程序可以很容易地定制为以新的中间格式输出(它目前只输出 HTML),如果这会使事情变得更容易的话。

I would suggest to write a quick throwaway script in the language of your choice to convert the output of the program in question to the Vim highlighting syntax. 我建议用您选择的语言编写一个快速的一次性脚本,将有问题的程序的输出转换为Vim突出显示语法。 You mentioned the program is prone to change, but its output format can be easily customized: using your own conversion script (which parses the programs output format) you could easily stay up-to-date with the latest changes (just run your script again). 您提到该程序很容易更改,但其输出格式可以轻松自定义:使用您自己的转换脚本(解析程序输出格式),您可以轻松地保持最新的更新(只需再次运行您的脚本) )。 And as others have mentioned: creating a new syntax file is really easy in Vim, so it's up to the complexity of the programs output how hard this actually is. 正如其他人所提到的:在Vim中创建一个新的语法文件非常简单 ,因此,程序的复杂性决定了它实际上有多难。

Yes, you can use vim job/channels to communicate with external process and highlight text using textprops.是的,您可以使用 vim 作业/通道与外部进程通信并使用 textprops 突出显示文本。

Type :help channel and :help textprop in vim to get more info.在 vim 中输入:help channel:help textprop以获取更多信息。

This method is used to implement treesitter highlighting in vim-treesitter plugin该方法用于在vim-treesitter插件中实现treesitter高亮

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM