New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lua interface #4411
Lua interface #4411
Conversation
Blocked by #4131: I think I can reuse
(you may need to increase number inside |
What do RPC client authors need to know in order to migrate after #4131, if anything? If we can provide clear answers to that, then I say just merge it. |
Will this bring along with it the functionality generally required for |
@ianks Look at the TODO list. |
@justinmk Where I should place notes regarding migration? Also there is still unresolved question with |
@ZyX-I I'm speaking of #4131 the JSON PR. I haven't had time to fully understand the implications of the
Oh. Ok, I will try to offer an opinion on it in the next days. |
I did. I just don't know enough about Neovim internals to know what it all means. |
Because I got no replies whether it is the right path. |
@ianks Answer is "yes", mostly, though I am curious about how userdata will be handled, if at all. (I'm not opposed to including lua/luajit in-process for |
At the current state differences are minor:
1 and 2 should not break much, but 3 and any way to fix problem in 4 I can imagine will break some functionality. @justinmk I always said that I am planning to be compatible with lua without jit. |
@justinmk Also note the branch name. I thought it is good idea to break |
I would like for Lua to be able to add built-in functions to NeoVIM. |
718fd46
to
7432f97
Compare
@justinmk Last commit adds |
What is the ReferenceDef interface for? Is it the different viml container/function types, or do we imagine even more different reference kinds? |
@bfredl For different types. Specifically for deeper integration between languages, I wanted something like this for Vim: to be able to use Python functions or containers directly from Ruby etc. At a cost of converting Python types to VimL and only then to Ruby, of course. In the current state using Python objects in Ruby is probably not the best idea (too many IPC calls: first from Ruby to Neovim, then from Neovim to Python, then sending replies back through this chain), though still applicable for some uses. But this allows adding things like partials with no changes on the client side. I also considered adding And another idea: make functions like I would also ask whether anybody actually wants |
We could avoid the extra roundtrip by allowing the client construct the scope reference ( have an EXT type such that the object EXT can be converted to the scope EXT by a client) |
@bfredl I do not think this is a good idea:
|
As I said before, I don't mean client constructable named references to replace (parts of) your proposal. These will be converted to References early in the request dispatch logic. No bookkeeping, just a one-shot |
@bfredl I think this is a good idea. Though I would not add it here, such references are not needed for lua interface. |
@ZyX-I Regarding the compatibility question:
We could use a similar approach as in #4083 (6eda7c0): create new functions and deprecate the old ones. But I think we can break back-compat here.
Last time we made a breaking change to the API I just notified client/plugin authors to be aware of the change, and it worked out ok. We can still use this approach, though #4083 and more explicit versioning will be required when Neovim gets more popular. |
Why does it exist then? I can simply make set and del void, this will avoid lots of unnecessary allocs/frees on both sides of the channel. For backward compatibility I know the following approaches that are applicable here:
Points 3 and 4 may also have an addition “older version is removed in next major release”. I do not remember API compatibility being discussed somewhere: did I miss some issue or should it be a new one? |
I can't think of a reason why it would be needed, maybe @tarruda can comment.
I suggest we take this approach as far as we can because it is the least clever. "Versioned channels" would be the next step. #1393 may be used to discuss API compatibility/versioning, though that issue regards "middleware" versions and not the |
Another approach is: adding new parameters with default values for old clients that don't supply it. Though it is probably overblown for this case. It might be useful for a rplugin to say get and delete a key atomically, but this is probably better served either by a general concept of atomic transactions
implemented correctly this could even be streamed (only one roundtrip needed). |
@bfredl This approach is rather limited which is why I did not list it:
I think that the idea of atomic requests (not transactions) can be implemented with the current code rather easily: just make an API call which will receive list of pairs |
Well it will work with a new nvim with a client either statically generated for the old api info, or a client doing no checking to the metadata (like python), but versioned/deprecated functions as your suggestions will definitely scale better when things get Sufficiently Complicated (which they will).
This would be very useful, for sure. |
Any thoughts on having a Lua API call to construct Lua-implemented functions and commands? |
It appears that I have a bug in
|
Got same hang again in QB:
|
If you did not merge 7c1a5d1 into this PR that would explain the hang. It's not related to this PR. See #6644 (comment) |
Other then QB, build successfull. |
|
|
@prabirshrestha, @Shougo I think the |
OK. |
I get this warning presumably from this PR:
|
Wondering how did that manage to pass CI. |
Different compiler versions? |
Yes, but this is one of the basic warnings. I am surprised how much of compilers we are using did not show it: starting from clang 3.9.1 (on my system) and proceeding with all those CI compilers compiling debug mode. |
@@ -309,6 +309,14 @@ include_directories(SYSTEM ${LIBUV_INCLUDE_DIRS}) | |||
find_package(Msgpack 1.0.0 REQUIRED) | |||
include_directories(SYSTEM ${MSGPACK_INCLUDE_DIRS}) | |||
|
|||
option(PREFER_LUAJIT "Prefer LuaJIT over Lua when compiling executable. Test library always uses luajit." ON) | |||
|
|||
find_package(LuaJit REQUIRED) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I don't care to run tests, then this REQUIRED
prevents me from being able to use cmake -DPREFER_LUAJIT=OFF
to simply build nvim with Lua, doesn't it? Shouldn't we instead avoid creating the relevant test targets if luajit isn't available?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be what's causing our nightly builds to fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to just switch the PPA to LuaJIT, but unfortunately LuaJIT is not supported on ARM64. Opened #6736.
return 0; | ||
nlua_print_error: | ||
emsgf(_("E5114: Error while converting print argument #%i: %.*s"), | ||
curargidx, errmsg_len, errmsg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Length argument should be of type int: errmsg_len
-> (int)errmsg_len
, otherwise macros va_*()
parse the parameter list wrong.
As reported by @Shougo , @prabirshrestha I'm on macOS 12.4 and My vim version
|
0.2.0 doesn't have lua, you need 0.2.1-dev (master) |
@bfredl Thanks :) |
FEATURES: 0e873a3 Lua(Jit) built-in neovim#4411 5b32bce Windows: `:terminal` neovim#7007 7b0ceb3 UI/API: externalize cmdline neovim#7173 b67f58b UI/API: externalize wildmenu neovim#7454 b23aa1c UI: 'winhighlight' neovim#6597 17531ed UI: command-line coloring (`:help input()-highlight`) neovim#6364 244a1f9 API: execute lua directly from the remote api neovim#6704 45626de API: `get_keymap()` neovim#6236 db99982 API: `nvim_get_hl_by_name()`, `nvim_get_hl_by_id()` neovim#7082 dc68538 menu_get() function neovim#6322 9db42d4 :cquit : take an error code argument neovim#7336 9cc185d job-control: serverstart(): support ipv6 neovim#6680 1b7a9bf job-control: sockopen() neovim#6594 6efe84a clipboard: fallback to tmux clipboard neovim#6894 6016ac2 clipboard: customize clipboard with `g:clipboard` neovim#6030 3a86dd5 ruby: override ruby host via `g:ruby_host_prog` neovim#6841 16cce1a debug: $NVIM_LOG_FILE neovim#6827 0cba3da `:checkhealth` built-in, validates $VIMRUNTIME neovim#7399 FIXES: 105d680 TUI: more terminals, improve scroll/resize neovim#6816 cb912a3 :terminal : handle F1-F12, other keys neovim#7241 619838f inccommand: improve performance neovim#6949 04b3c32 inccommand: Fix matches for zero-width neovim#7487 60b1e8a inccommand: multiline, other fixes neovim#7315 f1f7f3b inccommand: Ignore leading modifiers in the command neovim#6967 1551f71 inccommand: fix 'gdefault' lockup neovim#7262 6338199 API: bufhl: support creating new groups neovim#7414 541dde3 API: allow K_EVENT during operator-pending 8c732f7 terminal: adjust for 'number' neovim#7440 5bec946 UI: preserve wildmenu during jobs/events neovim#7110 c349083 UI: disable 'lazyredraw' during ui_refresh. neovim#6259 51808a2 send FocusGained/FocusLost event instead of pseudokey neovim#7221 133f8bc shada: preserve unnamed register on restart neovim#4700 1b70a1d shada: avoid assertion on corrupt shada file neovim#6958 9f534f3 mksession: Restore tab-local working directory neovim#6859 de1084f fix buf_write() crash neovim#7140 7f76986 syntax: register 'Normal' highlight group neovim#6973 6e7a8c3 RPC: close channel if stream was closed neovim#7081 85f3084 clipboard: disallow recursion; show hint only once neovim#7203 8d1ccb6 clipboard: performance, avoid weird edge-cases neovim#7193 01487d4 'titleold' neovim#7358 01e53a5 Windows: better path-handling, separator (slash) hygiene neovim#7349 0f2873c Windows: multibyte startup arguments neovim#7060 CHANGES: 9ff0cc7 :terminal : start in normal-mode neovim#6808 032b088 lower priority of 'cursorcolumn', 'colorcolumn' neovim#7364 2a3bcd1 RPC: Don't delay notifications when request is pending neovim#6544 023f67c :terminal : Do not change 'number', 'relativenumber' neovim#6796 1ef2d76 socket.c: Disable Nagle's algorithm on TCP sockets neovim#6915 6720fe2 help: `K` tries Vim help instead of manpage neovim#3104 7068370 help, man.vim: change "outline" map to `gO` neovim#7405
:lua
command:luafile
command:luado
command:lua
tests:lua <<
tests:luafile
tests:luado
testsvim
modulevim
module testsprint
print
testsdebug.debug
(Vim appears to be also overriding this)debug.debug
testsRef #3823