fix(lsp): create missing directory before creating file (#19835)

Co-authored-by: Mathias Fussenegger <f.mathias@zignar.net>
This commit is contained in:
shaunsingh
2022-09-24 06:46:21 -04:00
committed by GitHub
parent 24b5449b3d
commit caf5738fa9
2 changed files with 20 additions and 1 deletions

View File

@@ -772,8 +772,11 @@ local function create_file(change)
-- from spec: Overwrite wins over `ignoreIfExists`
local fname = vim.uri_to_fname(change.uri)
if not opts.ignoreIfExists or opts.overwrite then
vim.fn.mkdir(vim.fs.dirname(fname), 'p')
local file = io.open(fname, 'w')
file:close()
if file then
file:close()
end
end
vim.fn.bufadd(fname)
end