mirror of https://github.com/bfredl/nvim-luadev
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
3e27c752e4
The logic is abstracted into the s:luadev_run_operator function that receives the first parameter "visual" to know it should use the visual range. Otherwise work with motions. In this case motions that expand over one line execute code linewise from the start to the end. This makes motions j,k,%,/,? be more ergonomic I believe. |
3 years ago | |
---|---|---|
lua | 4 years ago | |
plugin | 3 years ago | |
LICENSE | 6 years ago | |
README.md | 5 years ago |
README.md
nvim-luadev
This plugins set up a REPL-like environment for developing lua plugins in Nvim.
The :Luadev
command will open an scratch window which will show output from executing lua code.
Use the folllowing mappings to execute lua code:
Binding | Action |
---|---|
<Plug>(Luadev-RunLine) |
Execute the current line |
<Plug>(Luadev-Run) |
in visual mode: execute visual selection |
<Plug>(Luadev-RunWord) |
Eval identifier under cursor, including table.attr |
<Plug>(Luadev-Complete) |
in insert mode: complete (nested) global table fields |
If the code is a expression, it will be evaluated, and the result shown with
inspect.lua
. Otherwise it will be executed as a block of code. A top-level
return
will cause the returned value to be inspected. A bare nil
will not
be shown.
Global print()
is also redirected to the output buffer, but only when executing
code via this plugin. require'luadev'.print(...)
can be used to print to the
buffer from some other context.
Planned features:
- autodetect expression vs statements
- Fix
inspect.lua
to usetostring()
on userdata (done on a local copy) - completion of global names and table attributes (WIP: basic implementation done)
- make
<Plug>(Luadev-Run)
a proper operator - solution for step-wise execution of code with
local
assignments (such as a flag to copy local values to an env) - tracebacks
- interactive debugging
- debug helpers for async callbacks (WIP)