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

Re: using syntax keywords for completion [patch]

Expand Messages
  • Bram Moolenaar
    ... This sounds like half a solution is better than no solution . Although that s true, my experience is that after using it for a while users want a
    Message 1 of 8 , May 25, 2002
    • 0 Attachment
      David Necas wrote:

      > On Sun, May 19, 2002 at 05:26:50PM +0200, Bram Moolenaar wrote:
      > >
      > > A few comments from my side:
      > >
      > > - I like the idea of completing keywords, but obtaining them from the
      > > syntax might not be the best way to do it. Why not specifically
      > > define a list of words that can be completed, so that it also works
      > > when syntax highlighting is off, or not all keywords are highlighted.
      > > This list could be defined in the filetype plugin.
      >
      > Using syntax keywords has the advantage one gets quite a
      > usable set of words even when there's nobody to maintain
      > some special keyword list (that's why I made it!).
      > Moreover, I don't like the idea there were two almost
      > identical keyword sets which have to be maintained
      > seperately. When it cannot be generated automatically, it
      > simply doesn't worth doing at all.

      This sounds like "half a solution is better than no solution". Although
      that's true, my experience is that after using it for a while users want
      a complete solution. Being able to complete only some of the keywords,
      and not offering a possibility to make the list complete will lead to
      frustration.

      > The best thing I could think up was adding `nocomplete' flag
      > to `:syn keyword' and something like `:syn complete' to
      > define keywords used exclusively for completion. This would
      > keep the keywords in one file. It however doesn't help when
      > syntax highlighting is off.

      I don't like the interdependence of completion and syntax file. The
      syntax file maintainer doesn't want to keep the completion in mind,
      someone who does completion doesn't want to know about how syntax
      highlighting works (and it's quite complicated, you can't just add a few
      keywords there without taking the risc that something breaks, some
      keywords are found with a match item for that reason).

      > > - The code for Insert mode completion already is quite messy. It needs
      > > to be cleaned up before adding new stuff.
      > >
      > > - There should also be a CTRL-X key sequence to trigger this
      > > completion, for when 'y' is not included in 'complete'.
      >
      > This is easy to add, but concerning the previous point,
      > should I wait with any patches until the Ins mode completion
      > code is cleaned?

      Or start working on it! :-)

      --
      hundred-and-one symptoms of being an internet addict:
      56. You leave the modem speaker on after connecting because you think it
      sounds like the ocean wind...the perfect soundtrack for "surfing the net".

      /// Bram Moolenaar -- Bram@... -- http://www.moolenaar.net \\\
      /// Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim \\\
      \\\ Project leader for A-A-P -- http://www.a-a-p.org ///
      \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///
    • Yeti
      ... That s sad. In fact, what you suggest is what I originally started with and using syntax files directly in Vim I considered an improvement and maybe the
      Message 2 of 8 , May 26, 2002
      • 0 Attachment
        On Sat, May 25, 2002 at 01:27:30PM +0200, Bram Moolenaar wrote:
        >
        > I don't like the interdependence of completion and syntax file.

        That's sad. In fact, what you suggest is what I originally
        started with and using syntax files directly in Vim
        I considered an improvement and maybe the best idea of it
        all.

        > The
        > syntax file maintainer doesn't want to keep the completion in mind,
        > someone who does completion doesn't want to know about how syntax
        > highlighting works (and it's quite complicated, you can't just add a few
        > keywords there without taking the risc that something breaks, some
        > keywords are found with a match item for that reason).

        Frankly speaking, I can't imagine syntax file and completion
        file maintainers to be different people. This would
        definitely lead to user frustration from not getting all
        keywords completed, too (or not getting highlighted some
        completable words). As a maintainer of 10+ syntax files
        I can say it would made me upset to maintain the same
        information twice, and I would automate the completion file
        generation as the first thing anyway.

        Also I want the keyword completion to work for every
        language I use, once implemented, so I would have to become
        maintainer of 30 or so completion files (if not officially,
        then for personal use) -- which I don't like either.

        Well, this is just vain whining, it's clear you don't like
        using syntax files for completion and I don't like having
        separate files; moreover I have a working patch I'm
        satisfied with and thus no motivation to do it
        differently... so let it be.

        Yeti
      • Vince Negri
        Given that an item already in the todo list is to add a command (say, keywords add ) which adds words to the completion list (and presumably this is the
        Message 3 of 8 , May 27, 2002
        • 0 Attachment
          Given that an item already in the todo list is to
          add a command (say, "keywords add") which adds words
          to the completion
          list (and presumably this is the command which would
          be used in a separate no-syntax-highlighting keyword
          file), the way forward (not necessarily for you David,
          but for anyone reading) might be to at the same
          time create a command ":keywords syntax <n>" which
          adds all keyword matches of length n or greater in the
          currently-defined syntax to the completion list.
          (Since you don't really want short keywords like "if"
          to clutter the completion list)

          This doesn't remove the need for a list for non
          syntax-highlighting users, but if such a list doesn't
          exist the syntax-highlighting user can use the
          ":keywords syntax" command as a rough-and-ready
          kickstart, e.g. in their personal filetype plugin.

          P.S. David, even though you don't want to change
          your patch you could still help to clean up the
          insert-mode completion code which would be beneficial
          to all parties.
        • Benji Fisher
          ... [snip] Why not add (1) a mechanism to do completion from a list (2) a mechanism to parse the syntax file. Then the user could take advantage of the syntax
          Message 4 of 8 , May 28, 2002
          • 0 Attachment
            On Saturday, May 25, 2002, at 07:27 AM, Bram Moolenaar wrote:

            >
            > David Necas wrote:
            >
            >> On Sun, May 19, 2002 at 05:26:50PM +0200, Bram Moolenaar wrote:
            >>>
            >>> A few comments from my side:
            >>>
            >>> - I like the idea of completing keywords, but obtaining them from the
            >>> syntax might not be the best way to do it. Why not specifically
            >>> define a list of words that can be completed, so that it also works
            >>> when syntax highlighting is off, or not all keywords are
            >>> highlighted.
            >>> This list could be defined in the filetype plugin.
            >>
            >> Using syntax keywords has the advantage one gets quite a
            >> usable set of words even when there's nobody to maintain
            >> some special keyword list (that's why I made it!).
            >> Moreover, I don't like the idea there were two almost
            >> identical keyword sets which have to be maintained
            >> seperately. When it cannot be generated automatically, it
            >> simply doesn't worth doing at all.
            >
            > This sounds like "half a solution is better than no solution". Although
            > that's true, my experience is that after using it for a while users want
            > a complete solution. Being able to complete only some of the keywords,
            > and not offering a possibility to make the list complete will lead to
            > frustration.
            [snip]

            Why not add

            (1) a mechanism to do completion from a list
            (2) a mechanism to parse the syntax file.

            Then the user could take advantage of the syntax file and still have the
            flexibility of getting something better. There should be a way to
            remove words from, as well as add them to, the completion list. The
            second item could be done internally or with a vim script.

            --Benji Fisher
          • Yeti
            ... Creating :keywords syntax sounds like a good approach, it can even keep the case information from syntax file (so case-insensitive words can be
            Message 5 of 8 , Jun 8, 2002
            • 0 Attachment
              On Mon, May 27, 2002 at 08:39:06AM +0100, Vince Negri wrote:
              > Given that an item already in the todo list is to
              > add a command (say, "keywords add") which adds words
              > to the completion
              > list (and presumably this is the command which would
              > be used in a separate no-syntax-highlighting keyword
              > file), the way forward (not necessarily for you David,
              > but for anyone reading) might be to at the same
              > time create a command ":keywords syntax <n>" which
              > adds all keyword matches of length n or greater in the
              > currently-defined syntax to the completion list.
              > (Since you don't really want short keywords like "if"
              > to clutter the completion list)

              Creating ":keywords syntax <n>" sounds like a good approach,
              it can even keep the case information from syntax file (so
              case-insensitive words can be completed ignoring case,
              and case-sensitive matching case, like with my patch) but
              syntax files contain even more information -- I could
              imagine that only keywords allowed in given context (in
              syntax file, or, if you like, in completion file) would be
              suggested for completion (this may or may not work depending
              on language and syntax/completion file philosophy, but it
              would work for some languages, at least). This effect cannot
              be achieved with simple keyword lists -- and the more
              information you put in the completion files, the more they
              will ressemble syntax files...

              > P.S. David, even though you don't want to change
              > your patch you could still help to clean up the
              > insert-mode completion code which would be beneficial
              > to all parties.

              Unfortunately I'm sure Bram has completely different view of
              what such a clean-up should consist of than me ;-) But
              maybe I'll try in spite of it.

              Yeti
            Your message has been successfully submitted and would be delivered to recipients shortly.