blob: d053f63041db249f0b18f59bb81b1b3dd83f2981 [file] [log] [blame]
Bram Moolenaarb3c90772022-05-06 16:32:46 +01001vim9script
2
3# Extra functionality for displaying Vim help .
4
5# Called when editing the doc/syntax.txt file
6export def HighlightGroups()
Bram Moolenaar6ba83ba2022-06-12 22:15:57 +01007 var save_cursor = getcurpos()
Bram Moolenaarb3c90772022-05-06 16:32:46 +01008 var buf: number = bufnr('%')
Bram Moolenaar6ba83ba2022-06-12 22:15:57 +01009
10 var start: number = search('\*highlight-groups\*', 'c')
11 var end: number = search('^======')
12 for lnum in range(start, end)
13 var word: string = getline(lnum)->matchstr('^\w\+\ze\t')
Bram Moolenaarb3c90772022-05-06 16:32:46 +010014 if word->hlexists()
Bram Moolenaar6ba83ba2022-06-12 22:15:57 +010015 var type = 'help-hl-' .. word
16 if prop_type_list({bufnr: buf})->index(type) != -1
Bram Moolenaarde216732022-05-12 17:24:49 +010017 # was called before, delete existing properties
Bram Moolenaar6ba83ba2022-06-12 22:15:57 +010018 prop_remove({type: type, bufnr: buf})
19 prop_type_delete(type, {bufnr: buf})
Bram Moolenaarde216732022-05-12 17:24:49 +010020 endif
Bram Moolenaar6ba83ba2022-06-12 22:15:57 +010021 prop_type_add(type, {
22 bufnr: buf,
23 highlight: word,
24 combine: false,
25 })
26 prop_add(lnum, 1, {length: word->strlen(), type: type})
Bram Moolenaarb3c90772022-05-06 16:32:46 +010027 endif
Bram Moolenaar6ba83ba2022-06-12 22:15:57 +010028 endfor
29
30 setpos('.', save_cursor)
Bram Moolenaarb3c90772022-05-06 16:32:46 +010031enddef