neovim/runtime/syntax/man.vim

61 lines
2.3 KiB
VimL
Raw Normal View History

" Maintainer: Anmol Sethi <hi@nhooyr.io>
man.vim: rewrite - Smart autocomplete. It's automatically sorted, filtered for duplicates and even formats the candidates based on what is needed. For example, `:Man 1 printf<TAB>` will show the pages that are in section 1m as 'page(sect)' to let you know they are in a more specific section. - Instead of trying to unset $MANPAGER we use the -P flag to set the pager to cat - Always use the section arg '-s', it makes the code much simpler (see comment in s:man-args). - A manpage name starting with '-' is invalid. It's fine for sections because of the use of '-s'. - The tagstack is an actual stack now, makes it much simpler. - By using v:count and v:count1, the plugin can explicitly check whether the user set a count, instead of relying on a default value (0) that is actually a real manpage section. - Extraction of a manpage reference is much more simple. No giant long complicated regexes. Now, the plugin lets `man` handle the actual validation. We merely extract the section and page. Syntax regexes are a bit more specific though to prevent highlighting everything. - Multilingual support in the syntax file. Removed the cruft that was only relevent to vim. Also simplified and improved many of the regexes. - Using shellescape when sending the page and sect as arguments - In general, the code flow is much more obvious. - man#get_page has been split up into smaller functions with explicit responsibilties - ':help' behavior in opening splits and manpages - Comments explaining anything that needs explaining and isn't immediately obvious. - If a manpage has already been loaded but if it were to reloaded at the current width which is the same as the width at which it was loaded at previously, it is not reloaded. - Use substitute to remove the backspaced instead of `col -b`, as the latter doesn't work with other languages. - Open paths to manpages - It uses cWORD instead of cword to get the manpage under the cursor, this helps with files that do not have (,) in iskeyword. It also means the plugin does not set iskeyword locally anymore. - <Plug>(Man) mapping for easy remapping - Switched to single quotes wherever possible. - Updated docs in $VIMRUNTIME/doc/filetype.txt (still need to update user-manual) - Always call tolower on section name. See comment in s:extract_page_and_sect_fpage - Formatting/consistency cleanup - Automatically map q to ':q<CR>' when invoked as $MANPAGER - It also fully supports being used as $MANPAGER. Setting the name and stuff automatically. - Split up the setlocals into multiple lines for easier readability - Better detection of errors by redirecting stderr to /dev/null. If an error occured, stdout will be empty. - Functions return [sect, page] not [page, sect]. Makes more sense with how man takes the arguments as sect and then page. - Pretty prints errors on a single line. - If no section is given, automatically finds the correct section for the buffer name. It also gets the correct page. See the comment in s:get_page - If $MANWIDTH is not set, do not assign directly to $MANWIDTH because then $MANWIDTH will always stay set to the same value as we only use winwidth(0) when the global $MANWIDTH is empty. Instead we set it locally for the command. - Maintainer notes on all files.
2016-03-14 02:05:28 -07:00
" Previous Maintainer: SungHyun Nam <goweol@gmail.com>
man.vim: rewrite - Smart autocomplete. It's automatically sorted, filtered for duplicates and even formats the candidates based on what is needed. For example, `:Man 1 printf<TAB>` will show the pages that are in section 1m as 'page(sect)' to let you know they are in a more specific section. - Instead of trying to unset $MANPAGER we use the -P flag to set the pager to cat - Always use the section arg '-s', it makes the code much simpler (see comment in s:man-args). - A manpage name starting with '-' is invalid. It's fine for sections because of the use of '-s'. - The tagstack is an actual stack now, makes it much simpler. - By using v:count and v:count1, the plugin can explicitly check whether the user set a count, instead of relying on a default value (0) that is actually a real manpage section. - Extraction of a manpage reference is much more simple. No giant long complicated regexes. Now, the plugin lets `man` handle the actual validation. We merely extract the section and page. Syntax regexes are a bit more specific though to prevent highlighting everything. - Multilingual support in the syntax file. Removed the cruft that was only relevent to vim. Also simplified and improved many of the regexes. - Using shellescape when sending the page and sect as arguments - In general, the code flow is much more obvious. - man#get_page has been split up into smaller functions with explicit responsibilties - ':help' behavior in opening splits and manpages - Comments explaining anything that needs explaining and isn't immediately obvious. - If a manpage has already been loaded but if it were to reloaded at the current width which is the same as the width at which it was loaded at previously, it is not reloaded. - Use substitute to remove the backspaced instead of `col -b`, as the latter doesn't work with other languages. - Open paths to manpages - It uses cWORD instead of cword to get the manpage under the cursor, this helps with files that do not have (,) in iskeyword. It also means the plugin does not set iskeyword locally anymore. - <Plug>(Man) mapping for easy remapping - Switched to single quotes wherever possible. - Updated docs in $VIMRUNTIME/doc/filetype.txt (still need to update user-manual) - Always call tolower on section name. See comment in s:extract_page_and_sect_fpage - Formatting/consistency cleanup - Automatically map q to ':q<CR>' when invoked as $MANPAGER - It also fully supports being used as $MANPAGER. Setting the name and stuff automatically. - Split up the setlocals into multiple lines for easier readability - Better detection of errors by redirecting stderr to /dev/null. If an error occured, stdout will be empty. - Functions return [sect, page] not [page, sect]. Makes more sense with how man takes the arguments as sect and then page. - Pretty prints errors on a single line. - If no section is given, automatically finds the correct section for the buffer name. It also gets the correct page. See the comment in s:get_page - If $MANWIDTH is not set, do not assign directly to $MANWIDTH because then $MANWIDTH will always stay set to the same value as we only use winwidth(0) when the global $MANWIDTH is empty. Instead we set it locally for the command. - Maintainer notes on all files.
2016-03-14 02:05:28 -07:00
if exists('b:current_syntax')
finish
endif
man.vim: rewrite - Smart autocomplete. It's automatically sorted, filtered for duplicates and even formats the candidates based on what is needed. For example, `:Man 1 printf<TAB>` will show the pages that are in section 1m as 'page(sect)' to let you know they are in a more specific section. - Instead of trying to unset $MANPAGER we use the -P flag to set the pager to cat - Always use the section arg '-s', it makes the code much simpler (see comment in s:man-args). - A manpage name starting with '-' is invalid. It's fine for sections because of the use of '-s'. - The tagstack is an actual stack now, makes it much simpler. - By using v:count and v:count1, the plugin can explicitly check whether the user set a count, instead of relying on a default value (0) that is actually a real manpage section. - Extraction of a manpage reference is much more simple. No giant long complicated regexes. Now, the plugin lets `man` handle the actual validation. We merely extract the section and page. Syntax regexes are a bit more specific though to prevent highlighting everything. - Multilingual support in the syntax file. Removed the cruft that was only relevent to vim. Also simplified and improved many of the regexes. - Using shellescape when sending the page and sect as arguments - In general, the code flow is much more obvious. - man#get_page has been split up into smaller functions with explicit responsibilties - ':help' behavior in opening splits and manpages - Comments explaining anything that needs explaining and isn't immediately obvious. - If a manpage has already been loaded but if it were to reloaded at the current width which is the same as the width at which it was loaded at previously, it is not reloaded. - Use substitute to remove the backspaced instead of `col -b`, as the latter doesn't work with other languages. - Open paths to manpages - It uses cWORD instead of cword to get the manpage under the cursor, this helps with files that do not have (,) in iskeyword. It also means the plugin does not set iskeyword locally anymore. - <Plug>(Man) mapping for easy remapping - Switched to single quotes wherever possible. - Updated docs in $VIMRUNTIME/doc/filetype.txt (still need to update user-manual) - Always call tolower on section name. See comment in s:extract_page_and_sect_fpage - Formatting/consistency cleanup - Automatically map q to ':q<CR>' when invoked as $MANPAGER - It also fully supports being used as $MANPAGER. Setting the name and stuff automatically. - Split up the setlocals into multiple lines for easier readability - Better detection of errors by redirecting stderr to /dev/null. If an error occured, stdout will be empty. - Functions return [sect, page] not [page, sect]. Makes more sense with how man takes the arguments as sect and then page. - Pretty prints errors on a single line. - If no section is given, automatically finds the correct section for the buffer name. It also gets the correct page. See the comment in s:get_page - If $MANWIDTH is not set, do not assign directly to $MANWIDTH because then $MANWIDTH will always stay set to the same value as we only use winwidth(0) when the global $MANWIDTH is empty. Instead we set it locally for the command. - Maintainer notes on all files.
2016-03-14 02:05:28 -07:00
syntax case ignore
syntax match manReference display '[^()[:space:]]\+([0-9nx][a-z]*)'
syntax match manSectionHeading display '^\S.*$'
syntax match manTitle display '^\%1l.*$'
syntax match manSubHeading display '^ \{3\}\S.*$'
syntax match manOptionDesc display '^\s\+\%(+\|-\)\S\+'
man.vim: rewrite - Smart autocomplete. It's automatically sorted, filtered for duplicates and even formats the candidates based on what is needed. For example, `:Man 1 printf<TAB>` will show the pages that are in section 1m as 'page(sect)' to let you know they are in a more specific section. - Instead of trying to unset $MANPAGER we use the -P flag to set the pager to cat - Always use the section arg '-s', it makes the code much simpler (see comment in s:man-args). - A manpage name starting with '-' is invalid. It's fine for sections because of the use of '-s'. - The tagstack is an actual stack now, makes it much simpler. - By using v:count and v:count1, the plugin can explicitly check whether the user set a count, instead of relying on a default value (0) that is actually a real manpage section. - Extraction of a manpage reference is much more simple. No giant long complicated regexes. Now, the plugin lets `man` handle the actual validation. We merely extract the section and page. Syntax regexes are a bit more specific though to prevent highlighting everything. - Multilingual support in the syntax file. Removed the cruft that was only relevent to vim. Also simplified and improved many of the regexes. - Using shellescape when sending the page and sect as arguments - In general, the code flow is much more obvious. - man#get_page has been split up into smaller functions with explicit responsibilties - ':help' behavior in opening splits and manpages - Comments explaining anything that needs explaining and isn't immediately obvious. - If a manpage has already been loaded but if it were to reloaded at the current width which is the same as the width at which it was loaded at previously, it is not reloaded. - Use substitute to remove the backspaced instead of `col -b`, as the latter doesn't work with other languages. - Open paths to manpages - It uses cWORD instead of cword to get the manpage under the cursor, this helps with files that do not have (,) in iskeyword. It also means the plugin does not set iskeyword locally anymore. - <Plug>(Man) mapping for easy remapping - Switched to single quotes wherever possible. - Updated docs in $VIMRUNTIME/doc/filetype.txt (still need to update user-manual) - Always call tolower on section name. See comment in s:extract_page_and_sect_fpage - Formatting/consistency cleanup - Automatically map q to ':q<CR>' when invoked as $MANPAGER - It also fully supports being used as $MANPAGER. Setting the name and stuff automatically. - Split up the setlocals into multiple lines for easier readability - Better detection of errors by redirecting stderr to /dev/null. If an error occured, stdout will be empty. - Functions return [sect, page] not [page, sect]. Makes more sense with how man takes the arguments as sect and then page. - Pretty prints errors on a single line. - If no section is given, automatically finds the correct section for the buffer name. It also gets the correct page. See the comment in s:get_page - If $MANWIDTH is not set, do not assign directly to $MANWIDTH because then $MANWIDTH will always stay set to the same value as we only use winwidth(0) when the global $MANWIDTH is empty. Instead we set it locally for the command. - Maintainer notes on all files.
2016-03-14 02:05:28 -07:00
highlight default link manTitle Title
highlight default link manSectionHeading Statement
highlight default link manOptionDesc Constant
highlight default link manReference PreProc
highlight default link manSubHeading Function
2017-12-24 10:16:58 -07:00
highlight default manUnderline cterm=underline gui=underline
highlight default manBold cterm=bold gui=bold
highlight default manItalic cterm=italic gui=italic
2017-11-10 21:27:00 -07:00
if &filetype != 'man'
" May have been included by some other filetype.
finish
endif
if !exists('b:man_sect')
call man#init_pager()
endif
if b:man_sect =~# '^[023]'
syntax case match
syntax include @c $VIMRUNTIME/syntax/c.vim
syntax match manCFuncDefinition display '\<\h\w*\>\ze\(\s\|\n\)*(' contained
syntax match manLowerSentence /\n\s\{7}\l.\+[()]\=\%(\:\|.\|-\)[()]\=[{};]\@<!\n$/ display keepend contained contains=manReference
syntax region manSentence start=/^\s\{7}\%(\u\|\*\)[^{}=]*/ end=/\n$/ end=/\ze\n\s\{3,7}#/ keepend contained contains=manReference
syntax region manSynopsis start='^\%(
man.vim: rewrite - Smart autocomplete. It's automatically sorted, filtered for duplicates and even formats the candidates based on what is needed. For example, `:Man 1 printf<TAB>` will show the pages that are in section 1m as 'page(sect)' to let you know they are in a more specific section. - Instead of trying to unset $MANPAGER we use the -P flag to set the pager to cat - Always use the section arg '-s', it makes the code much simpler (see comment in s:man-args). - A manpage name starting with '-' is invalid. It's fine for sections because of the use of '-s'. - The tagstack is an actual stack now, makes it much simpler. - By using v:count and v:count1, the plugin can explicitly check whether the user set a count, instead of relying on a default value (0) that is actually a real manpage section. - Extraction of a manpage reference is much more simple. No giant long complicated regexes. Now, the plugin lets `man` handle the actual validation. We merely extract the section and page. Syntax regexes are a bit more specific though to prevent highlighting everything. - Multilingual support in the syntax file. Removed the cruft that was only relevent to vim. Also simplified and improved many of the regexes. - Using shellescape when sending the page and sect as arguments - In general, the code flow is much more obvious. - man#get_page has been split up into smaller functions with explicit responsibilties - ':help' behavior in opening splits and manpages - Comments explaining anything that needs explaining and isn't immediately obvious. - If a manpage has already been loaded but if it were to reloaded at the current width which is the same as the width at which it was loaded at previously, it is not reloaded. - Use substitute to remove the backspaced instead of `col -b`, as the latter doesn't work with other languages. - Open paths to manpages - It uses cWORD instead of cword to get the manpage under the cursor, this helps with files that do not have (,) in iskeyword. It also means the plugin does not set iskeyword locally anymore. - <Plug>(Man) mapping for easy remapping - Switched to single quotes wherever possible. - Updated docs in $VIMRUNTIME/doc/filetype.txt (still need to update user-manual) - Always call tolower on section name. See comment in s:extract_page_and_sect_fpage - Formatting/consistency cleanup - Automatically map q to ':q<CR>' when invoked as $MANPAGER - It also fully supports being used as $MANPAGER. Setting the name and stuff automatically. - Split up the setlocals into multiple lines for easier readability - Better detection of errors by redirecting stderr to /dev/null. If an error occured, stdout will be empty. - Functions return [sect, page] not [page, sect]. Makes more sense with how man takes the arguments as sect and then page. - Pretty prints errors on a single line. - If no section is given, automatically finds the correct section for the buffer name. It also gets the correct page. See the comment in s:get_page - If $MANWIDTH is not set, do not assign directly to $MANWIDTH because then $MANWIDTH will always stay set to the same value as we only use winwidth(0) when the global $MANWIDTH is empty. Instead we set it locally for the command. - Maintainer notes on all files.
2016-03-14 02:05:28 -07:00
\SYNOPSIS\|
\SYNTAX\|
\SINTASSI\|
\SKŁADNIA\|
\СИНТАКСИС\|
\書式\)$' end='^\%(\S.*\)\=\S$' keepend contains=manLowerSentence,manSentence,manSectionHeading,@c,manCFuncDefinition
man.vim: rewrite - Smart autocomplete. It's automatically sorted, filtered for duplicates and even formats the candidates based on what is needed. For example, `:Man 1 printf<TAB>` will show the pages that are in section 1m as 'page(sect)' to let you know they are in a more specific section. - Instead of trying to unset $MANPAGER we use the -P flag to set the pager to cat - Always use the section arg '-s', it makes the code much simpler (see comment in s:man-args). - A manpage name starting with '-' is invalid. It's fine for sections because of the use of '-s'. - The tagstack is an actual stack now, makes it much simpler. - By using v:count and v:count1, the plugin can explicitly check whether the user set a count, instead of relying on a default value (0) that is actually a real manpage section. - Extraction of a manpage reference is much more simple. No giant long complicated regexes. Now, the plugin lets `man` handle the actual validation. We merely extract the section and page. Syntax regexes are a bit more specific though to prevent highlighting everything. - Multilingual support in the syntax file. Removed the cruft that was only relevent to vim. Also simplified and improved many of the regexes. - Using shellescape when sending the page and sect as arguments - In general, the code flow is much more obvious. - man#get_page has been split up into smaller functions with explicit responsibilties - ':help' behavior in opening splits and manpages - Comments explaining anything that needs explaining and isn't immediately obvious. - If a manpage has already been loaded but if it were to reloaded at the current width which is the same as the width at which it was loaded at previously, it is not reloaded. - Use substitute to remove the backspaced instead of `col -b`, as the latter doesn't work with other languages. - Open paths to manpages - It uses cWORD instead of cword to get the manpage under the cursor, this helps with files that do not have (,) in iskeyword. It also means the plugin does not set iskeyword locally anymore. - <Plug>(Man) mapping for easy remapping - Switched to single quotes wherever possible. - Updated docs in $VIMRUNTIME/doc/filetype.txt (still need to update user-manual) - Always call tolower on section name. See comment in s:extract_page_and_sect_fpage - Formatting/consistency cleanup - Automatically map q to ':q<CR>' when invoked as $MANPAGER - It also fully supports being used as $MANPAGER. Setting the name and stuff automatically. - Split up the setlocals into multiple lines for easier readability - Better detection of errors by redirecting stderr to /dev/null. If an error occured, stdout will be empty. - Functions return [sect, page] not [page, sect]. Makes more sense with how man takes the arguments as sect and then page. - Pretty prints errors on a single line. - If no section is given, automatically finds the correct section for the buffer name. It also gets the correct page. See the comment in s:get_page - If $MANWIDTH is not set, do not assign directly to $MANWIDTH because then $MANWIDTH will always stay set to the same value as we only use winwidth(0) when the global $MANWIDTH is empty. Instead we set it locally for the command. - Maintainer notes on all files.
2016-03-14 02:05:28 -07:00
highlight default link manCFuncDefinition Function
syntax region manExample start='^EXAMPLES\=$' end='^\%(\S.*\)\=\S$' keepend contains=manLowerSentence,manSentence,manSectionHeading,manSubHeading,@c,manCFuncDefinition
" XXX: groupthere doesn't seem to work
syntax sync minlines=500
"syntax sync match manSyncExample groupthere manExample '^EXAMPLES\=$'
"syntax sync match manSyncExample groupthere NONE '^\%(EXAMPLES\=\)\@!\%(\S.*\)\=\S$'
endif
man.vim: rewrite - Smart autocomplete. It's automatically sorted, filtered for duplicates and even formats the candidates based on what is needed. For example, `:Man 1 printf<TAB>` will show the pages that are in section 1m as 'page(sect)' to let you know they are in a more specific section. - Instead of trying to unset $MANPAGER we use the -P flag to set the pager to cat - Always use the section arg '-s', it makes the code much simpler (see comment in s:man-args). - A manpage name starting with '-' is invalid. It's fine for sections because of the use of '-s'. - The tagstack is an actual stack now, makes it much simpler. - By using v:count and v:count1, the plugin can explicitly check whether the user set a count, instead of relying on a default value (0) that is actually a real manpage section. - Extraction of a manpage reference is much more simple. No giant long complicated regexes. Now, the plugin lets `man` handle the actual validation. We merely extract the section and page. Syntax regexes are a bit more specific though to prevent highlighting everything. - Multilingual support in the syntax file. Removed the cruft that was only relevent to vim. Also simplified and improved many of the regexes. - Using shellescape when sending the page and sect as arguments - In general, the code flow is much more obvious. - man#get_page has been split up into smaller functions with explicit responsibilties - ':help' behavior in opening splits and manpages - Comments explaining anything that needs explaining and isn't immediately obvious. - If a manpage has already been loaded but if it were to reloaded at the current width which is the same as the width at which it was loaded at previously, it is not reloaded. - Use substitute to remove the backspaced instead of `col -b`, as the latter doesn't work with other languages. - Open paths to manpages - It uses cWORD instead of cword to get the manpage under the cursor, this helps with files that do not have (,) in iskeyword. It also means the plugin does not set iskeyword locally anymore. - <Plug>(Man) mapping for easy remapping - Switched to single quotes wherever possible. - Updated docs in $VIMRUNTIME/doc/filetype.txt (still need to update user-manual) - Always call tolower on section name. See comment in s:extract_page_and_sect_fpage - Formatting/consistency cleanup - Automatically map q to ':q<CR>' when invoked as $MANPAGER - It also fully supports being used as $MANPAGER. Setting the name and stuff automatically. - Split up the setlocals into multiple lines for easier readability - Better detection of errors by redirecting stderr to /dev/null. If an error occured, stdout will be empty. - Functions return [sect, page] not [page, sect]. Makes more sense with how man takes the arguments as sect and then page. - Pretty prints errors on a single line. - If no section is given, automatically finds the correct section for the buffer name. It also gets the correct page. See the comment in s:get_page - If $MANWIDTH is not set, do not assign directly to $MANWIDTH because then $MANWIDTH will always stay set to the same value as we only use winwidth(0) when the global $MANWIDTH is empty. Instead we set it locally for the command. - Maintainer notes on all files.
2016-03-14 02:05:28 -07:00
" Prevent everything else from matching the last line
execute 'syntax match manFooter display "^\%'.line('$').'l.*$"'
man.vim: rewrite - Smart autocomplete. It's automatically sorted, filtered for duplicates and even formats the candidates based on what is needed. For example, `:Man 1 printf<TAB>` will show the pages that are in section 1m as 'page(sect)' to let you know they are in a more specific section. - Instead of trying to unset $MANPAGER we use the -P flag to set the pager to cat - Always use the section arg '-s', it makes the code much simpler (see comment in s:man-args). - A manpage name starting with '-' is invalid. It's fine for sections because of the use of '-s'. - The tagstack is an actual stack now, makes it much simpler. - By using v:count and v:count1, the plugin can explicitly check whether the user set a count, instead of relying on a default value (0) that is actually a real manpage section. - Extraction of a manpage reference is much more simple. No giant long complicated regexes. Now, the plugin lets `man` handle the actual validation. We merely extract the section and page. Syntax regexes are a bit more specific though to prevent highlighting everything. - Multilingual support in the syntax file. Removed the cruft that was only relevent to vim. Also simplified and improved many of the regexes. - Using shellescape when sending the page and sect as arguments - In general, the code flow is much more obvious. - man#get_page has been split up into smaller functions with explicit responsibilties - ':help' behavior in opening splits and manpages - Comments explaining anything that needs explaining and isn't immediately obvious. - If a manpage has already been loaded but if it were to reloaded at the current width which is the same as the width at which it was loaded at previously, it is not reloaded. - Use substitute to remove the backspaced instead of `col -b`, as the latter doesn't work with other languages. - Open paths to manpages - It uses cWORD instead of cword to get the manpage under the cursor, this helps with files that do not have (,) in iskeyword. It also means the plugin does not set iskeyword locally anymore. - <Plug>(Man) mapping for easy remapping - Switched to single quotes wherever possible. - Updated docs in $VIMRUNTIME/doc/filetype.txt (still need to update user-manual) - Always call tolower on section name. See comment in s:extract_page_and_sect_fpage - Formatting/consistency cleanup - Automatically map q to ':q<CR>' when invoked as $MANPAGER - It also fully supports being used as $MANPAGER. Setting the name and stuff automatically. - Split up the setlocals into multiple lines for easier readability - Better detection of errors by redirecting stderr to /dev/null. If an error occured, stdout will be empty. - Functions return [sect, page] not [page, sect]. Makes more sense with how man takes the arguments as sect and then page. - Pretty prints errors on a single line. - If no section is given, automatically finds the correct section for the buffer name. It also gets the correct page. See the comment in s:get_page - If $MANWIDTH is not set, do not assign directly to $MANWIDTH because then $MANWIDTH will always stay set to the same value as we only use winwidth(0) when the global $MANWIDTH is empty. Instead we set it locally for the command. - Maintainer notes on all files.
2016-03-14 02:05:28 -07:00
let b:current_syntax = 'man'