tangled
alpha
login
or
join now
robinwobin.dev
/
artio.nvim
3
fork
atom
minimal extui fuzzy finder for neovim
3
fork
atom
overview
issues
pulls
pipelines
feat: add pattern matching to default sorter
robinwobin.dev
3 months ago
f608b27b
5d3060f4
+24
-1
1 changed file
expand all
collapse all
unified
split
lua
artio
init.lua
+24
-1
lua/artio/init.lua
···
93
93
end
94
94
95
95
---@type artio.Picker.sorter
96
96
-
artio.sorter = function(lst, input)
96
96
+
artio.fuzzy_sorter = function(lst, input)
97
97
if not lst or #lst == 0 then
98
98
return {}
99
99
end
···
112
112
end
113
113
return items
114
114
end
115
115
+
116
116
+
---@type artio.Picker.sorter
117
117
+
artio.pattern_sorter = function(lst, input)
118
118
+
local match = string.match(input, "^/[^/]*/")
119
119
+
local pattern = match and string.match(match, "^/([^/]*)/$")
120
120
+
121
121
+
return vim
122
122
+
.iter(lst)
123
123
+
:map(function(v)
124
124
+
if pattern and not string.match(v.text, pattern) then
125
125
+
return
126
126
+
end
127
127
+
128
128
+
return { v.id, {}, 0 }
129
129
+
end)
130
130
+
:totable()
131
131
+
end
132
132
+
133
133
+
---@type artio.Picker.sorter
134
134
+
artio.sorter = artio.mergesorters("intersect", artio.pattern_sorter, function(lst, input)
135
135
+
input = string.gsub(input, "^/[^/]*/", "")
136
136
+
return artio.fuzzy_sorter(lst, input)
137
137
+
end)
115
138
116
139
---@generic T
117
140
---@param items T[] Arbitrary items