• Re: Vim syntax file for ksh93 ?

    From Janis Papanagnou@21:1/5 to Benjamin Esham on Fri Aug 18 05:47:49 2023
    On 18.08.2023 02:01, Benjamin Esham wrote:
    Janis Papanagnou wrote:

    On 8/7/23 4:34 PM, Janis Papanagnou wrote:

    Is there some Vim syntax file existing that handles a contemporary
    Kornshell syntax (ksh93u+) correctly, i.e. without displaying valid
    ksh93 constructs as errors (as the existing sh.vim does[*])?


    Have you tried the zsh syntax highlighting (:set filetype=zsh)? I tried
    these two constructs and neither was marked as an error.

    I thought that I had tried that with zsh syntax in the past...


    Zsh supports a fairly large subset of ksh syntax and semantics,[1][2] so I'd imagine that a lot of your scripts would be highlighted in a reasonable way by the zsh syntax file. (If anything, you might run into problems where ksh syntax errors *aren't* flagged because they're valid in zsh.)

    ...but upon retrying now the result is indeed very good.

    The only thing is that my (k)sh syntax file supports embedded awk
    scripts so that both, ksh and awk, are highlighted accordingly.
    The zsh syntax does not support that feature, the whole awk program
    is marked monochrome as an undifferentiated string. It may be that
    this embedded syntax feature had been added later (it was probably
    contributed by someone in the shell and/or awk newsgroup). (I'll
    have a look into that, but I'm no expert in vim's syntax language,
    so I have to see what I can make of it.)


    Hope this helps,

    Yes, thanks.

    Janis


    Benjamin


    [1] At least that's my impression as a zsh user but ksh non-user.

    [2] I don't know whether the ksh emulation ever covered 100% of ksh syntax
    and semantics, and even if it did in the past, ksh may have evolved
    since then. I am far from an expert here :-)


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From castAway@21:1/5 to Janis Papanagnou on Wed Sep 20 09:50:00 2023
    On 18/08/2023 00:47, Janis Papanagnou wrote:
    On 18.08.2023 02:01, Benjamin Esham wrote:
    Janis Papanagnou wrote:
    The only thing is that my (k)sh syntax file supports embedded awk
    scripts so that both, ksh and awk, are highlighted accordingly.
    The zsh syntax does not support that feature, the whole awk program
    is marked monochrome as an undifferentiated string. It may be that
    this embedded syntax feature had been added later (it was probably contributed by someone in the shell and/or awk newsgroup). (I'll
    have a look into that, but I'm no expert in vim's syntax language,
    so I have to see what I can make of it.)


    Check `:h sh-awk`:


    *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/.vim/after/syntax/sh/awkembed.vim: >

    [code]


    This code will then let the awk code in the single quotes: >
    awk '...awk code here...'
    be highlighted using the awk highlighting syntax. Clearly this may be
    extended to other languages.


    The awkembed.vim ball may be changed to be read after ksh syntax, I reckon.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to castAway on Wed Sep 20 20:47:02 2023
    On 20.09.2023 14:50, castAway wrote:
    [ awk syntax within ksh syntax highlighting ]

    Check `:h sh-awk`:
    [...]
    file into $HOME/.vim/after/syntax/sh/awkembed.vim: >

    [code]

    This code will then let the awk code in the single quotes: >
    awk '...awk code here...'
    be highlighted using the awk highlighting syntax. Clearly this may be
    extended to other languages.
    [...]

    Thanks! :-)

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Janis Papanagnou on Wed Sep 20 21:20:16 2023
    On 20.09.2023 20:47, Janis Papanagnou wrote:
    On 20.09.2023 14:50, castAway wrote:
    [ awk syntax within ksh syntax highlighting ]

    Check `:h sh-awk`:
    [...]
    file into $HOME/.vim/after/syntax/sh/awkembed.vim: >

    [code]

    This code will then let the awk code in the single quotes: >
    awk '...awk code here...'
    be highlighted using the awk highlighting syntax. Clearly this may be
    extended to other languages.
    [...]

    Thanks! :-)

    Upthread I noted I have problems with new ksh syntax constructs, e.g.
    in (( count++ )) the final closing parenthesis is market as error.
    This was the primary concern of my (original) post.

    The suggestion was - granted, it's a kludge - to set syntax to 'zsh'
    (instead of 'sh'). This changed the coloring slightly but it worked
    as as far as such constructs were not any more marked as errors. Fine.

    The awkembed.vim suggestion now doesn't work correctly with the other
    syntax issue; now either awk programs have a correct coloring but I
    see those spurious syntax errors (with syntax=sh and awkembed.vim) or
    I see no spurious errors but the whole awk program is uncolored (with syntax=zsh).

    It would be nice to have a solution that works correctly for both
    requirements.

    I tried to install a $HOME/.vim/after/syntax/zsh/awkembed.vi for zsh
    but obviously this is not how this is supposed to work.

    Any idea or how to fix both issues reliably (not just one or the other)?

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From castAway@21:1/5 to Janis Papanagnou on Wed Sep 20 20:02:37 2023
    On 20/09/2023 16:20, Janis Papanagnou wrote:
    On 20.09.2023 20:47, Janis Papanagnou wrote:
    On 20.09.2023 14:50, castAway wrote:
    [ awk syntax within ksh syntax highlighting ]


    I tried to install a $HOME/.vim/after/syntax/zsh/awkembed.vi for zsh
    but obviously this is not how this is supposed to work.

    Any idea or how to fix both issues reliably (not just one or the other)?

    Janis


    I beg your pardon but awk syntax does work for me with zsh (I just set it up today).

    Note that the file path you wrote is:

    $HOME/.vim/after/syntax/zsh/awkembed.vi

    Shouldn't that end with .vim?

    Also note that I use DrChip's Vim Colorscheme astronaut.vba.gz.

    Maybe try changing your colourscheme?

    Best regards,
    JSN

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)