[vim] Add ensureMetadataDirectoriesExist() and call it
This function creates backup, undo, and swap directories if they do not already exist
This commit is contained in:
parent
e71f78feee
commit
833c4c8a6f
1 changed files with 17 additions and 0 deletions
|
@ -5,3 +5,20 @@ vim.cmd [[ source ~/.vimrc.common ]]
|
|||
|
||||
require 'configuration'
|
||||
require 'keys'
|
||||
|
||||
function ensureMetadataDirectoriesExist()
|
||||
paths = {
|
||||
vim.opt.backupdir:get(),
|
||||
vim.opt.directory:get(),
|
||||
vim.opt.undodir:get()
|
||||
}
|
||||
|
||||
for _, opt in ipairs(paths) do
|
||||
local first_path = opt[1]
|
||||
if string.find(first_path, "//$") then
|
||||
os.execute("mkdir -p " .. first_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
ensureMetadataDirectoriesExist()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue