diff --git a/autoload/build.vim b/autoload/build.vim index b449caf..a389436 100644 --- a/autoload/build.vim +++ b/autoload/build.vim @@ -37,8 +37,12 @@ function! build#dir(...) abort if exists('l:dir') " Set build directory and restart YouCompleteMe. let $BUILD_DIR = getcwd().'/'.substitute(l:dir, '\/$', '', '') - " TODO: Check .vim/coc-settings.json exists, create it if not - let l:coc_settings = json_decode(join(readfile('.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 let l:coc_settings['cmake.lsp.buildDirectory'] = $BUILD_DIR call writefile([json_encode(l:coc_settings)], '.vim/coc-settings.json')