mirror of
https://github.com/neovim/neovim.git
synced 2024-12-29 14:41:06 -07:00
45549f031e
Problem: When "-l" is followed by "--", we stop sending args to the Lua script and treat "--" in the usual way. This was for flexibility but didn't have a strong use-case, and has these problems: - prevents Lua "-l" scripts from handling "--" in their own way. - complicates the startup logic (must call nlua_init before command_line_scan) Solution: Don't treat "--" specially if it follows "-l".
36 lines
690 B
Lua
36 lines
690 B
Lua
-- Test "nvim -l foo.lua …"
|
|
|
|
local function printbufs()
|
|
local bufs = ''
|
|
for _, v in ipairs(vim.api.nvim_list_bufs()) do
|
|
local b = vim.fn.bufname(v)
|
|
if b:len() > 0 then
|
|
bufs = ('%s %s'):format(bufs, b)
|
|
end
|
|
end
|
|
print(('bufs:%s'):format(bufs))
|
|
end
|
|
|
|
local function parseargs(args)
|
|
local exitcode = nil
|
|
for i = 1, #args do
|
|
if args[i] == '--exitcode' then
|
|
exitcode = tonumber(args[i + 1])
|
|
end
|
|
end
|
|
return exitcode
|
|
end
|
|
|
|
local function main()
|
|
printbufs()
|
|
print('nvim args:', #vim.v.argv)
|
|
print('lua args:', vim.inspect(_G.arg))
|
|
|
|
local exitcode = parseargs(_G.arg)
|
|
if type(exitcode) == 'number' then
|
|
os.exit(exitcode)
|
|
end
|
|
end
|
|
|
|
main()
|