From 0c1bc129da3f684b04d72530dddaedb5255f12ef Mon Sep 17 00:00:00 2001 From: JINNOUCHI Yasushi Date: Tue, 15 Jun 2021 03:47:33 +0900 Subject: chore: use plenary.strings and remove strings functions from utils (#690) Co-authored-by: Simon Hauser --- lua/telescope/config.lua | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) (limited to 'lua/telescope/config.lua') diff --git a/lua/telescope/config.lua b/lua/telescope/config.lua index 2c1b463..4ca3d0a 100644 --- a/lua/telescope/config.lua +++ b/lua/telescope/config.lua @@ -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 -- cgit v1.2.3