From 14d653b421d3ee4e0d641e45e67dafe43809e502 Mon Sep 17 00:00:00 2001 From: Joshua Cao Date: Mon, 16 May 2022 04:49:44 -0700 Subject: [PATCH] feat(man.vim): list command flags in "gO" outline #17558 --- runtime/autoload/man.vim | 6 ++++++ runtime/syntax/man.vim | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/runtime/autoload/man.vim b/runtime/autoload/man.vim index 065ca8432e..b8a73a64c9 100644 --- a/runtime/autoload/man.vim +++ b/runtime/autoload/man.vim @@ -171,6 +171,12 @@ function! man#show_toc() abort while lnum && lnum < last_line let text = getline(lnum) if text =~# '^\%( \{3\}\)\=\S.*$' + " if text is a section title + call add(toc, {'bufnr': bufnr('%'), 'lnum': lnum, 'text': text}) + elseif text =~# '^\s\+\%(+\|-\)\S\+' + " if text is a flag title. we strip whitespaces and prepend two + " spaces to have a consistent format in the loclist. + let text = ' ' .. substitute(text, '^\s*\(.\{-}\)\s*$', '\1', '') call add(toc, {'bufnr': bufnr('%'), 'lnum': lnum, 'text': text}) endif let lnum = nextnonblank(lnum + 1) diff --git a/runtime/syntax/man.vim b/runtime/syntax/man.vim index 55b0e16de9..89162f1e20 100644 --- a/runtime/syntax/man.vim +++ b/runtime/syntax/man.vim @@ -10,7 +10,7 @@ syntax match manReference display '[^()[:space:]]\+(\%([0-9][a-z]*\|[nlpox] syntax match manSectionHeading display '^\S.*$' syntax match manHeader display '^\%1l.*$' syntax match manSubHeading display '^ \{3\}\S.*$' -syntax match manOptionDesc display '^\s\+\%(+\|-\)\S\+' +syntax match manOptionDesc display '^\s\+\(\%(+\|-\)\S\+,\s\+\)*\%(+\|-\)\S\+' highlight default link manHeader Title highlight default link manSectionHeading Statement