VIM中的颜色突出显示功能调用

问题描述 投票:1回答:1

有人知道在Vim中为突出显示功能调用着色的方法吗?

[我知道有些插件可以通过记录标记来完成类似的工作,但是根据我在网上找到的内容,我不知道如何使它工作。

[我尝试过使用easy tags(顺便说一句,似乎不再维护了)和gutentags,但老实说,我还差得很远就无法使用它们了。工作。

另一方面,我想实现一个脚本来突出显示点和左括号之间或空白与左括号之间的内容将非常简单(如.anyCodeAtAll()anotherCode()) ,但我不知道该怎么做。当然,这将是一个不完整的解决方案,但就我目前的目的而言,已经足够了。

有人知道怎么做吗?

vim syntax-highlighting vim-plugin vim-syntax-highlighting
1个回答
0
投票

我的配置中有类似的内容,但这是特定于语言的。例如对于Golang,我有一个~/.vim/after/go.vim,其中包含:

syntax match goCustomParen     "(" contains=cParen
syntax match goCustomFuncDef   "func\s\+\w\+\s*(" contains=goDeclaration,goCustomParen
" Exclude import as function name, for multi-line imports
syntax match goCustomFunc      "import\s\+(\|\(\w\+\s*\)(" contains=goCustomParen,goImport
syntax match goCustomScope     "\."
syntax match goCustomAttribute "\.\w\+" contains=goCustomScope
syntax match goCustomMethod    "\.\w\+\s*(" contains=goCustomScope,goCustomParen

highlight def link goCustomMethod Function
highlight def link goCustomAttribute Identifier

highlight goCustomFuncDef ctermfg=13
highlight goCustomFunc ctermfg=43
highlight goCustomAttribute ctermfg=247
highlight goCustomMethod ctermfg=33

对于Python,我有一个!/.vim/after/python.vim

syntax match pyCustomParen     "(" contains=cParen
syntax match pyCustomFunc      "\w\+\s*(" contains=pyCustomParen
syntax match pyCustomScope     "\."
syntax match pyCustomAttribute "\.\w\+" contains=pyCustomScope
syntax match pyCustomMethod    "\.\w\+\s*(" contains=pyCustomScope,pyCustomParen

highlight def link pyCustomFunc  Function
highlight def link pyCustomMethod Function
highlight def link pyCustomAttribute Identifier

highlight pyCustomFunc ctermfg=43
highlight pyCustomAttribute ctermfg=247
highlight pyCustomMethod ctermfg=33

[在每种情况下,第一个块定义什么是函数,方法,属性等,第二个块将这些自定义定义链接到通用类“ Function,Identifier ...”,第三个块定义颜色。

文件必须位于after目录中,才能在颜色方案和突出显示定义之后执行。

这里是使用和不使用这些设置的并排比较(请看最后三行):

enter image description here

除非有人有更好的解决方案,否则您可以根据需要的语言来修改上面的内容。

© www.soinside.com 2019 - 2024. All rights reserved.