-
Notifications
You must be signed in to change notification settings - Fork 220
Mention vim.api.nvim_call_function #6
Comments
Yeah, it's not clear to me if there are any advantages to using it over One interesting tidbit from the documentation is |
vim.call({func}, {...}) *vim.call()*
Invokes |vim-function| or |user-function| {func} with arguments {...}.
See also |vim.fn|.
Equivalent to:
vim.fn[func]({...}) It is the same. Closing? |
@nanotee If possible, one shall always use vim.cmd or vim.api (because they dont need to be parsed or something). However, you cant call user functions with that. Should I add this to the vim.fn description? |
From what I gathered this is really context dependent, and even then I'd be surprised if the difference was noticeable in most cases. I don't know if this is all that useful to mention in a "getting started" guide |
I forgot that I originally opened this issue 🤦 The difference between It might be useful to mention that if the function is part of the nvim API (i.e., available through
|
This belongs to the advanced guide, as it is a performance optimisation in hot code paths. I am not sure either, if it makes a difference in jitted code imho.
I dont understand. |
I disagree; it's important to know how the different methods relate (e.g., that
The point is that |
@clason Thats true. You can not use internal functions from |
I'd suggest to add the following short notes to https://github.com/nanotee/nvim-lua-guide#vimfnfunction :
|
No, that's not going to happen; Also,
(assuming these exist; i.e., you'd only use a later one if the previous one doesn't exist). |
@clason thats very concise and informative way to put it. It should be added to the guide I think. |
@clason Good enough like this? I would prefer to explain internal functions into the advanced guide, ie for plugin creation. |
Yes, that's good. |
also hint why `vim.call` exists to prevent usage fixes #6
I have finally merged #49, apologies for the delay. Looking at the backtrace for I believe the original issue was about |
from
So I don't know where you'd use that, either -- maybe if you want to do some sort of transformation of vimscript code? That wouldn't be anything for a beginner's guide, though 😆 It's been a hot minute since I opened the issue, so it's hard to recall what precisely was the point of it... I think my original motivation was that there were too many ways of calling vimscript from lua, and I wanted to have a quick overview over the differences (or lack thereof, as it turned out later) between them. I guess "don't worry about As I wrote above, I think it's good to mention all possible ways, even if only to quickly discount some of them -- "don't worry about that" is very useful information ;) |
It would be great, if you could examplify "what extra work" you mean or close the issue. |
In my tests this resulted in 2 extra function calls for I have addressed |
especially the difference to
vim.fn
/vim.call
:so I think you'd always want to use
vim.call
?The text was updated successfully, but these errors were encountered: