23 lines
543 B
Lua
23 lines
543 B
Lua
local plen_status_ok, _ = pcall(require, "plenary")
|
|
if not plen_status_ok then return end
|
|
|
|
local M = {}
|
|
local Path = require "plenary.path"
|
|
|
|
function M.get_path(str) return str:match "(.*[/\\])" end
|
|
|
|
function M.add_trailing_slash(value)
|
|
if value:sub(-1) ~= Path.path.sep then return value .. Path.path.sep end
|
|
return value
|
|
end
|
|
|
|
function M.split(inputstr, sep)
|
|
if sep == nil then sep = Path.path.sep end
|
|
local t = {}
|
|
for str in string.gmatch(inputstr, "([^" .. sep .. "]+)") do
|
|
table.insert(t, str)
|
|
end
|
|
return t
|
|
end
|
|
|
|
return M
|