Home Explore Blog CI



neovim

72th chunk of `runtime/doc/syntax.txt`
3d4ac4159c802b339fe08a5b92d07a67917b849b5cb3da58000000010000092d
 can be done too.  For this you
must use Universal Ctags (https://ctags.io) or Exuberant ctags.

Put these lines in your Makefile: >

    # Make a highlight file for types.  Requires Universal/Exuberant ctags and awk
    types: types.vim
    types.vim: *.[ch]
	    ctags --c-kinds=gstu -o- *.[ch] |\
		    awk 'BEGIN{printf("syntax keyword Type\t")}\
			    {printf("%s ", $$1)}END{print ""}' > $@

And put these lines in your vimrc: >

   " load the types.vim highlighting file, if it exists
   autocmd BufRead,BufNewFile *.[ch] let fname = expand('<afile>:p:h') .. '/types.vim'
   autocmd BufRead,BufNewFile *.[ch] if filereadable(fname)
   autocmd BufRead,BufNewFile *.[ch]   exe 'so ' .. fname
   autocmd BufRead,BufNewFile *.[ch] endif

==============================================================================
17. Window-local syntax				*:ownsyntax*

Normally all windows on a buffer share the same syntax settings. It is
possible, however, to set a particular window on a file to have its own
private syntax setting. A possible example would be to edit LaTeX source
with conventional highlighting in one window, while seeing the same source
highlighted differently (so as to hide control sequences and indicate bold,
italic etc regions) in another. The 'scrollbind' option is useful here.

To set the current window to have the syntax "foo", separately from all other
windows on the buffer: >
   :ownsyntax foo
<						*w:current_syntax*
This will set the "w:current_syntax" variable to "foo".  The value of
"b:current_syntax" does not change.  This is implemented by saving and
restoring "b:current_syntax", since the syntax files do set
"b:current_syntax".  The value set by the syntax file is assigned to
"w:current_syntax".
Note: This resets the 'spell', 'spellcapcheck', 'spellfile' and 'spelloptions'
options.

Once a window has its own syntax, syntax commands executed from other windows
on the same buffer (including :syntax clear) have no effect. Conversely,
syntax commands executed from that window do not affect other windows on the
same buffer.

A window with its own syntax reverts to normal behavior when another buffer
is loaded into that window or the file is reloaded.
When splitting the window, the new window will use the original syntax.

==============================================================================

Title: Highlighting Types with Universal/Exuberant Ctags and Window-Local Syntax
Summary
This section explains how to highlight typedefs, unions, and structs using Universal Ctags or Exuberant Ctags, providing Makefile and vimrc configurations. It then introduces window-local syntax, which allows each window on a buffer to have its own syntax settings using the ':ownsyntax' command, useful for scenarios like editing LaTeX with different highlighting schemes in separate windows. It also discusses the behavior of 'w:current_syntax' and 'b:current_syntax' when using window-local syntax.