Re: Access vim command from the lua end WAS: How do the default key commands work

2011-01-31 Thread Marco
On 2011-01-31 Ben Schmidt  wrote:

> > So I rephrase my question. How to access basic vim commands (here: %) from
> > inside lua? How to access an arbitrary vim function from inside lua?
> 
> Use the :normal command (probably with ! to avoid using user mappings).
> E.g.
> 
> :lua vim.command"normal! %"
> 
> Then to get the cursor position, you can use the getpos() function. E.g.
> 
> :lua mypos = vim.eval"getpos('.')"
> 

Thank you very much.

Marco


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


Re: Access vim command from the lua end WAS: How do the default key commands work

2011-01-30 Thread Ben Schmidt

It's not about remapping. I'm writing a vimscript in lua. In a function I need
the position of the opening and closing bracket. So in vim I would execute »%«
twice. Than I have both positions. If there would be functions for the basic
comands I just would execute the corresponding function. But apparently this
is not the case.

So I rephrase my question. How to access basic vim commands (here: %) from
inside lua? How to access an arbitrary vim function from inside lua?


Use the :normal command (probably with ! to avoid using user mappings).
E.g.

:lua vim.command"normal! %"

Then to get the cursor position, you can use the getpos() function. E.g.

:lua mypos = vim.eval"getpos('.')"

Or something like that (I don't know Lua, and don't have the interface
compiled in, so haven't tested; but this is the idea).

Smiles,

Ben.





vim 7.3  compiled with lua interpreter


Regards
Marco




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


Re: Access vim command from the lua end WAS: How do the default key commands work

2011-01-30 Thread Marco
On 2011-01-30 Tim Chase  wrote:

> If you want a catalog of the functionality, you can look at 
> things like
>
> [...]
>
> or more generically:
> 
>:h index.txt  

Nice list I didn't know before.

> They're available "natively" from within a "noremap" version of a 
> mapping.  So if you want to swap the functionality of "j" and "k" 
> (wow, that would get annoying, but it's a good example), you can use
> 
>:nnoremap j k
>:nnoremap k j
> 
> If you didn't use the "nore" version, then the 2nd one would 
> produce a recursive mapping:
> 
>:nmap j k   " now both j & k act like k
>:nmap k j   " now k calls j calls k calls j calls k...boom
> 
> Hope this makes sense.  There's no underlying function (like I 
> understand Emacs has) accessible to which keys can be rebound.  

Thanks for the explanation.

It's not about remapping. I'm writing a vimscript in lua. In a function I need
the position of the opening and closing bracket. So in vim I would execute »%«
twice. Than I have both positions. If there would be functions for the basic
comands I just would execute the corresponding function. But apparently this
is not the case.

So I rephrase my question. How to access basic vim commands (here: %) from
inside lua? How to access an arbitrary vim function from inside lua?

vim 7.3  compiled with lua interpreter


Regards
Marco


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