summaryrefslogtreecommitdiffstats
path: root/runtime/import/dist/vimhelp.vim
blob: e0afd1f97d5226ec11a5a042fbb2d68247e3c54f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
vim9script

# Extra functionality for displaying Vim help .

# Called when editing the doc/syntax.txt file
export def HighlightGroups()
  var buf: number = bufnr('%')
  var lnum: number = search('\*highlight-groups\*', 'cn')
  while getline(lnum) !~ '===' && lnum < line('$')
    var word: string = getline(lnum)->matchstr('^\w\+\ze\s')
    if word->hlexists()
      var name = 'help-hl-' .. word
      if prop_type_list({bufnr: buf})->match(name) == -1
	prop_type_add('help-hl-' .. word, {
	  bufnr: buf,
	  highlight: word,
	  combine: false,
	  })
      else
	# was called before, delete existing properties
	prop_remove({type: name, bufnr: buf})
      endif
      prop_add(lnum, 1, {length: word->strlen(), type: 'help-hl-' .. word})
    endif
    ++lnum
  endwhile
enddef