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

Re: matchit support for python

Expand Messages
  • Bram Moolenaar
    ... That should not be much of a problem. Most important is that the user can activate matchit.vim and get support for all languages. Exceptions make it more
    Message 1 of 11 , Sep 3 7:19 AM
      Benji Fisher wrote:

      > > The matchit plugin is included. It's probably not a bad idea if the
      > > Python version would be merged into it. Would anybody want the matchit
      > > functionality but not the extra Python stuff?
      > >
      > > Otherwise we could include matchit_python.vim as well, and instruct
      > > users to install that additionally. This is more complicated, thus it
      > > would be good if we can avoid that.
      >
      > That would require a change to matchit.vim .

      That should not be much of a problem. Most important is that the user
      can activate matchit.vim and get support for all languages. Exceptions
      make it more complicated for the user.

      > Currently, the only
      > customization for different file types is that matchit.vim looks for a
      > list of regular expressions (usually defined in the ftplugin file) that
      > define matching pairs. I suppose the simplest thing to do would be to
      > look for a function like Matchit_python(); if the function exists and
      > returns a non-zero value, then use it to decide where to jump;
      > otherwise, continue as normal. The Matchit_python() function would be
      > perhaps half as long as the current python_match.vim file, and would
      > probably have to be defined in the ftplugin file.

      Defining a function in the filetype plugin, instead of/besides giving a
      value to b:match_words, appears to be a logical thing to do. Perhaps a
      b:match_function variable needs to be set? Or would the existence of
      the function with a specific name be sufficient? The function would
      need to be global though, can't select it on a per-buffer basis.

      > Another possibility is to add a new file to the distribution:
      > $VIMRUNTIME/python_matchit.vim . Unlike the current python_matchit.vim,
      > this would define only the Matchit_python() function, not actually remap
      > % . The maintainer of the distribution would have to do this, not the
      > maintainer of the standard ftplugin file. It might be a good thing to
      > have an example in the standard distribution of a plugin with this sort
      > of naming convention.

      This adds a new type of file in a specific place. I don't think this is
      attractive.

      > The only other language I know where this might be useful is TeX.
      > Matchit.vim can bounce between \begin{foo} and \end{foo}, but not
      > between $ and $.

      Others might pop up later, thus if we find a generic solution (without
      disadvantages) that would be good.

      --
      GALAHAD: No. Look, I can tackle this lot single-handed!
      GIRLS: Yes, yes, let him Tackle us single-handed!
      "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

      /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
      /// Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
      \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
      \\\ Buy at Amazon and help AIDS victims -- http://ICCF.nl/click1.html ///
    • Charles E. Campbell, Jr.
      ... With a function, highlighting can be used to help with figuring out what the matching pair is, too (see
      Message 2 of 11 , Sep 3 8:42 AM
        Benji Fisher wrote:

        >
        >...Currently, the only
        >customization for different file types is that matchit.vim looks for a
        >list of regular expressions (usually defined in the ftplugin file) that
        >define matching pairs. I suppose the simplest thing to do would be to
        >look for a function like Matchit_python(); if the function exists and
        >returns a non-zero value, then use it to decide where to jump;
        >otherwise, continue as normal.
        >

        With a function, highlighting can be used to help with figuring out what
        the matching pair
        is, too (see http://vim.sourceforge.net/scripts/script.php?script_id=848
        for something related).

        Regards,
        Chip Campbell
      • Benji Fisher
        ... Yes, matchit already uses synID() and related functions in order to skip quotes( and //comments) . I guess I should not have written only in the bit
        Message 3 of 11 , Sep 6 7:28 AM
          On Fri, Sep 03, 2004 at 11:42:14AM -0400, Charles E. Campbell, Jr. wrote:
          > Benji Fisher wrote:
          >
          > >
          > >...Currently, the only
          > >customization for different file types is that matchit.vim looks for a
          > >list of regular expressions (usually defined in the ftplugin file) that
          > >define matching pairs. I suppose the simplest thing to do would be to
          > >look for a function like Matchit_python(); if the function exists and
          > >returns a non-zero value, then use it to decide where to jump;
          > >otherwise, continue as normal.
          >
          > With a function, highlighting can be used to help with figuring out what
          > the matching pair
          > is, too (see http://vim.sourceforge.net/scripts/script.php?script_id=848
          > for something related).

          Yes, matchit already uses synID() and related functions in order to
          skip "quotes(" and //comments) . I guess I should not have written
          "only" in the bit quoted above.

          :help matchit-configure

          --Benji Fisher
        Your message has been successfully submitted and would be delivered to recipients shortly.