From a9d9b3d8bf694914a07a01749306dd5157b868d7 Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Thu, 17 Sep 2020 12:34:42 -0400 Subject: feat: Improved previewers and cleanup --- lua/telescope/utils.lua | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'lua/telescope/utils.lua') diff --git a/lua/telescope/utils.lua b/lua/telescope/utils.lua index db77a7f..fe9eff3 100644 --- a/lua/telescope/utils.lua +++ b/lua/telescope/utils.lua @@ -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 -- cgit v1.2.3