I’m in the process of tentatively switching from “classic” vim to NeoVim (specifically, LazyVim), and it took me ages to get Tim Pope’s Projectionist plugin working.
In case this helps anyone else (and Google successfully indexes it), the trick seems to have been to set event to BufEnter, to force it to check whether to load itself whenever you open a file (there may be a better way, but this one seems to work). This is what I ended up with in lua/plugins/projectionist.lua (I’m setting it up for Elixir, so you’ll probably want a different language-specific plugin, or to add your own config (see below).
return {
{
"tpope/vim-projectionist",
keys = {
{ "<leader>a", "<cmd>A<cr>", desc = "Go to alternate file" },
},
event = "BufEnter",
},
{ "c-brenn/fuzzy-projectionist.vim" },
{ "andyl/vim-projectionist-elixir" },
}
I think, based on this Stack Overflow answer, that the syntax for adding your own heuristics is as below (see the plugin docs for more details). In this case mix.exs is the path it checks for the existence of to decide whether these mappings apply to the current project.
return {
"tpope/vim-projectionist",
config = function()
vim.g.projectionist_heuristics = {
["mix.exs"] = {
["src/*.ex"] = {
alternate = "test/{}_test.exs",
},
["test/*_test.exs"] = {
alternate = "src/{}.ex",
},
},
}
end,
event = "BufEnter",
},