Files
neovim/runtime/lua/vim/_core/exrc.lua
Justin M. Keyes 20e77c5d88 build: ship "_core/*" as bytecode (built-into Nvim binary)
Problem:
We want to encourage implementing core features in Lua instead of C, but
it's clumsy because:
- Core Lua code (built into `nvim` so it is available even if VIMRUNTIME
  is missing/invalid) requires manually updating CMakeLists.txt, or
  stuffing it into `_editor.lua`.
- Core Lua modules are not organized similar to C modules, `_editor.lua`
  is getting too big.

Solution:
- Introduce `_core/` where core Lua code can live. All Lua modules added
  there will automatically be included as bytecode in the `nvim` binary.
- Move these core modules into `_core/*`:
  ```
  _defaults.lua
  _editor.lua
  _options.lua
  _system.lua
  shared.lua
  ```

TODO:
- Move `_extui/ => _core/ui2/`
2025-12-30 01:44:24 -05:00

22 lines
540 B
Lua

-- 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