diff options
| author | Gregory Anders <greg@gpanders.com> | 2025-05-20 12:06:08 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-20 12:06:08 -0500 |
| commit | cd9d8469b22cedeb5ccad3def6e3cfee2877577f (patch) | |
| tree | ec9f776478d9bb1818bd278f7aa12d89e435e1fb /runtime/lua/vim/_defaults.lua | |
| parent | 5ad01184f3c3cb4f100bbdcebee3dd699a69b0da (diff) | |
| parent | 8d397fa458a9f89c8e48fcaa281d2efcd0ef8e69 (diff) | |
| download | rneovim-cd9d8469b22cedeb5ccad3def6e3cfee2877577f.tar.gz rneovim-cd9d8469b22cedeb5ccad3def6e3cfee2877577f.tar.bz2 rneovim-cd9d8469b22cedeb5ccad3def6e3cfee2877577f.zip | |
Merge pull request #34090 from yochem/exrc-search-parent
feat(exrc): unset 'exrc' to stop searching parent directories
Diffstat (limited to 'runtime/lua/vim/_defaults.lua')
| -rw-r--r-- | runtime/lua/vim/_defaults.lua | 36 |
1 files changed, 22 insertions, 14 deletions
diff --git a/runtime/lua/vim/_defaults.lua b/runtime/lua/vim/_defaults.lua index d0b3fea389..52fdfd0aef 100644 --- a/runtime/lua/vim/_defaults.lua +++ b/runtime/lua/vim/_defaults.lua @@ -928,23 +928,31 @@ do vim.api.nvim_create_autocmd('VimEnter', { group = vim.api.nvim_create_augroup('nvim.find_exrc', {}), - desc = 'Find project-local configuration', + desc = 'Find exrc files in parent directories', callback = function() - if vim.o.exrc then - 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 - loadstring(trusted)() - else - vim.api.nvim_exec2(trusted, {}) - end + if not vim.o.exrc then + return + end + local files = vim.fs.find({ '.nvim.lua', '.nvimrc', '.exrc' }, { + type = 'file', + upward = true, + limit = math.huge, + -- exrc in cwd already handled from C, thus start in parent directory. + path = vim.fs.dirname(vim.uv.cwd()), + }) + for _, file in ipairs(files) do + local trusted = vim.secure.read(file) --[[@as string|nil]] + if trusted then + if vim.endswith(file, '.lua') then + loadstring(trusted)() + 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 + return + end end end, }) |