I've got a c++ cmake project. I've created a subdirectory work in the main directory that I'm using for compilation. When I compile the project I cd into work and do cmake .. && make. This way, compiler files do not pollute the main directory. work is also the directory, where compile_commands.json is generated, and I use that for coc syntax highlighting.
As long as it's in the subdirectory, coc can't find it, therefore, I created a softlink in the main directory that leads to the file. This works, and another solution would be adding a command to CMakeLists.txt that would copy the file to the main directory, but I keep wondering if there is a better way to do it. And with a better way, I mean, something like creating .vimrc in the main directory and writing in it commands that coc could use to find the file.
So far, I have found vim command that allows me to move into that direction, set exrc will load local .vimrc files
One thing I've tried is putting
" setting with vim-lsp
if executable('ccls')
au User lsp_setup call lsp#register_server({
\ 'name': 'ccls',
\ 'cmd': {server_info->['ccls']},
\ 'root_uri': {server_info->lsp#utils#path_to_uri(
\ lsp#utils#find_nearest_parent_file_directory(
\ lsp#utils#get_buffer_path(), ['.ccls', 'compile_commands.json', '.git/', 'work/compile_commands.json' ]))},
\ 'initialization_options': {
\ 'highlight': { 'lsRanges' : v:true },
\ 'cache': {'directory': stdpath('cache') . '/ccls' },
\ },
\ 'whitelist': ['c', 'cpp', 'objc', 'objcpp', 'cc'],
\ })
endif
into the local .vimrc file, but that didn't work
What command should I put into the .vimrc located in the main directory to tell coc plugin to look for ./work/compile_commands.json?