mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-03-13 02:05:40 +08:00
feat(mkdir): add lua mkdir plugin
This commit is contained in:
parent
42b0bf25aa
commit
ffb93f252a
36
lua/spacevim/plugin/mkdir.lua
Normal file
36
lua/spacevim/plugin/mkdir.lua
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
--=============================================================================
|
||||||
|
-- mkdir.lua --- mkdir plugin in lua
|
||||||
|
-- Copyright (c) 2016-2019 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)
|
||||||
|
local d = dir
|
||||||
|
if d ~= '^[a-z]\\+:/' then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if sp.fn.isdirectory(d) == 0 then
|
||||||
|
mkdir(d)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function M.create_current()
|
||||||
|
local directory = sp.fn.fnamemodify(sp.fn.expand('<afile>'), ':p:h')
|
||||||
|
create_directory(directory)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
Loading…
x
Reference in New Issue
Block a user