Vim syntax hides in context

I want to hide variables with names based on Greek characters and turn them into their equivalent Unicode character, just as vim-cute-python works, So, for example, I have this

syntax match scalaNiceKeyword "alpha" conceal cchar=α

defined in a file to hide in Scala files, which works fine except that it is overly aggressive. If I write alphabet, it will be hidden in order to become αbet, which is noticeably wrong. How can I change / expand this hidden operator so that it only hides keywords that match "[_] alpha [_]", that is, I want the following conversions

alpha_1 => α_1
alpha => α
alphabet => alphabet

Note. This is similar to this question , but it seems a bit more complicated, since the group environment I want to map to is spaces and underscores. A naive definition of a syntax area, like the following, makes things all kinds of wrong:

syn region scalaGreekGroup start="[ _]" end="[ _]"

Thanks in advance!

+5
source share
2 answers

Modify the template so that it matches only names bounded by word boundaries or underlines:

:syntax match scalaNiceKeyword '\(_\|\<\)\zsalpha\ze\(\>\|_\)' conceal cchar=α
+3
source

script, unilatex.vim, imaps \alpha => α / . , , unicode . , scala unicode, , .

0

All Articles