1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-24 02:10:05 +08:00
SpaceVim/lua/spacevim/plugin/mkdir.lua
2024-06-03 22:38:36 +08:00

36 lines
900 B
Lua

--=============================================================================
-- mkdir.lua --- mkdir plugin in lua
-- Copyright (c) 2016-2023 Wang Shidong & Contributors
-- Author: Wang Shidong < wsdjeg@outlook.com >
-- URL: https://spacevim.org
-- License: GPLv3
--=============================================================================
local M = {}
local sp = require('spacevim')
local logger = require('spacevim.logger').derive('mkdir')
local function mkdir(dir)
if sp.fn.exists('*mkdir') == 1 then
sp.fn.mkdir(dir, 'p')
else
end
end
local function create_directory(dir)
if vim.regex('^[a-z]\\+:/'):match_str(dir) then
return
end
if sp.fn.isdirectory(dir) == 0 then
mkdir(dir)
end
end
function M.create_current()
local directory = sp.fn.fnamemodify(sp.fn.expand('<afile>'), ':p:h')
create_directory(directory)
end
return M