cannot find project path from subdirectory
youzark opened this issue · 5 comments
Bug description
suppose the project's file hierarchy as below:
project_root
CMakeLists.txt
.marker(such .git)
src
main.cpp
include
hello.hpp
I can only use cmakegenerate in project_root to locate .marker correctly
if I try it in src or include , it will try to locate .marker from $HOME
I found FindProjectRoot() in autoload
if I change the following line:
let l:root = fnamemodify(l:marker_path, printf(
\ ':.:s?%s??:h', l:marker_path))
to:
let l:root = fnamemodify(l:marker_path,":h")
things will work fine
I think nvim change it's findfile() return value to full path, to strip the .marker, we only need to use ':h' in fnamemodify()
Hi, thanks for reporting this. However, I cannot reproduce your problem. Can you please fill in the issue description template as it is provided when creating an issue?
I rewrite the issue
Bug description
cmake can't find project root properly
To Reproduce
Steps to reproduce the behavior:
- file structure:(under project root)
CMakeLists.txt include/hello.hpp src/main.cpp src/printer.cpp .youzark(a marker) - In src/main.cpp run :CMakeGenerate (or other subfile)
- In root dir run :CMakeGenerate
Expected behavior
under both 2 or 3, the CMakeLists(the same folder with .youzark) should be found
but only under 3(root dir) ,cmake will work normally.
under case 3, an error will occur:
CMake Error: The source directory "path/to/project/root/src" does not appear to contain CMakeLists.txt.
Behavior with minimal .vimrc
let g:cmake_root_markers = ['.youzark','.git','.svn']
let g:cmake_link_compile_commands = 1
let g:cmake_jump_on_completion = 1
Screenshots
Other info
- OS:
NAME="Ubuntu"
VERSION="20.04.3 LTS (Focal Fossa)" - Vim/Neovim version:NVIM v0.6.0-dev+184-g8d62f5fd5 (release)
- Vim-CMake version (5th line in
:help cmake
):
Additional context
Add any other context about the problem here.
@youzark sorry for the huge delay.
Could you please try to pull the latest master
and check if this issue is resolved? Thank you.
@cdelledonne I am using the latest master
, this issue is resolved, no matter autochdir
is set or not.
Thanks.
Great!