WIP: Actually get the UI to work and add some tests

This commit is contained in:
TJ DeVries
2020-08-20 23:41:53 -04:00
parent 96cac0a8c8
commit cfddae42f5
9 changed files with 270 additions and 146 deletions

View File

@@ -1,3 +1,4 @@
local log = require('telescope.log')
local util = require('telescope.utils')
local sorters = {}
@@ -12,7 +13,7 @@ Sorter.__index = Sorter
---
--- Lower number is better (because it's like a closer match)
--- But, any number below 0 means you want that line filtered out.
--- @param scoring_function function Function that has the interface:
--- @field scoring_function function Function that has the interface:
-- (sorter, prompt, line): number
function Sorter:new(opts)
opts = opts or {}
@@ -59,4 +60,14 @@ sorters.get_ngram_sorter = function()
}
end
sorters.get_levenshtein_sorter = function()
return Sorter:new {
scoring_function = function(_, prompt, line)
local result = require('telescope.algos.string_distance')(prompt, line)
log.info("Sorting result for", prompt, line, " = ", result)
return result
end
}
end
return sorters