neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

man.vim (2342B)


      1 " Maintainer:          Anmol Sethi <hi@nhooyr.io>
      2 " Previous Maintainer: SungHyun Nam <goweol@gmail.com>
      3 
      4 if exists('b:current_syntax')
      5  finish
      6 endif
      7 
      8 syntax case  ignore
      9 syntax match manReference      display '[^()[:space:]]\+(\%([0-9][a-z]*\|[nlpox]\))'
     10 syntax match manSectionHeading display '^\S.*$'
     11 syntax match manHeader         display '^\%1l.*$'
     12 syntax match manSubHeading     display '^ \{3\}\S.*$'
     13 syntax match manOptionDesc     display '^\s\+\(\%(+\|-\)\S\+,\s\+\)*\%(+\|-\)\S\+'
     14 
     15 highlight default link manHeader         Title
     16 highlight default link manSectionHeading Statement
     17 highlight default link manOptionDesc     Constant
     18 highlight default link manReference      PreProc
     19 highlight default link manSubHeading     Function
     20 
     21 highlight default manUnderline cterm=underline gui=underline
     22 highlight default manBold      cterm=bold      gui=bold
     23 highlight default manItalic    cterm=italic    gui=italic
     24 
     25 if &filetype != 'man'
     26  " May have been included by some other filetype.
     27  finish
     28 endif
     29 
     30 if get(b:, 'man_sect', '') =~# '^[023]'
     31  syntax case match
     32  syntax include @c $VIMRUNTIME/syntax/c.vim
     33  syntax match manCFuncDefinition display '\<\h\w*\>\ze\(\s\|\n\)*(' contained
     34  syntax match manLowerSentence /\n\s\{7}\l.\+[()]\=\%(\:\|.\|-\)[()]\=[{};]\@<!\n$/ display keepend contained contains=manReference
     35  syntax region manSentence start=/^\s\{7}\%(\u\|\*\)[^{}=]*/ end=/\n$/ end=/\ze\n\s\{3,7}#/ keepend contained contains=manReference
     36  syntax region manSynopsis start='^\%(
     37        \SYNOPSIS\|
     38        \SYNTAX\|
     39        \SINTASSI\|
     40        \SKŁADNIA\|
     41        \СИНТАКСИС\|
     42        \書式\)$' end='^\%(\S.*\)\=\S$' keepend contains=manLowerSentence,manSentence,manSectionHeading,@c,manCFuncDefinition
     43  highlight default link manCFuncDefinition Function
     44 
     45  syntax region manExample start='^EXAMPLES\=$' end='^\%(\S.*\)\=\S$' keepend contains=manLowerSentence,manSentence,manSectionHeading,manSubHeading,@c,manCFuncDefinition
     46 
     47  " XXX: groupthere doesn't seem to work
     48  syntax sync minlines=500
     49  "syntax sync match manSyncExample groupthere manExample '^EXAMPLES\=$'
     50  "syntax sync match manSyncExample groupthere NONE '^\%(EXAMPLES\=\)\@!\%(\S.*\)\=\S$'
     51 endif
     52 
     53 " Prevent everything else from matching the last line
     54 execute 'syntax match manFooter display "^\%'.line('$').'l.*$"'
     55 
     56 let b:current_syntax = 'man'