Issue Checks
What does the problem you encountered relate to?
What neovim version are you using? (nvim -v)
v0.11.5
Operating system and, if possible, what version?
macOS Tahoe 26.2
Output Of :ProjectConfig!
{
allow_different_owners = false,
allow_patterns_for_lsp = false,
before_attach = <function 1>,
datapath = "/Users/peter/.local/share/nvim",
disable_on = {
bt = { "help", "nofile", "nowrite", "terminal" },
ft = { "", "NvimTree", "TelescopePrompt", "TelescopeResults", "alpha", "checkhealth", "lazy", "log", "ministarter", "neo-tree", "notify", "nvim-pack", "packer", "qf" }
},
enable_autochdir = false,
exclude_dirs = {},
expand_excluded = <function 2>,
fzf_lua = {
enabled = false
},
historysize = 100,
ignore_lsp = {},
log = {
enabled = false,
logpath = "/Users/peter/.local/state/nvim",
max_size = 1.1
},
manual_mode = false,
on_attach = <function 3>,
patterns = { ".git", ".github", "_darcs", ".hg", ".bzr", ".svn", "Pipfile", "pyproject.toml", ".pre-commit-config.yaml", ".pre-commit-config.yml", ".csproj", ".sln", ".nvim.lua" },
scope_chdir = "global",
show_hidden = false,
silent_chdir = true,
telescope = {
disable_file_picker = false,
mappings = {
i = {
["<C-b>"] = "browse_project_files",
["<C-d>"] = "delete_project",
["<C-f>"] = "find_project_files",
["<C-r>"] = "recent_project_files",
["<C-s>"] = "search_in_project_files",
["<C-w>"] = "change_working_directory"
},
n = {
b = "browse_project_files",
d = "delete_project",
f = "find_project_files",
r = "recent_project_files",
s = "search_in_project_files",
w = "change_working_directory"
}
},
prefer_file_browser = false,
sort = "newest"
},
use_lsp = true
}
Output of :checkhealth project
==============================================================================
project: 1 ⚠️
Setup ~
- ✅ OK
setup() has been called!
- ✅ OK nvim version is at least
v0.11 (v0.11.5)
- ✅ OK
fd executable in PATH
Current Project ~
- Current project:
/Users/peter/Downloads/test-git-nvim/project
My Method used: "texlab" lsp
Last project: /Users/peter/Downloads/test-git-nvim
Detection Methods ~
Active Sessions ~
-
/Users/peter/Downloads/test-git-nvim/project
-
/Users/peter/Downloads/test-git-nvim
History ~
- ✅ OK datapath:
/Users/peter/.local/share/nvim
- ✅ OK projectpath:
/Users/peter/.local/share/nvim/project_nvim
- ✅ OK historyfile:
/Users/peter/.local/share/nvim/project_nvim/project_history
Fzf-Lua ~
Config ~
- ✅ OK - show_hidden:
false
- ✅ OK - scope_chdir:
"global"
- ✅ OK - log:
enabled: false
max_size: 1.1
logpath: "/Users/peter/.local/state/nvim"
- ✅ OK - historysize:
100
- ✅ OK - disable_on:
bt:
[1]: "help"
[2]: "nofile"
[3]: "nowrite"
[4]: "terminal"
ft:
[1]: ""
[2]: "NvimTree"
[3]: "TelescopePrompt"
[4]: "TelescopeResults"
[5]: "alpha"
[6]: "checkhealth"
[7]: "lazy"
[8]: "log"
[9]: "ministarter"
[10]: "neo-tree"
[11]: "notify"
[12]: "nvim-pack"
[13]: "packer"
[14]: "qf"
- ✅ OK - manual_mode:
false
- ✅ OK - use_lsp:
true
- ✅ OK - patterns:
[1]: ".git"
[2]: ".github"
[3]: "_darcs"
[4]: ".hg"
[5]: ".bzr"
[6]: ".svn"
[7]: "Pipfile"
[8]: "pyproject.toml"
[9]: ".pre-commit-config.yaml"
[10]: ".pre-commit-config.yml"
[11]: ".csproj"
[12]: ".sln"
[13]: ".nvim.lua"
- ✅ OK - allow_different_owners:
false
- ✅ OK - silent_chdir:
true
- ✅ OK - expand_excluded:
function
- ✅ OK - exclude_dirs:
{}
- ✅ OK - verify:
function
- ✅ OK - ignore_lsp:
{}
- ✅ OK - enable_autochdir:
false
- ✅ OK - allow_patterns_for_lsp:
false
- ✅ OK - datapath:
"/Users/peter/.local/share/nvim"
- ✅ OK - on_attach:
function
- ✅ OK - before_attach:
function
Recent Projects ~
1. /Users/peter/Downloads/test-git-nvim
2. … (removed some more entries)
Describe the bug
I have a git repository with multiple subdirectories, where some subdirectories contain a LaTeX project. I use a LaTeX language server for root detection, which works fite (checked separately via :LSPInfo).
When loading such a project from a subdirectory, project.nvim sets the CWD to the git repository instead of the subdirectory. Note that I have set use_lsp = true, which I understood should ensure that the LSP takes precedence.
Steps To Reproduce
- Have a git repository with a subdirectory containing a LaTeX project.
- Have a LaTeX LSP configured that recognizes the subdirectory as the LaTeX project root.
- Configure project.nvim with
use_lsp = true.
- Load a file from the LaTeX project.
(Any other LSP based project with LSP root detection should work too.)
Expected Behavior
The CWD should be set to the subdirectory. Instead, it is set to the git repository.
How did you setup the plugin?
Additional Info and/or Screenshots
I did some debugging myself and looked at the method Api.get_project_root in lua/project/api.lua. The roots variable contains
{ { "/Users/peter/Downloads/test-git-nvim/project", '"texlab" lsp', "lsp" }, { "/Users/peter/Downloads/test-git-nvim", "pattern .git", "pattern" } }
after the for loop in lines 302 to 309. This seems correct.
I then took a look at the decision logic in the following lines and got confused. Maybe I'm misunderstanding something, but that logic seems to always prefer the root found via the traditional pattern matching. In particular due to the final for loop in lines 321 to 325.
I replaced that whole logic for a simple
if vim.tbl_isempty(roots) then
return
else
return roots[1][1], roots[1][2]
end
which works for me (not tested thoroughly). From my (very quick) glances at the rest of the code, I got the impression that roots is filled such that the first entry should always be the one preferred. If use_lsp is set, then it will be the LSP entry, otherwise the traditional pattern matching entry.
Issue Checks
project.nvimREADME.md,:h project-nvim, etc.)What does the problem you encountered relate to?
project.nvimfzf-luaintegration issuesWhat neovim version are you using? (
nvim -v)v0.11.5
Operating system and, if possible, what version?
macOS Tahoe 26.2
Output Of
:ProjectConfig!Output of
:checkhealth project==============================================================================⚠️
project: 1
Setup ~
setup()has been called!v0.11(v0.11.5)fdexecutable inPATHCurrent Project ~
/Users/peter/Downloads/test-git-nvim/projectMy Method used:
"texlab" lspLast project:
/Users/peter/Downloads/test-git-nvimDetection Methods ~
Active Sessions ~
/Users/peter/Downloads/test-git-nvim/project/Users/peter/Downloads/test-git-nvimHistory ~
/Users/peter/.local/share/nvim/Users/peter/.local/share/nvim/project_nvim/Users/peter/.local/share/nvim/project_nvim/project_historyFzf-Lua ~
fzf-luaintegration is disabled.This doesn't represent an issue necessarily!
Config ~
false"global"enabled:
falsemax_size:
1.1logpath:
"/Users/peter/.local/state/nvim"100bt:
[1]:
"help"[2]:
"nofile"[3]:
"nowrite"[4]:
"terminal"ft:
[1]:
""[2]:
"NvimTree"[3]:
"TelescopePrompt"[4]:
"TelescopeResults"[5]:
"alpha"[6]:
"checkhealth"[7]:
"lazy"[8]:
"log"[9]:
"ministarter"[10]:
"neo-tree"[11]:
"notify"[12]:
"nvim-pack"[13]:
"packer"[14]:
"qf"falsetrue[1]:
".git"[2]:
".github"[3]:
"_darcs"[4]:
".hg"[5]:
".bzr"[6]:
".svn"[7]:
"Pipfile"[8]:
"pyproject.toml"[9]:
".pre-commit-config.yaml"[10]:
".pre-commit-config.yml"[11]:
".csproj"[12]:
".sln"[13]:
".nvim.lua"falsetruefunction{}function{}falsefalse"/Users/peter/.local/share/nvim"functionfunctionRecent Projects ~
1./Users/peter/Downloads/test-git-nvim2. … (removed some more entries)Describe the bug
I have a git repository with multiple subdirectories, where some subdirectories contain a LaTeX project. I use a LaTeX language server for root detection, which works fite (checked separately via
:LSPInfo).When loading such a project from a subdirectory, project.nvim sets the CWD to the git repository instead of the subdirectory. Note that I have set
use_lsp = true, which I understood should ensure that the LSP takes precedence.Steps To Reproduce
use_lsp = true.(Any other LSP based project with LSP root detection should work too.)
Expected Behavior
The CWD should be set to the subdirectory. Instead, it is set to the git repository.
How did you setup the plugin?
Additional Info and/or Screenshots
I did some debugging myself and looked at the method
Api.get_project_rootinlua/project/api.lua. Therootsvariable containsafter the for loop in lines 302 to 309. This seems correct.
I then took a look at the decision logic in the following lines and got confused. Maybe I'm misunderstanding something, but that logic seems to always prefer the root found via the traditional pattern matching. In particular due to the final for loop in lines 321 to 325.
I replaced that whole logic for a simple
which works for me (not tested thoroughly). From my (very quick) glances at the rest of the code, I got the impression that
rootsis filled such that the first entry should always be the one preferred. Ifuse_lspis set, then it will be the LSP entry, otherwise the traditional pattern matching entry.