chore: use plenary.strings and remove strings functions from utils (#690)

Co-authored-by: Simon Hauser <Simon-Hauser@outlook.de>
This commit is contained in:
JINNOUCHI Yasushi
2021-06-15 03:47:33 +09:00
committed by GitHub
parent 398a0d391a
commit 0c1bc129da
6 changed files with 25 additions and 139 deletions

View File

@@ -1,3 +1,5 @@
local strings = require('plenary.strings')
-- Keep the values around between reloads
_TelescopeConfigurationValues = _TelescopeConfigurationValues or {}
_TelescopeConfigurationPickers = _TelescopeConfigurationPickers or {}
@@ -13,30 +15,6 @@ local function first_non_null(...)
end
end
local dedent = function(str, leave_indent)
-- find minimum common indent across lines
local indent = nil
for line in str:gmatch('[^\n]+') do
local line_indent = line:match('^%s+') or ''
if indent == nil or #line_indent < #indent then
indent = line_indent
end
end
if indent == nil or #indent == 0 then
-- no minimum common indent
return str
end
local left_indent = (' '):rep(leave_indent or 0)
-- create a pattern for the indent
indent = indent:gsub('%s', '[ \t]')
-- strip it from the first line
str = str:gsub('^'..indent, left_indent)
-- strip it from the remaining lines
str = str:gsub('[\n]'..indent, '\n' .. left_indent)
return str
end
local sorters = require('telescope.sorters')
-- TODO: Add other major configuration points here.
@@ -69,7 +47,7 @@ function config.set_defaults(defaults)
config.values[name] = get(name, default_val)
if description then
config.descriptions[name] = dedent(description)
config.descriptions[name] = strings.dedent(description)
end
end