19 lines
474 B
Lua
19 lines
474 B
Lua
local M = {}
|
|
|
|
function M.setup(opts)
|
|
opts = opts or {}
|
|
local markers = opts.markers
|
|
or { ".git", ".jj", "Cargo.toml", "pyproject.toml", "Makefile", "go.mod", "package.json" }
|
|
vim.api.nvim_create_autocmd({ "BufReadPost", "BufNewFile" }, {
|
|
group = vim.api.nvim_create_augroup("tiny-rooter", { clear = true }),
|
|
callback = function()
|
|
local root = vim.fs.root(0, markers)
|
|
if root then
|
|
vim.cmd.lcd(root)
|
|
end
|
|
end,
|
|
})
|
|
end
|
|
|
|
return M
|