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

How can I define a command that can be completed with both var and options?

Expand Messages
  • Christophe-Marie Duquesne
    Hi list, Using :command , I can define a custom command that can be completed ... which will let me complete :Foo from already defined variables. ... which
    Message 1 of 4 , Nov 8, 2010
    • 0 Attachment
      Hi list,

      Using ":command", I can define a custom command that can be completed
      with variables names:
      :com -nargs=* -complete=var Foo call foo(<f-args>)
      which will let me complete :Foo from already defined variables.

      I can also define a command that can be completed with options names:
      :com -nargs=* -complete=option Bar call bar(<f-args>)
      which will let me complete :Bar from vim options

      I want to create a command FooBar that can be completed from both
      options and variables.
      I know I should be using custom completion, with a function like:
      :function {func}(ArgLead, CmdLine, CursorPos)
      returning the list of possible names for completion. What is the
      simplest way to get variables and options in lists in order to return
      them in my completion function?

      Thank you,
      Christophe-Marie

      --
      You received this message from the "vim_dev" 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
    • Christophe-Marie Duquesne
      On Mon, Nov 8, 2010 at 4:33 PM, Christophe-Marie Duquesne ... Did I post this question in the right mailing list? I assumed vim scripts were part of vim
      Message 2 of 4 , Nov 8, 2010
      • 0 Attachment
        On Mon, Nov 8, 2010 at 4:33 PM, Christophe-Marie Duquesne
        <chm.duquesne@...> wrote:
        > Hi list,
        >
        > Using ":command", I can define a custom command that can be completed
        > with variables names:
        > :com -nargs=* -complete=var Foo call foo(<f-args>)
        > which will let me complete :Foo from already defined variables.
        >
        > I can also define a command that can be completed with options names:
        > :com -nargs=* -complete=option Bar call bar(<f-args>)
        > which will let me complete :Bar from vim options
        >
        > I want to create a command FooBar that can be completed from both
        > options and variables.
        > I know I should be using custom completion, with a function like:
        > :function {func}(ArgLead, CmdLine, CursorPos)
        > returning the list of possible names for completion. What is the
        > simplest way to get variables and options in lists in order to return
        > them in my completion function?
        >
        > Thank you,
        > Christophe-Marie
        >

        Did I post this question in the right mailing list? I assumed vim
        scripts were part of vim development...

        --
        You received this message from the "vim_dev" 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
      • Ingo Karkat
        ... Vim scripting how-to issues belong to vim_use. However, I think your core problem has implications to the Vim implementation (you require an enhancement
        Message 3 of 4 , Nov 9, 2010
        • 0 Attachment
          On 09-Nov-2010 08:37, Christophe-Marie Duquesne wrote:
          > On Mon, Nov 8, 2010 at 4:33 PM, Christophe-Marie Duquesne
          > Did I post this question in the right mailing list? I assumed vim
          > scripts were part of vim development...

          Vim scripting "how-to" issues belong to vim_use. However, I think your core
          problem has implications to the Vim implementation (you require an enhancement
          of the :command that allows combination of completion methods), so this is
          indeed the right list.

          It would help if you could provide further motivation for your need. Why do you
          need this combination? Is this a use case that (many) other script writers could
          face, too, or more of a peculiarity that may be best served by a clumsy
          Vimscript workaround or a candid "sorry, not possible; get over it" response ;-)

          If you could come up with a patch that implements the combination of completion
          methods and post it here, there is a good chance that Bram includes it, assuming
          it is small and clean. If you hope that some other developer will create such a
          patch for you, well, look at the current todo list for perspective...

          -- regards, ingo

          --
          You received this message from the "vim_dev" 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
        • Christophe-Marie Duquesne
          ... That is good to know, thank you. ... I wrote a tiny script that allows to toggle options and variables in a unified way, therefore in my case it would
          Message 4 of 4 , Nov 9, 2010
          • 0 Attachment
            On Tue, Nov 9, 2010 at 9:15 AM, Ingo Karkat <swdev@...> wrote:
            > Vim scripting "how-to" issues belong to vim_use.

            That is good to know, thank you.

            > It would help if you could provide further motivation for your need. Why do you
            > need this combination? Is this a use case that (many) other script writers could
            > face, too, or more of a peculiarity that may be best served by a clumsy
            > Vimscript workaround or a candid "sorry, not possible; get over it" response ;-)

            I wrote a tiny script that allows to toggle options and variables in a
            unified way, therefore in my case it would perfectly make sense to be
            able to mix those two completion methods
            (http://www.vim.org/scripts/script.php?script_id=3295). That said, I
            think there are not many other scripts that would need this feature.

            > If you could come up with a patch that implements the combination of completion
            > methods and post it here, there is a good chance that Bram includes it, assuming
            > it is small and clean.

            I'll have a look at that this afternoon/tomorrow. If I can produce a
            "small and clean" patch, I will submit it. Otherwise, considering the
            peculiarity of the use case, I don't think it is a feature that is
            worth spending time on, so I am definitely not asking anyone on this
            mailing-list to add anything to its TODO list.

            Regards,
            Christophe-Marie

            --
            You received this message from the "vim_dev" 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.