diff options
| author | TJ DeVries <devries.timothyj@gmail.com> | 2020-09-17 12:34:42 -0400 |
|---|---|---|
| committer | TJ DeVries <devries.timothyj@gmail.com> | 2020-09-17 12:34:42 -0400 |
| commit | a9d9b3d8bf694914a07a01749306dd5157b868d7 (patch) | |
| tree | f274d94a7c251bd25496cc3d3a66d8d8751d9de3 /lua/telescope/utils.lua | |
| parent | 7bdb39b138ac49f20143d8a3a94467ecc32c23ed (diff) | |
feat: Improved previewers and cleanup
Diffstat (limited to 'lua/telescope/utils.lua')
| -rw-r--r-- | lua/telescope/utils.lua | 20 |
1 files changed, 16 insertions, 4 deletions
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 |
