neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

startup.lua (690B)


      1 -- Test "nvim -l foo.lua …"
      2 
      3 local function printbufs()
      4  local bufs = ''
      5  for _, v in ipairs(vim.api.nvim_list_bufs()) do
      6    local b = vim.fn.bufname(v)
      7    if b:len() > 0 then
      8      bufs = ('%s %s'):format(bufs, b)
      9    end
     10  end
     11  print(('bufs:%s'):format(bufs))
     12 end
     13 
     14 local function parseargs(args)
     15  local exitcode = nil
     16  for i = 1, #args do
     17    if args[i] == '--exitcode' then
     18      exitcode = tonumber(args[i + 1])
     19    end
     20  end
     21  return exitcode
     22 end
     23 
     24 local function main()
     25  printbufs()
     26  print('nvim args:', #vim.v.argv)
     27  print('lua args:', vim.inspect(_G.arg))
     28 
     29  local exitcode = parseargs(_G.arg)
     30  if type(exitcode) == 'number' then
     31    os.exit(exitcode)
     32  end
     33 end
     34 
     35 main()