Skip to content
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

Support passing argument to lua functions #394

Closed
sayanarijit opened this issue Nov 1, 2021 · 2 comments · Fixed by #401 or #424
Closed

Support passing argument to lua functions #394

sayanarijit opened this issue Nov 1, 2021 · 2 comments · Fixed by #401 or #424

Comments

@sayanarijit
Copy link
Owner

Implement something like CallLuaWithArg, using which, users can pass arguments to the Lua functions. Being able to pass one argument should be enough. Serde Value should support this.

@sayanarijit
Copy link
Owner Author

sayanarijit commented Nov 1, 2021

Also, research and probably implement something like this:

From matrix chat:

can i run inline-lua-code in messages? like

CallLuaSilently = 'xplr.context.switch = 2'

similar to BashExec but maybe LuaExec

sayanarijit added a commit that referenced this issue Nov 5, 2021
This PR adds support for quickly executing arbitrary lua functions,
without needing to define a function.

Example:

```lua
xplr.config.modes.builtin.default.key_bindings.on_key["#"] = {
  help = "test",
  messages = {
    { LuaEvalSilently = [[return { { LogInfo = "foo" } }]] },
    { LuaEval = [[return { { LogInfo = io.read() } }]] },
  },
}
```

Partly closes: #394
sayanarijit added a commit that referenced this issue Nov 5, 2021
This PR adds support for quickly executing arbitrary lua functions,
without needing to define a function.

Example:

```lua
xplr.config.modes.builtin.default.key_bindings.on_key["#"] = {
  help = "test",
  messages = {
    { LuaEvalSilently = [[return { { LogInfo = "foo" } }]] },
    { LuaEval = [[return { { LogInfo = io.read() } }]] },
  },
}
```

Partly closes: #394
sayanarijit added a commit that referenced this issue Nov 5, 2021
This PR adds support for quickly executing arbitrary lua functions,
without needing to define a function.

Example:

```lua
xplr.config.modes.builtin.default.key_bindings.on_key["#"] = {
  help = "test",
  messages = {
    { LuaEvalSilently = [[return { { LogInfo = "foo" } }]] },
    { LuaEval = [[return { { LogInfo = io.read() } }]] },
  },
}
```

Partly closes: #394
@sayanarijit
Copy link
Owner Author

I have implemented LuaEval and LuaEvalSilently, but passing arguments seems not so easy. Keeping this open in case someone else is interested.

@sayanarijit sayanarijit reopened this Nov 5, 2021
sayanarijit added a commit that referenced this issue Dec 11, 2021
If the argument of `LuaEval` evaluates to a function, xplr will try to
pass Lua Context to it.

Example:

```lua
{ LuaEval = [[function(app) return { { LogInfo = app.pwd } } end]] }
```

Closes: #394
sayanarijit added a commit that referenced this issue Dec 11, 2021
If the argument of `LuaEval` evaluates to a function, xplr will try to
pass Lua Context to it.

Example:

```lua
{ LuaEval = [[function(app) return { { LogInfo = app.pwd } } end]] }
```

Closes: #394
sayanarijit added a commit that referenced this issue Dec 11, 2021
If the argument of `LuaEval` evaluates to a function, xplr will try to
pass Lua Context to it.

Example:

```lua
{ LuaEval = [[function(app) return { { LogInfo = app.pwd } } end]] }
```

Closes: #394
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant