File: startup.lua

package info (click to toggle)
neovim 0.11.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 64,140 kB
  • sloc: ansic: 263,427; python: 1,472; lisp: 1,237; sh: 1,138; makefile: 383; xml: 84; ruby: 6
file content (35 lines) | stat: -rw-r--r-- 690 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
-- 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()