[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: vim syntax highlight plugin for gawk
From: |
Andrew J. Schorr |
Subject: |
Re: vim syntax highlight plugin for gawk |
Date: |
Wed, 25 Mar 2020 08:27:07 -0400 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Tue, Mar 24, 2020 at 04:38:40PM -0500, Peng Yu wrote:
> The default vim highlight for awk is not always correct. For example,
> I don't see "case" highlighted. Is there an official vim syntax
> highlight plugin recommended for gawk? Thanks.
On my platform, the awk syntax file in /usr/share/vim/vim82/syntax/awk.vim
says at the top:
" Vim syntax file
" Language: awk, nawk, gawk, mawk
" Maintainer: Antonio Colombo <address@hidden>
" Last Change: 2016 Sep 05
" AWK ref. is: Alfred V. Aho, Brian W. Kernighan, Peter J. Weinberger
" The AWK Programming Language, Addison-Wesley, 1988
" GAWK ref. is: Arnold D. Robbins
" Effective AWK Programming, Third Edition, O'Reilly, 2001
" Effective AWK Programming, Fourth Edition, O'Reilly, 2015
" (also available and updated with the gawk source distribution)
" MAWK is a "new awk" meaning it implements AWK ref.
" mawk conforms to the Posix 1003.2 (draft 11.3)
" definition of the AWK language which contains a few features
" not described in the AWK book, and mawk provides a small number of extensions.
...
So it clearly intends to support gawk, at least to some extent.
And it does include some gawk-specific features. For example:
" GAWK ref. Chapter 7-9
syn keyword awkStatement switch nextfile
syn keyword awkStatement func
"
" GAWK ref. Chapter 9, Functions
" Numeric Functions
syn keyword awkFunction atan2 cos exp int intdiv log rand sin sqrt srand
" String Manipulation Functions
syn keyword awkFunction asort asort1 gensub gsub index length match
syn keyword awkFunction patsplit split sprintf strtonum sub substr
The quick and dirty hack is to patch the file to add missing statements such as
case. For example, just add:
syn keyword awkStatement case
For a better solution, you should perhaps contact the maintainer
Antonio Colombo <address@hidden>. He also seems to have a typo
where he's got "asort1" instead of "asorti".
Regards,
Andy