summaryrefslogtreecommitdiffstatshomepage
path: root/runtime/lua/vim/_core/exrc.lua
blob: 671ee948de541edb86af0b4542b4cd3877c1224a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
-- For 'exrc' and related functionality.

local files = vim.fs.find({ '.nvim.lua', '.nvimrc', '.exrc' }, {
  type = 'file',
  upward = true,
  limit = math.huge,
})
for _, file in ipairs(files) do
  local trusted = vim.secure.read(file) --[[@as string|nil]]
  if trusted then
    if vim.endswith(file, '.lua') then
      assert(loadstring(trusted, '@' .. file))()
    else
      vim.api.nvim_exec2(trusted, {})
    end
  end
  -- If the user unset 'exrc' in the current exrc then stop searching
  if not vim.o.exrc then
    break
  end
end