From c87bc88ec059e697e96e44ef2a31c312d6cb94b8 Mon Sep 17 00:00:00 2001 From: "Kenneth Benzie (Benie)" Date: Wed, 14 Jul 2021 11:27:26 +0100 Subject: [PATCH] temp! --- .conduit.yaml | 1 + autoload/build.vim | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.conduit.yaml b/.conduit.yaml index aa6bf1a..8504548 100644 --- a/.conduit.yaml +++ b/.conduit.yaml @@ -4,6 +4,7 @@ - vim-vint - yamllint - cmakelint + - compdb - repo: - remote: https://github.com/k-takata/minpac.git location: ~/.vim/pack/minpac/opt/minpac diff --git a/autoload/build.vim b/autoload/build.vim index 10f5e20..c0f90b4 100644 --- a/autoload/build.vim +++ b/autoload/build.vim @@ -48,17 +48,28 @@ function! build#dir(...) abort endif endif if exists('l:dir') - " Set build directory and restart YouCompleteMe. - let $BUILD_DIR = getcwd().'/'.substitute(l:dir, '\/$', '', '') + " Set build directory. + let l:cwd = substitute(getcwd(), '\\', '\/', 'g') + let $BUILD_DIR = l:cwd.'/'.substitute(l:dir, '\/$', '', '') + let l:database_dir = $BUILD_DIR + if executable('compdb') + " TODO: Post-process compile_commands.json with compdb. + let l:database_dir = l:cwd.'/.vim' + call systemlist('compdb -p '.$BUILD_DIR.' list > '.l:compile_commands) + endif + call system('') + " Read/create .vim/coc-settings.json let l:coc_settings = {} if isdirectory('.vim') let l:coc_settings = json_decode(join(readfile('.vim/coc-settings.json'), '')) else call mkdir('.vim') endif - let l:coc_settings['clangd.compilationDatabasePath'] = $BUILD_DIR + " Update .vim/coc-settings.json with new build directory. + let l:coc_settings['clangd.compilationDatabasePath'] = l:database_dir let l:coc_settings['cmake.lsp.buildDirectory'] = $BUILD_DIR call writefile([json_encode(l:coc_settings)], '.vim/coc-settings.json') + " Finally coc.nvim with new config. CocRestart endif endfunction