Loading ...
Sorry, an error occurred while loading the content.

Re: No ~/.vim/after/syntax/php.vim

Expand Messages
  • Dotan Cohen
    ... Apparently I erred, I apologise for driving everyone crazy. Here is the :scriptfiles output for a PHP file: 1: /usr/share/vim/vimrc 2:
    Message 1 of 18 , May 3, 2012
    • 0 Attachment
      On Thu, May 3, 2012 at 11:49 PM, Gary Johnson <garyjohn@...> wrote:
      > On 2012-05-03, Dotan Cohen wrote:
      >> On Thu, May 3, 2012 at 10:34 PM, Ben Fritz wrote:
      >> > It shouldn't, without a syntax/php.vim file somewhere. As noted,
      >> > this file is only sourced as-needed; is the output of the
      >> > :scriptnames command you gave from a Vim with the php file
      >> > loaded and syntax highlighting on as you describe? In that Vim,
      >> > what does this command say?
      >> >
      >>
      >> The PHP syntax is probably being sourced from whatever the default is
      >> in /etc or /usr
      >>
      >> >  :verbose set syntax? filetype?
      >> >
      >>
      >>   syntax=php
      >>         Last set from /usr/share/vim/vim73/syntax/syntax.vim
      >>   filetype=php
      >>         Last set from /usr/share/vim/vim73/filetype.vim
      >
      > Neither of those files was in the :scriptnames output that you
      > posted originally.
      >
      >      1: /usr/share/vim/vimrc
      >      2: /usr/share/vim/vim73/debian.vim
      >      3: /usr/share/vim/vim73/syntax/syntax.vim
      >      4: /usr/share/vim/vim73/syntax/synload.vim
      >      5: /usr/share/vim/vim73/syntax/syncolor.vim
      >      6: /usr/share/vim/vim73/filetype.vim
      >      7: /home/dotancohen/.vimrc
      >      8: /home/dotancohen/.vim/keymap/insert-only_capslock.vim
      >      9: /home/dotancohen/.vim/plugin/taglist.vim
      >     10: /usr/share/vim/vim73/plugin/getscriptPlugin.vim
      >     11: /usr/share/vim/vim73/plugin/gzip.vim
      >     12: /usr/share/vim/vim73/plugin/matchparen.vim
      >     13: /usr/share/vim/vim73/plugin/netrwPlugin.vim
      >     14: /usr/share/vim/vim73/plugin/rrhelper.vim
      >     15: /usr/share/vim/vim73/plugin/spellfile.vim
      >     16: /usr/share/vim/vim73/plugin/tarPlugin.vim
      >     17: /usr/share/vim/vim73/plugin/tohtml.vim
      >     18: /usr/share/vim/vim73/plugin/vimballPlugin.vim
      >     19: /usr/share/vim/vim73/plugin/zipPlugin.vim
      >     20: /home/dotancohen/.vim/after/plugin/matchparen.vim
      >     21: /usr/share/vim/vim73/scripts.vim
      >    Press ENTER or type command to continue
      >
      > That means that they were sourced AFTER you executed that
      > :scriptnames command but BEFORE you executed
      >
      >    :verbose set syntax? filetype?
      >
      > So try the :scriptnames command again but this time AFTER you open a
      > PHP file.
      >

      Apparently I erred, I apologise for driving everyone crazy. Here is
      the :scriptfiles output for a PHP file:

      1: /usr/share/vim/vimrc
      2: /usr/share/vim/vim73/debian.vim
      3: /usr/share/vim/vim73/syntax/syntax.vim
      4: /usr/share/vim/vim73/syntax/synload.vim
      5: /usr/share/vim/vim73/syntax/syncolor.vim
      6: /usr/share/vim/vim73/filetype.vim
      7: /home/dotancohen/.vimrc
      8: /home/dotancohen/.vim/keymap/insert-only_capslock.vim
      9: /home/dotancohen/.vim/plugin/taglist.vim
      10: /usr/share/vim/vim73/plugin/getscriptPlugin.vim
      11: /usr/share/vim/vim73/plugin/gzip.vim
      12: /usr/share/vim/vim73/plugin/matchparen.vim
      13: /usr/share/vim/vim73/plugin/netrwPlugin.vim
      14: /usr/share/vim/vim73/plugin/rrhelper.vim
      15: /usr/share/vim/vim73/plugin/spellfile.vim
      16: /usr/share/vim/vim73/plugin/tarPlugin.vim
      17: /usr/share/vim/vim73/plugin/tohtml.vim
      18: /usr/share/vim/vim73/plugin/vimballPlugin.vim
      19: /usr/share/vim/vim73/plugin/zipPlugin.vim
      20: /home/dotancohen/.vim/after/plugin/matchparen.vim
      21: /usr/share/vim/vim73/syntax/php.vim
      22: /usr/share/vim/vim73/syntax/html.vim
      23: /usr/share/vim/vim73/syntax/javascript.vim
      24: /usr/share/vim/vim73/syntax/vb.vim
      25: /usr/share/vim/vim73/syntax/css.vim
      26: /usr/share/vim/vim73/syntax/sql.vim
      27: /usr/share/vim/vim73/syntax/sqloracle.vim
      28: /home/dotancohen/.vim/after/syntax/php.vim
      29: /usr/share/vim/vim73/scripts.vim
      30: /usr/share/vim/vim73/syntax/help.vim

      I see that ~/.vim/after/syntax/php.vim is in there. However, the +=
      string is certainly not being highlighted as error. Here is the
      content of the ~/.vim/after/syntax/php.vim file:
      scriptencoding utf-8
      setlocal nolist
      syn match phpPlusEq '+='
      hi link phpPlusEq Error

      I also tried with a keyword definition instead of match, this did not
      work to highlight += either:
      scriptencoding utf-8
      setlocal nolist
      syn keyword phpPlusEq +=
      highlight phpPlusEq term=reverse ctermfg=black ctermbg=yellow
      guifg=black guibg=yellow

      --
      Dotan Cohen

      http://gibberish.co.il
      http://what-is-what.com

      --
      You received this message from the "vim_use" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php
    • sc
      ... in your original post you said ... is it possible you have similarly fat-fingered the operator in your script? sc -- You received this
      Message 2 of 18 , May 4, 2012
      • 0 Attachment
        On Fri, May 04, 2012 at 09:34:23AM +0300, Dotan Cohen wrote:
        > On Thu, May 3, 2012 at 11:49 PM, Gary Johnson <garyjohn@...> wrote:
        > > On 2012-05-03, Dotan Cohen wrote:
        > >> On Thu, May 3, 2012 at 10:34 PM, Ben Fritz wrote:

        <rapacious snip>

        in your original post you said

        > I am trying to get the "=+" operator highlighted as an error in PHP

        is it possible you have similarly fat-fingered the operator in
        your script?

        sc

        --
        You received this message from the "vim_use" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php
      • Dotan Cohen
        ... Nice catch! I just double checked, no fat fingers in either of the two scripts that I am trying on the assumption that there may be a problem in the
        Message 3 of 18 , May 4, 2012
        • 0 Attachment
          On Fri, May 4, 2012 at 8:40 PM, sc <toothpik@...> wrote:
          > <rapacious snip>
          >
          > in your original post you said
          >
          >> I am trying to get the "=+" operator highlighted as an error in PHP
          >
          > is it possible you have similarly fat-fingered the operator in
          > your script?
          >

          Nice catch! I just double checked, no fat fingers in either of the two
          scripts that I am trying on the assumption that there may be a problem
          in the script:

          Version 1:
          scriptencoding utf-8
          setlocal nolist
          syn match phpPlusEq '+='
          hi link phpPlusEq Error

          Version 2:
          scriptencoding utf-8
          setlocal nolist
          syn keyword phpPlusEq +=
          highlight phpPlusEq term=reverse ctermfg=black ctermbg=yellow
          guifg=black guibg=yellow


          --
          Dotan Cohen

          http://gibberish.co.il
          http://what-is-what.com

          --
          You received this message from the "vim_use" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php
        • Benjamin R. Haskell
          ... It worked for me after changing that line to: syn match phpPlusEq += containedin=phpOperator ... -- Best, Ben -- You received this message from the
          Message 4 of 18 , May 7, 2012
          • 0 Attachment
            On Sat, 5 May 2012, Dotan Cohen wrote:

            > On Fri, May 4, 2012 at 8:40 PM, sc <toothpik@...> wrote:
            >> <rapacious snip>
            >>
            >> in your original post you said
            >>
            >>> I am trying to get the "=+" operator highlighted as an error in PHP
            >>
            >> is it possible you have similarly fat-fingered the operator in your
            >> script?
            >>
            >
            > Nice catch! I just double checked, no fat fingers in either of the two
            > scripts that I am trying on the assumption that there may be a problem
            > in the script:
            >
            > Version 1:
            > scriptencoding utf-8
            > setlocal nolist
            > syn match phpPlusEq '+='

            It worked for me after changing that line to:

            syn match phpPlusEq '+=' containedin=phpOperator

            > hi link phpPlusEq Error

            --
            Best,
            Ben

            --
            You received this message from the "vim_use" maillist.
            Do not top-post! Type your reply below the text you are replying to.
            For more information, visit http://www.vim.org/maillist.php
          • Dotan Cohen
            ... Thanks, Ben! I changed the line as you mention, but still no highlighting of the += operator, even though I can see the file is being sourced. I will say,
            Message 5 of 18 , May 7, 2012
            • 0 Attachment
              On Mon, May 7, 2012 at 5:56 PM, Benjamin R. Haskell <vim@...> wrote:
              >> syn match phpPlusEq '+='
              >
              >
              > It worked for me after changing that line to:
              >
              > syn match phpPlusEq '+=' containedin=phpOperator
              >

              Thanks, Ben! I changed the line as you mention, but still no
              highlighting of the += operator, even though I can see the file is
              being sourced.

              I will say, though, that this issue brought my attention to the
              operator so forward in my mind that I am much more mindful of it. I
              dare say that I may be less prone to making the .= / += mistake now.

              The root of the problem is PHP usage of the . operator for string
              concatenation, vs. Javascript / Java / C# usage of += for the same.
              PHP _does_ use += for integer/float addition, and on top of that PHP
              will silently cast a string to an int (value: 0) if the += operator is
              used on it, then silently overwrite the weakly-typed variable with the
              integer!

              TRWFT is PHP.

              --
              Dotan Cohen

              http://gibberish.co.il
              http://what-is-what.com

              --
              You received this message from the "vim_use" maillist.
              Do not top-post! Type your reply below the text you are replying to.
              For more information, visit http://www.vim.org/maillist.php
            Your message has been successfully submitted and would be delivered to recipients shortly.