Check if .vim directory exists before use
Update `build#dir()` to check for the existence of the `.vim` directory containing `coc_settings.json` before attempting to read the file. If it doesn't exist then create it.
This commit is contained in:
parent
bf6deaf1ed
commit
eb1a4a71d8
@ -37,8 +37,12 @@ function! build#dir(...) abort
|
|||||||
if exists('l:dir')
|
if exists('l:dir')
|
||||||
" Set build directory and restart YouCompleteMe.
|
" Set build directory and restart YouCompleteMe.
|
||||||
let $BUILD_DIR = getcwd().'/'.substitute(l:dir, '\/$', '', '')
|
let $BUILD_DIR = getcwd().'/'.substitute(l:dir, '\/$', '', '')
|
||||||
" TODO: Check .vim/coc-settings.json exists, create it if not
|
let l:coc_settings = {}
|
||||||
let l:coc_settings = json_decode(join(readfile('.vim/coc-settings.json'), ''))
|
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['clangd.compilationDatabasePath'] = $BUILD_DIR
|
||||||
let l:coc_settings['cmake.lsp.buildDirectory'] = $BUILD_DIR
|
let l:coc_settings['cmake.lsp.buildDirectory'] = $BUILD_DIR
|
||||||
call writefile([json_encode(l:coc_settings)], '.vim/coc-settings.json')
|
call writefile([json_encode(l:coc_settings)], '.vim/coc-settings.json')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user