Home Explore Blog CI



neovim

38th chunk of `runtime/doc/syntax.txt`
d9f3450b1787a93290db2c8dffe672070da04f3c01fe18440000000100000faf
 initialization) >
   let sgml_my_rendering=1

You can also disable this rendering by adding the following line to your
vimrc file: >
   let sgml_no_rendering=1

(Adapted from the html.vim help text by Claudio Fleiner <claudio@fleiner.com>)


		*ft-posix-syntax* *ft-dash-syntax*
SH		*sh.vim*  *ft-sh-syntax*  *ft-bash-syntax*  *ft-ksh-syntax*

This covers syntax highlighting for the older Unix (Bourne) sh, and newer
shells such as bash, dash, posix, and the Korn shells.

Vim attempts to determine which shell type is in use by specifying that
various filenames are of specific types, e.g.: >

    ksh : .kshrc* *.ksh
    bash: .bashrc* bashrc bash.bashrc .bash_profile* *.bash
<
See $VIMRUNTIME/filetype.vim for the full list of patterns.  If none of these
cases pertain, then the first line of the file is examined (ex. looking for
/bin/sh  /bin/ksh  /bin/bash).  If the first line specifies a shelltype, then
that shelltype is used.  However some files (ex. .profile) are known to be
shell files but the type is not apparent.  Furthermore, on many systems sh is
symbolically linked to "bash" (Linux, Windows+cygwin) or "ksh" (POSIX).

One may specify a global default by instantiating one of the following
variables in your vimrc:

   ksh: >
	let g:is_kornshell = 1
<   posix: (default) >
	let g:is_posix     = 1
<   bash: >
	let g:is_bash	   = 1
<   dash: >
	let g:is_dash	   = 1
<   sh: Bourne shell >
	let g:is_sh	   = 1

Specific shell features are automatically enabled based on the shell detected
from the shebang line ("#! ...").  For KornShell Vim detects different shell
features for mksh, ksh88, ksh93, ksh93u, ksh93v, and ksh2020.

If there's no "#! ..." line, and the user hasn't availed themself of a default
sh.vim syntax setting as just shown, then syntax/sh.vim will assume the POSIX
shell syntax.  No need to quote RFCs or market penetration statistics in error
reports, please -- just select the default version of the sh your system uses
and install the associated "let..." in your <.vimrc>.

The syntax/sh.vim file provides several levels of syntax-based folding: >

	let g:sh_fold_enabled= 0     (default, no syntax folding)
	let g:sh_fold_enabled= 1     (enable function folding)
	let g:sh_fold_enabled= 2     (enable heredoc folding)
	let g:sh_fold_enabled= 4     (enable if/do/for folding)

then various syntax items (ie. HereDocuments and function bodies) become
syntax-foldable (see |:syn-fold|).  You also may add these together
to get multiple types of folding: >

	let g:sh_fold_enabled= 3     (enables function and heredoc folding)

If you notice highlighting errors while scrolling backwards which are fixed
when one redraws with CTRL-L, try setting the "sh_minlines" internal variable
to a larger number.  Example: >

	let sh_minlines = 500

This will make syntax synchronization start 500 lines before the first
displayed line.  The default value is 200.  The disadvantage of using a larger
number is that redrawing can become slow.

If you don't have much to synchronize on, displaying can be very slow.	To
reduce this, the "sh_maxlines" internal variable can be set.  Example: >

	let sh_maxlines = 100
<
The default is to use the twice sh_minlines.  Set it to a smaller number to
speed up displaying.  The disadvantage is that highlight errors may appear.

syntax/sh.vim tries to flag certain problems as errors; usually things like
unmatched "]", "done", "fi", etc.  If you find the error handling problematic
for your purposes, you may suppress such error highlighting by putting
the following line in your .vimrc: >

	let g:sh_no_error= 1
<

						*sh-embed*  *sh-awk*
 Sh: EMBEDDING LANGUAGES~

You may wish to embed languages into sh.  I'll give an example courtesy of
Lorance Stinson on how to do this with awk as an example. Put the following
file into $HOME/.config/nvim/after/syntax/sh/awkembed.vim: >

    " AWK Embedding:
    " ==============
    " Shamelessly ripped from aspperl.vim by Aaron Hope.
    if exists("b:current_syntax")
      unlet b:current_syntax

Title: SH (Shell) Syntax Highlighting: Shell Type, Folding, and Error Handling
Summary
This section describes how Vim handles syntax highlighting for various Unix shells (sh, bash, ksh, etc.). It details how Vim determines the shell type, the usage of default shell settings, different levels of syntax-based folding, error highlighting suppression, and embedding languages like AWK within SH scripts.