!HCjHPBLFfoFpYNgwdE:matrix.org

Neovim dev

209 Members
Discussion about Neovim development and adjacent topics14 Servers

Load older messages


SenderMessageTime
1 Nov 2024
@clason:matrix.orgclasonyeah, then the value proposition is much lower14:50:38
@clason:matrix.orgclasonprobably not worth it14:50:44
@clason:matrix.orgclasonbetter approach would be to improve the bridge for tables (in C) along Justin's proposal14:51:23
@clason:matrix.orgclasonthreads and userdata are very low priority14:51:35
@lewis6991:matrix.orglewis6991

Breaking changes will occur with general tables.

No bueno

14:51:46
@ofseed:matrix.orgYi
threads and userdata are very low priority
The main purpose is tables (with metatables). userdata, and threads are supported as a sideline
14:54:18
@clason:matrix.orgclasonyeah, but then a more targeted approach is appropriate 14:54:43
@ofseed:matrix.orgYi
No bueno
Even now it cannot be used directly, so I think it maybe reasonable
https://github.com/neovim/neovim/blob/7bf3a616e18205d353d9c4a44e8c2f885d700129/runtime/doc/lua.txt#L1227-L1238
14:58:23
@clason:matrix.orgclason

In a nutshell:

  1. adding a separate API is unacceptable
  2. breaking the current API for tables is unacceptable
14:58:27
@clason:matrix.orgclasonthese two things are not up for discussion14:58:37
@clason:matrix.orgclasonwhich means the way forward needs to be in C14:59:06
@ofseed:matrix.orgYiThis breaking change may not happen; I will reimplement it tomorrow (leaving time for discussion)14:59:49
@lewis6991:matrix.orglewis6991The only acceptable breaking change is that variables created in Lua are readonly to vimscript.15:04:22
@lewis6991:matrix.orglewis6991So it will be breaking no matter what15:04:30
@ofseed:matrix.orgYi To clarify further:

The breaking change I mentioned is that the table created in vimscript using vim.b.foo can no longer be accessed in the same way as before (though there are still other read-only ways). The reason is that vim.b no longer attempts to convert Lua tables into Vimscript dictionaries, but instead saves them directly as Lua variables. This breaking change could be avoided, but IMHO the necessity of maintaining it is not very significant, because:

  1. A Vimscript dictionary cannot contain both integer and string keys at the same time.


  1. Vimscript dictionaries cannot contain metatables.


  1. Even if the created table is a regular table, it may still have keys with values that correspond to the two situations mentioned above.


In simple terms, there must be Lua tables that cannot be completely converted into Vimscript dictionaries, even if implemented in C.

Moreover, even though we can access dictionaries like b:foo using vim.b.foo now, it returns a copy, which means using vim.b.foo.bar = "value" is always a meaningless operation; it will not change b:foo.bar or anything else, which contradicts the idea of broadly using this API in Lua. So if a separate API for Lua variables(like what this PR does) is not added, this behavior will and should be broken.
16:37:56
@clason:matrix.orgclason Yeah, that would be too breaking. Sorry. 16:38:23
@clason:matrix.orgclasonit need not be broken if the conversion layer in C is extended16:38:51
@clason:matrix.orgclasonso this is the (one) way to do it16:39:00
@clason:matrix.orgclason The deal breaker is changing the behavior for tables that can be represented as dictionaries 16:39:43
@clason:matrix.orgclasonthat is simply not acceptable16:40:49
@ofseed:matrix.orgYi
The deal breaker is changing the behavior for tables that can be represented as dictionaries
Definitely, but it may not be worth it
16:42:06
@ofseed:matrix.orgYi But I am not creating a problem and then trying to solve it. We do already have a mechanism for managing buffer-level variables, and my goal is to avoid it being invented over and over again and bugs being fixed repeatedly. 16:44:50
@ofseed:matrix.orgYi Any refactoring that unifies this mechanism without using vim.b can be seen as adding a separate API, which is unacceptable, as you said. 16:45:53
@clason:matrix.orgclasonBut the crux here is that there is already a plan for how this should be done, and you're deviating from it.16:46:58
@clason:matrix.orgclasonif your proposal was the only way to do that, things would be different -- but that's not the case.16:47:52
@clason:matrix.orgclasonSo we'd rather hold out for a proper solution, all things considered.16:48:06
@ofseed:matrix.orgYiI think I have outlined several solutions here. The first is a standalone API (the code currently in the PR), the second would introduce a breaking change (it's easy to change but not implemented, and I discussed the issues it would bring here). I also have a third idea that tries to avoid breaking changes as much as possible, but it may have issues in terms of implementation, so I will demonstrate it later through code.17:00:20
@ofseed:matrix.orgYi
So we'd rather hold out for a proper solution, all things considered.
This is what I am doing, because I won't know if it is acceptable before I express my first and second solution.
17:02:44
@lewis6991:matrix.orglewis6991It sounds like you are trying to shy away from making any changes in C and making a Lua only solution? If so, I don't think the read-only aspect for vimscript will be that hard.17:03:38
@clason:matrix.orgclason
In reply to @ofseed:matrix.org
I think I have outlined several solutions here. The first is a standalone API (the code currently in the PR), the second would introduce a breaking change (it's easy to change but not implemented, and I discussed the issues it would bring here). I also have a third idea that tries to avoid breaking changes as much as possible, but it may have issues in terms of implementation, so I will demonstrate it later through code.
looking forward to it then
17:10:43

Show newer messages


Back to Room ListRoom Version: 10