mirror of
https://github.com/neovim/neovim.git
synced 2025-12-16 03:15:39 +00:00
feat(exrc): search in parent directories (#33889)
feat(exrc): search exrc in parent directories Problem: `.nvim.lua` is only loaded from current directory, which is not flexible when working from a subfolder of the project. Solution: Also search parent directories for configuration file.
This commit is contained in:
committed by
GitHub
parent
2c07428966
commit
23bf4c0531
@@ -925,6 +925,29 @@ do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd('VimEnter', {
|
||||
group = vim.api.nvim_create_augroup('nvim.find_exrc', {}),
|
||||
desc = 'Find project-local configuration',
|
||||
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
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
--- Default options
|
||||
|
||||
Reference in New Issue
Block a user