@dzaima You can use vim slime with tmux to achieve this effect
Install vim slime using vundle, or your favorite package manager for vim, or manually
open tmux, and then split the panes into 2
in one of the panes open k repl, in the other open your vim editor with vim slime installed
now over any k text in your vim editor, press Ctrl-C Ctrl-C, it will prompt you for what screen you want to use, say tmux, then press .1 (as .1 is your repl pane), the text will be sent to your repl pane through tmux
Although, @ngn still for whatever reason your K vim plugin conflicts with my tmux hotkeys :C
@meyt4r iirc, k3 was the last version of k that had any (even if partial) support for closures. ngn/k, being an imitation of k6, doesn't have them. i think closures are an elegant and natural concept but i don't see a way to implement them without also introducing major problems complexity, speed, and compatibility.
@meyt4r when i need access to a variable from the outer scope, i usually either do like you did - introduce a global, or add an extra parameter to the inner function and curry the value there - something like choose:{[a;s] fail{[s;x;y] :[err x;y s;x]}[s]/a}. the latter works only for read-only closures.
also, surprisingly often there's a way to rewrite the code so it doesn't require closures at all