Tuesday, August 17, 2010

Re: how to write omnifunction?

On 17/08/10 08:28, aleCodd wrote:
>
> I would like the items in the popupmenu to be more than simple strings, i
> mean that after i select an item i want the cursor to automatically jump to
> specific locations.
>
> let me give a simple example, from JavaScript:
> when i type:
> document.getEle
> and then
> <c-x><c-o>
> i want it to complete to
> document.getElementById()
> but that is NOT enough, i want the cursor to MOVE<left>, so it will already
> be between the parentheses after i select the completion.
>
> Now, in the help files there is a vague paragraph that implies that
> theoretically this is possible, i mean in insert.txt (line 613)
> it says the following:
> "Note: While completion is active Insert mode can't be used
> recursively.
> Mappings that somehow invoke ":normal i.." will generate an E523
> error."
>
> I mean, it warns against invoking the insert mode recursively, but could it
> be possible in the first place?
> Because in order to invoke the :normal command you must first ESCAPE the
> insert mode, now what is the trick to do that from INSIDE an item of the
> popupmenu?
> if i look in the example (insert.txt line 1059), the res variable is always
> set to a list of "simple" strings that do no more than to complete a string
> but not so much as to complete the magic by jumping the cursor from place to
> place, and in order to do that, you must first ESCAPE the insert mode or to
> let the function interpret the<left><up> etc. inside the strings (as in
> mapping and abbreviations), but can we do that?
>
>
> Thanks in advance for ANY help, please keep in mind that im new to vim so
> that ANY help would be much appreciated.
>
> Alex

Did you try ending your completion text with "\<Left>" e.g. :return
"document.getElementById()\<Left>" (with double quotes and a backslash
before the less-than sign)? (I haven't, so I don't know if it works.)

See
:help expr-quote
:help complete-functions

Best regards,
Tony.
--
"God gives burdens; also shoulders"

Jimmy Carter cited this Jewish saying in his concession speech at the
end of the 1980 election. At least he said it was a Jewish saying; I
can't find it anywhere. I'm sure he's telling the truth though; why
would he lie about a thing like that?
-- Arthur Naiman, "Every Goy's Guide to Yiddish"

--
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

No comments: