vim/parts/gen_conceal.awk

48 lines
1.1 KiB
Awk
Raw Normal View History

2023-10-14 08:14:24 -07:00
#!/usr/bin/awk -f
# set conceallevel=0 " Nothing is hidden
# set conceallevel=1 " Hide stuff as concealchar, or as listchar.
# set conceallevel=2 " Hide stuff as concealchar, or completely.
# set conceallevel=3 " Hide completely.
#
# syntax keyword ConcealedX kw_hide_x conceal concealchar=x
# syntax keyword ConcealedY kw_hide_y conceal concealchar=y
# syntax keyword ConcealedMe kw_hide_me conceal
# syntax keyword NoConceal kw_normal
#
# highlight ConcealedX ctermfg=2
# highlight ConcealedY ctermfg=3
# highlight ConcealedMe ctermfg=4
# highlight NoConceal ctermfg=5
BEGIN {
print "\" Conceal character file generated by awk."
print "\" Do not edit this manually."
print
# Conceal settings
print ":set conceallevel=2"
print "highlight Conceal ctermbg=NONE ctermfg=green guibg=NONE guifg=NONE"
print
}
{
# Ignore all whitespace
gsub("\\s", "", $0)
# Skip comments
if (substr($0,0,1) == "#") { next }
# Skip blank lines
if (NF <= 0) { next }
# Extract args
p = index($0, "|")
conceal = substr($0,0,p-1)
string = substr($0,p+1)
# Vim config output
print ":syntax match keyword \"\\<" string "\\>\" conceal cchar=" conceal
}