Allow customization of the method that find_pattern_root obtains the current working directory.
Right now it uses vim.fn.expand("%:p:h", true), but this does not work for all buffer types (for instance, it doesn't work for oil.nvim, because vim.fn.expand returns a URI and not the local file path).
An example of usage for oil.nvim (with lazy.nvim):
{
"ahmedkhalf/project.nvim",
config = function()
require("project_nvim").setup({
manual_mode = false,
silent_chdir = true,
detection_methods = { "pattern", "lsp" },
pattern_get_current_dir_fn = function()
local status, oil = pcall(require, "oil")
if status then
local dir = oil.get_current_dir()
if dir ~= nil then
return dir
end
end
return vim.fn.expand("%:p:h", true)
end,
show_hidden = false,
datapath = vim.fn.stdpath("data"),
})
utils.on_load("telescope.nvim", function()
require("telescope").load_extension("projects")
end)
end,
},
The default setting remains as vim.vn.expand("%:p:h"), so functionality will be the same for anyone that doesn't configure a pattern_get_current_dir_fn.
Allow customization of the method that
find_pattern_root
obtains the current working directory.Right now it uses
vim.fn.expand("%:p:h", true)
, but this does not work for all buffer types (for instance, it doesn't work for oil.nvim, becausevim.fn.expand
returns a URI and not the local file path).An example of usage for oil.nvim (with lazy.nvim):
The default setting remains as
vim.vn.expand("%:p:h")
, so functionality will be the same for anyone that doesn't configure apattern_get_current_dir_fn
.