Repository: neovim/neovim
File: test/functional/core/startup_spec.lua (Lua)

Code before:
    local file1, file2 = 'Xargf_file1', 'Xargf_file2'
    write_file(file1, '')
    write_file(file2, '')
    files = { file1, file2 }

    local abs1 = fn.fnamemodify(file1, ':p')
    local abs2 = fn.fnamemodify(file2, ':p')

    local p =
      n.spawn_wait('--cmd', 'echo v:argf', '-c', 'qall', file1, file2, 'https://example.com')

    eq(0, p.status)
    matches(pesc(abs1), p.stderr)
    matches(pesc(abs2), p.stderr)
  end)

  it('handles -- separator correctly', function()
    local file1, file2 = 'Xargf_sep1', 'Xargf_sep2'
    write_file(file1, '')
    write_file(file2, '')
    files = { file1, file2 }

    local abs1 = fn.fnamemodify(file1, ':p')
    local abs2 = fn.fnamemodify(file2, ':p')

    local p = n.spawn_wait('--cmd', 'echo v:argf', '-c', 'qall', '--', file1, file2)

    eq(0, p.status)
    matches(pesc(abs1), p.stderr)
    matches(pesc(abs2), p.stderr)
  end)

  it('is read-only', function()
    matches('E46', t.pcall_err(command, "let v:argf = ['foo']"))
  end)
end)


Review comment (suggestion):
Let's also add a file *before* the `--` part here, so that we test the case where files appear in both positions. Or is that tested already that I missed?
```suggestion
    local p = n.spawn_wait(file1, '--cmd', 'echo v:argf', '-c', 'qall', '--', file2, file3)
```

Code after:
      table.concat({ plugin_folder_path, 'plugin.vim' }, pathsep),
      [[
        let &runtimepath = &runtimepath
        let g:vim_plugin = 1
      ]]
    )
    write_file(
      table.concat({ plugin_folder_path, 'plugin.lua' }, pathsep),
      [[
        vim.o.runtimepath = vim.o.runtimepath
        vim.g.lua_plugin = 1
      ]]
    )

    clear { args_rm = { '-u' }, args = { '--cmd', 'packloadall' }, env = xenv }

    eq(1, eval('g:vim_plugin'))
    eq(1, eval('g:lua_plugin'))
  end)

  it("loads ftdetect/*.{vim,lua} respecting 'rtp' order", function()
    local rtp_folder = table.concat({ xconfig, 'nvim' }, pathsep)
    local after_rtp_folder = table.concat({ rtp_folder, 'after' }, pathsep)
    local ftdetect_folder = table.concat({ rtp_folder, 'ftdetect' }, pathsep)
    local after_ftdetect_folder = table.concat({ after_rtp_folder, 'ftdetect' }, pathsep)
    mkdir_p(ftdetect_folder)
    mkdir_p(after_ftdetect_folder)
    finally(function()
      rmdir(ftdetect_folder)
      rmdir(after_ftdetect_folder)
    end)
    write_file(table.concat({ rtp_folder, 'scripts.vim' }, pathsep), [[let g:aseq ..= 'S']])
    write_file(table.concat({ after_rtp_folder, 'scripts.vim' }, pathsep), [[let g:aseq ..= 's']])
    -- A .lua file is loaded after a .vim file if they only differ in extension.
    -- All files in after/ftdetect/ are loaded after all files in ftdetect/.
    write_file(
      table.concat({ ftdetect_folder, 'new-ft.vim' }, pathsep),
      [[
        let g:seq ..= 'A'
        autocmd BufRead,BufNewFile FTDETECT let g:aseq ..= 'A'
      ]]
    )
    write_file(
      table.concat({ ftdetect_folder, 'new-ft.lua' }, pathsep),
      [[
        vim.g.seq = vim.g.seq .. 'B'
        vim.api.nvim_create_autocmd({ 'BufRead', 'BufNewFile' }, {
          pattern = 'FTDETECT',
          command = "let g:aseq ..= 'B'",
        })
      ]]