Friday, October 2, 2015

How to highlight brackets for functions

I'm trying to define a vim highlighting scheme where the brackets belonging to language functions are highlighted the same as functions, so for example if functions are red then their corresponding brackets will also be red. My idea is this will differentiate them from other round-bracket constructions. (Maybe this is actually a terrible idea, but I wanted to try it out.)

I tried defining a region for a dummy function "TestFun()" like this:

syn region Function matchgroup=Function start=+TestFun\s*(+ end=+)+ contains=ALL

However this doesn't work with my test case:

-- [Test case start]

hi Function gui=bold guifg=Red guibg=NONE

syn region Function matchgroup=Function start=+TestFun\s*(+ end=+)+ contains=ALL

" Dummy function to demo syntax highlighting
function! TestFun()
let x = 1
endfunction!

if 0
TestFun(123)
TestFun(SomethingElse(123))
SomethingElse(123)
endif

-- [Test case end]

Save the above as a .vim file, open it in Vim and :so % to see what I mean. TestFun( gets highlighted, but not its closing bracket.

Can this be done at all using standard Vim without writing a load of code?

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment