summaryrefslogtreecommitdiff
path: root/lua/telescope/algos/fzy.lua
diff options
context:
space:
mode:
authorSimon Hauser <Simon-Hauser@outlook.de>2021-07-23 17:42:37 +0200
committerGitHub <noreply@github.com>2021-07-23 11:42:37 -0400
commit79644ab67731c7ba956c354bf0545282f34e10cc (patch)
treee65dbf73b3442ab1aa9fc59fc56a35b4c9edf1e0 /lua/telescope/algos/fzy.lua
parent664690029fdb302bee8d3f27a458383e8477add7 (diff)
chore: use stylua for formatting (#1040)
* chore: stylua job and config * reformat with stylua
Diffstat (limited to 'lua/telescope/algos/fzy.lua')
-rw-r--r--lua/telescope/algos/fzy.lua19
1 files changed, 9 insertions, 10 deletions
diff --git a/lua/telescope/algos/fzy.lua b/lua/telescope/algos/fzy.lua
index f6622d0..bf322ab 100644
--- a/lua/telescope/algos/fzy.lua
+++ b/lua/telescope/algos/fzy.lua
@@ -7,12 +7,12 @@
-- > matches on consecutive letters and starts of words. This allows matching
-- > using acronyms or different parts of the path." - J Hawthorn
-local has_path, Path = pcall(require, 'plenary.path')
+local has_path, Path = pcall(require, "plenary.path")
if not has_path then
Path = {
path = {
- separator = '/'
- }
+ separator = "/",
+ },
}
end
@@ -48,11 +48,11 @@ function fzy.has_match(needle, haystack)
end
local function is_lower(c)
- return c:match("%l")
+ return c:match "%l"
end
local function is_upper(c)
- return c:match("%u")
+ return c:match "%u"
end
local function precompute_bonus(haystack)
@@ -93,7 +93,7 @@ local function compute(needle, haystack, D, M)
haystack_chars[i] = lower_haystack:sub(i, i)
end
- for i=1,n do
+ for i = 1, n do
D[i] = {}
M[i] = {}
@@ -147,7 +147,7 @@ function fzy.positions(needle, haystack)
return {}
elseif n == m then
local consecutive = {}
- for i=1,n do
+ for i = 1, n do
consecutive[i] = i
end
return consecutive
@@ -160,11 +160,10 @@ function fzy.positions(needle, haystack)
local positions = {}
local match_required = false
local j = m
- for i=n,1,-1 do
+ for i = n, 1, -1 do
while j >= 1 do
if D[i][j] ~= SCORE_MIN and (match_required or D[i][j] == M[i][j]) then
- match_required = (i ~= 1) and (j ~= 1) and (
- M[i][j] == D[i - 1][j - 1] + SCORE_MATCH_CONSECUTIVE)
+ match_required = (i ~= 1) and (j ~= 1) and (M[i][j] == D[i - 1][j - 1] + SCORE_MATCH_CONSECUTIVE)
positions[i] = j
j = j - 1
break