feat(lua)!: execute Lua with "nvim -l"

Problem:
Nvim has Lua but the "nvim" CLI can't easily be used to execute Lua
scripts, especially scripts that take arguments or produce output.

Solution:
- support "nvim -l [args...]" for running scripts. closes #15749
- exit without +q
- remove lua2dox_filter
- remove Doxyfile. This wasn't used anyway, because the doxygen config
  is inlined in gen_vimdoc.py (`Doxyfile` variable).
- use "nvim -l" in docs-gen CI job

Examples:

    $ nvim -l scripts/lua2dox.lua --help
    Lua2DoX (0.2 20130128)
    ...

    $ echo "print(vim.inspect(_G.arg))" | nvim -l - --arg1 --arg2
    $ echo 'print(vim.inspect(vim.api.nvim_buf_get_text(1,0,0,-1,-1,{})))' | nvim +"put ='text'" -l -

TODO?
  -e executes Lua code
  -l loads a module
  -i enters REPL _after running the other arguments_.
This commit is contained in:
Justin M. Keyes
2021-09-20 19:00:50 -07:00
parent 39d70fcafd
commit 7c94bcd2d7
16 changed files with 311 additions and 2784 deletions

View File

@@ -27,14 +27,13 @@ http://search.cpan.org/~alec/Doxygen-Lua-0.02/lib/Doxygen/Lua.pm
Running
-------
This file "lua2dox.lua" gets called by "lua2dox_filter" (bash).
This script "lua2dox.lua" gets called by "gen_vimdoc.py".
Doxygen must be on your system. You can experiment like so:
- Run "doxygen -g" to create a default Doxyfile.
- Then alter it to let it recognise lua. Add the two following lines:
- Then alter it to let it recognise lua. Add the following line:
FILE_PATTERNS = *.lua
FILTER_PATTERNS = *.lua=lua2dox_filter
- Then run "doxygen".
The core function reads the input file (filename or stdin) and outputs some pseudo C-ish language.
@@ -117,26 +116,6 @@ local function string_split(Str, Pattern)
return splitStr
end
--! \class TCore_Commandline
--! \brief reads/parses commandline
local TCore_Commandline = class()
--! \brief constructor
function TCore_Commandline.init(this)
this.argv = arg
this.parsed = {}
this.params = {}
end
--! \brief get value
function TCore_Commandline.getRaw(this, Key, Default)
local val = this.argv[Key]
if not val then
val = Default
end
return val
end
-------------------------------
--! \brief file buffer
--!
@@ -147,7 +126,7 @@ local TStream_Read = class()
--!
--! \param Filename name of file to read (or nil == stdin)
function TStream_Read.getContents(this, Filename)
assert(Filename)
assert(Filename, ('invalid file: %s'):format(Filename))
-- get lines from file
-- syphon lines to our table
local filecontents = {}
@@ -548,15 +527,14 @@ end
local This_app = TApp()
--main
local cl = TCore_Commandline()
local argv1 = cl:getRaw(2)
local argv1 = arg[1]
if argv1 == '--help' then
TCore_IO_writeln(This_app:getVersion())
TCore_IO_writeln(This_app:getCopyright())
TCore_IO_writeln([[
run as:
lua2dox_filter <param>
nvim -l scripts/lua2dox.lua <param>
--------------
Param:
<filename> : interprets filename