feat: Improved previewers and cleanup

This commit is contained in:
TJ DeVries
2020-09-17 12:34:42 -04:00
parent 7bdb39b138
commit a9d9b3d8bf
5 changed files with 192 additions and 185 deletions

View File

@@ -1,5 +1,12 @@
local utils = {}
utils.get_separator = (function()
local val = package.config:sub(1, 1)
return function()
return val
end
end)()
utils.if_nil = function(x, was_nil, was_not_nil)
if x == nil then
return was_nil
@@ -114,6 +121,15 @@ utils.path_shorten = (function()
end
end)()
utils.path_tail = (function()
local os_sep = utils.get_separator()
local match_string = '[^' .. os_sep .. ']*$'
return function(path)
return string.match(path, match_string)
end
end)()
-- local x = utils.make_default_callable(function(opts)
-- return function()
-- print(opts.example, opts.another)
@@ -138,10 +154,6 @@ function utils.make_default_callable(f, default_opts)
})
end
function utils.get_separator()
return package.config:sub(1, 1)
end
function utils.job_is_running(job_id)
if job_id == nil then return false end
return vim.fn.jobwait({job_id}, 0)[1] == -1