ncm2 / ncm2-pyclang

Cached, fast C/C++ completion for ncm2
MIT License
45 stars 1 forks source link

Non-relative/-absolute includes are ignored #19

Closed Qix- closed 5 years ago

Qix- commented 5 years ago
$ ls
CMakeLists.txt  build       ext     src

$ ls build/*.json
build/compile_commands.json

$ cat ~/.config/nvim/init.vim | grep -A2 -B2 'compile_commands'
let g:ncm2_pyclang#library_path = '/usr/local/opt/llvm/lib'
let g:ncm2_pyclang#database_path = [
            \ 'compile_commands.json',
            \ 'build/compile_commands.json'
            \ ]
autocmd FileType c,cpp nnoremap <buffer> gd :<c-u>call ncm2_pyclang#goto_declaration()<cr>

Running nvim in the same directory as my CMakeLists.txt file (shown in the first ls above), I can #include a relative/absolute path to the header in question and get valid suggestions - however, relying on the include path set by include_directories() in CMake (emitting -I ../path/to/lib options in compile_commands.json, which I've verified exist) does not.

Either compile_commands.json is being ignored entirely, or for some reason this plugin isn't honoring -I.

Qix- commented 5 years ago

Ping @roxma - any idea? This is really a bummer as it works perfectly otherwise :/

Qix- commented 5 years ago

kapture 2019-01-29 at 22 19 46

Here's a demonstration. I've made sure the build commands are correct. They seem to be, as macros from CMake seem to be detected with no problem.

If I use an include that relies on the -I paths, it doesn't show any symbols - but including from a relative/absolute path does.

Qix- commented 5 years ago

Nevermind, made a patch. PR incoming :)

roxma commented 5 years ago

Could you show me a hello-world case so that I could understand what your pr is trying to achieve?

Qix- commented 5 years ago

:+1: good catch, that makes a lot of sense ;)