ci: Add luacheck ci job (#317)
* Add luacheck ci job * Fix most of the linting issues * fixup: lint Co-authored-by: TJ DeVries <devries.timothyj@gmail.com>
This commit is contained in:
19
.github/workflows/lint.yml
vendored
Normal file
19
.github/workflows/lint.yml
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
name: Linting and style checking
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
luacheck:
|
||||||
|
name: Luacheck
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install luarocks
|
||||||
|
sudo luarocks install luacheck
|
||||||
|
|
||||||
|
- name: Lint
|
||||||
|
run: sudo make lint
|
||||||
26
.luacheckrc
Normal file
26
.luacheckrc
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
-- Rerun tests only if their modification time changed.
|
||||||
|
cache = true
|
||||||
|
|
||||||
|
std = luajit
|
||||||
|
codes = true
|
||||||
|
|
||||||
|
self = false
|
||||||
|
|
||||||
|
-- Glorious list of warnings: https://luacheck.readthedocs.io/en/stable/warnings.html
|
||||||
|
ignore = {
|
||||||
|
"212", -- Unused argument, In the case of callback function, _arg_name is easier to understand than _, so this option is set to off.
|
||||||
|
"122", -- Indirectly setting a readonly global
|
||||||
|
}
|
||||||
|
|
||||||
|
globals = {
|
||||||
|
"TelescopeGlobalState",
|
||||||
|
"TelescopeCachedUppers",
|
||||||
|
"TelescopeCachedTails",
|
||||||
|
"TelescopeCachedNgrams",
|
||||||
|
"_TelescopeConfigurationValues",
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Global objects defined by the C code
|
||||||
|
read_globals = {
|
||||||
|
"vim",
|
||||||
|
}
|
||||||
3
Makefile
3
Makefile
@@ -1,2 +1,5 @@
|
|||||||
test:
|
test:
|
||||||
nvim --headless -c 'lua require("plenary.test_harness"):test_directory("busted", "./lua/tests/automated/")'
|
nvim --headless -c 'lua require("plenary.test_harness"):test_directory("busted", "./lua/tests/automated/")'
|
||||||
|
|
||||||
|
lint:
|
||||||
|
luacheck lua/telescope
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
vim.deepcopy = (function()
|
vim.deepcopy = (function()
|
||||||
local function _id(v)
|
local function _id(v)
|
||||||
return v
|
return v
|
||||||
@@ -55,17 +54,3 @@ vim.deepcopy = (function()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)()
|
end)()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
table.clear = table.clear or function(t)
|
|
||||||
for k in pairs (t) do
|
|
||||||
t[k] = nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
table.pop = table.pop or function(t, k)
|
|
||||||
local val = t[k]
|
|
||||||
t[k] = nil
|
|
||||||
return val
|
|
||||||
end
|
|
||||||
|
|||||||
@@ -1,109 +0,0 @@
|
|||||||
local NGram = {}
|
|
||||||
NGram.__index = NGram
|
|
||||||
|
|
||||||
function NGram:new(opts)
|
|
||||||
-- TODO: Add padding
|
|
||||||
opts = opts or {}
|
|
||||||
return setmetatable({
|
|
||||||
N = opts.N or 2,
|
|
||||||
split = opts.split or "/",
|
|
||||||
_depth = 5,
|
|
||||||
_grams = setmetatable({}, utils.default_table_mt)
|
|
||||||
}, self)
|
|
||||||
end
|
|
||||||
|
|
||||||
local min = math.min
|
|
||||||
|
|
||||||
function NGram:_split(word)
|
|
||||||
local word_len = #word
|
|
||||||
|
|
||||||
local result = {}
|
|
||||||
for i = 1, word_len - 1 do
|
|
||||||
-- for j = i + (self.N - 1), min(i + self._depth - 1, word_len) do
|
|
||||||
-- table.insert(result, string.sub(word, i, j))
|
|
||||||
-- end
|
|
||||||
table.insert(result, string.sub(word, i, i + self.N - 1))
|
|
||||||
end
|
|
||||||
|
|
||||||
return result
|
|
||||||
end
|
|
||||||
|
|
||||||
-- local function pairsByKeys (t, f)
|
|
||||||
-- local a = {}
|
|
||||||
-- for n in pairs(t) do table.insert(a, n) end
|
|
||||||
-- table.sort(a, f)
|
|
||||||
-- local i = 0 -- iterator variable
|
|
||||||
-- local iter = function () -- iterator function
|
|
||||||
-- i = i + 1
|
|
||||||
-- if a[i] == nil then return nil
|
|
||||||
-- else return a[i], t[a[i]]
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
-- return iter
|
|
||||||
-- end
|
|
||||||
|
|
||||||
function NGram:add(word)
|
|
||||||
local split_word = self:_split(word)
|
|
||||||
|
|
||||||
for _, k in ipairs(split_word) do
|
|
||||||
local counts = self._grams[k]
|
|
||||||
if counts[word] == nil then
|
|
||||||
counts[word] = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
counts[word] = counts[word] + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function NGram:_items_sharing_ngrams(query)
|
|
||||||
local split_query = self:_split(query)
|
|
||||||
|
|
||||||
-- Matched string to number of N-grams shared with the query string.
|
|
||||||
local shared = {}
|
|
||||||
|
|
||||||
local remaining = {}
|
|
||||||
|
|
||||||
for _, ngram in ipairs(split_query) do
|
|
||||||
remaining = {}
|
|
||||||
for match, count in pairs(self._grams[ngram] or {}) do
|
|
||||||
remaining[match] = remaining[match] or count
|
|
||||||
|
|
||||||
if remaining[match] > 0 then
|
|
||||||
remaining[match] = remaining[match] - 1
|
|
||||||
shared[match] = (shared[match] or 0) + 1
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return shared
|
|
||||||
end
|
|
||||||
|
|
||||||
function NGram:search(query, show_values)
|
|
||||||
local sharing_ngrams = self:_items_sharing_ngrams(query)
|
|
||||||
|
|
||||||
local results = {}
|
|
||||||
for name, count in pairs(sharing_ngrams) do
|
|
||||||
local allgrams = #query + #name - (2 * self.N) - count + 2
|
|
||||||
table.insert(results, {name, count / allgrams})
|
|
||||||
end
|
|
||||||
|
|
||||||
table.sort(results, function(left, right)
|
|
||||||
return left[2] > right[2]
|
|
||||||
end)
|
|
||||||
|
|
||||||
if not show_values then
|
|
||||||
for k, v in ipairs(results) do
|
|
||||||
results[k] = v[1]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return results
|
|
||||||
end
|
|
||||||
|
|
||||||
function NGram:find(query)
|
|
||||||
return self:search(query)[1]
|
|
||||||
end
|
|
||||||
|
|
||||||
function NGram:score(query)
|
|
||||||
return (self:search(query, true)[1] or {})[2] or 0
|
|
||||||
end
|
|
||||||
@@ -198,7 +198,7 @@ actions.edit_register = function(prompt_bufnr)
|
|||||||
|
|
||||||
-- update entry in results table
|
-- update entry in results table
|
||||||
-- TODO: find way to redraw finder content
|
-- TODO: find way to redraw finder content
|
||||||
for k, v in pairs(picker.finder.results) do
|
for _, v in pairs(picker.finder.results) do
|
||||||
if v == entry then
|
if v == entry then
|
||||||
v.content = updated_value
|
v.content = updated_value
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
local action_mt = {}
|
local action_mt = {}
|
||||||
|
|
||||||
action_mt.create = function(mod)
|
action_mt.create = function(mod)
|
||||||
|
|||||||
@@ -71,7 +71,8 @@ files.find_files = function(opts)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if not find_command then
|
if not find_command then
|
||||||
print("You need to install either find, fd, or rg. You can also submit a PR to add support for another file finder :)")
|
print("You need to install either find, fd, or rg. " ..
|
||||||
|
"You can also submit a PR to add support for another file finder :)")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -54,8 +54,7 @@ internal.planets = function(opts)
|
|||||||
local globbed_files = vim.fn.globpath(base_directory .. '/data/memes/planets/', '*', true, true)
|
local globbed_files = vim.fn.globpath(base_directory .. '/data/memes/planets/', '*', true, true)
|
||||||
local acceptable_files = {}
|
local acceptable_files = {}
|
||||||
for _, v in ipairs(globbed_files) do
|
for _, v in ipairs(globbed_files) do
|
||||||
if not show_pluto and v:find("pluto") then
|
if show_pluto or not v:find("pluto") then
|
||||||
else
|
|
||||||
table.insert(acceptable_files,vim.fn.fnamemodify(v, ':t'))
|
table.insert(acceptable_files,vim.fn.fnamemodify(v, ':t'))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -212,7 +211,8 @@ end
|
|||||||
|
|
||||||
internal.vim_options = function(opts)
|
internal.vim_options = function(opts)
|
||||||
-- Load vim options.
|
-- Load vim options.
|
||||||
local vim_opts = loadfile(utils.data_directory() .. path.separator .. 'options' .. path.separator .. 'options.lua')().options
|
local vim_opts = loadfile(utils.data_directory() .. path.separator .. 'options' ..
|
||||||
|
path.separator .. 'options.lua')().options
|
||||||
|
|
||||||
pickers.new(opts, {
|
pickers.new(opts, {
|
||||||
prompt = 'options',
|
prompt = 'options',
|
||||||
@@ -250,12 +250,13 @@ internal.vim_options = function(opts)
|
|||||||
-- float_opts.anchor = "sw"
|
-- float_opts.anchor = "sw"
|
||||||
-- float_opts.focusable = false
|
-- float_opts.focusable = false
|
||||||
-- float_opts.style = "minimal"
|
-- float_opts.style = "minimal"
|
||||||
-- float_opts.row = vim.api.nvim_get_option("lines") - 2 -- TODO: include `cmdheight` and `laststatus` in this calculation
|
-- float_opts.row = vim.api.nvim_get_option("lines") - 2 -- TODO: inc `cmdheight` and `laststatus` in this calc
|
||||||
-- float_opts.col = 2
|
-- float_opts.col = 2
|
||||||
-- float_opts.height = 10
|
-- float_opts.height = 10
|
||||||
-- float_opts.width = string.len(selection.last_set_from)+15
|
-- float_opts.width = string.len(selection.last_set_from)+15
|
||||||
-- local buf = vim.fn.nvim_create_buf(false, true)
|
-- local buf = vim.fn.nvim_create_buf(false, true)
|
||||||
-- vim.fn.nvim_buf_set_lines(buf, 0, 0, false, {"default value: abcdef", "last set from: " .. selection.last_set_from})
|
-- vim.fn.nvim_buf_set_lines(buf, 0, 0, false,
|
||||||
|
-- {"default value: abcdef", "last set from: " .. selection.last_set_from})
|
||||||
-- local status_win = vim.fn.nvim_open_win(buf, false, float_opts)
|
-- local status_win = vim.fn.nvim_open_win(buf, false, float_opts)
|
||||||
-- -- vim.api.nvim_win_set_option(status_win, "winblend", 100)
|
-- -- vim.api.nvim_win_set_option(status_win, "winblend", 100)
|
||||||
-- vim.api.nvim_win_set_option(status_win, "winhl", "Normal:PmenuSel")
|
-- vim.api.nvim_win_set_option(status_win, "winhl", "Normal:PmenuSel")
|
||||||
@@ -308,9 +309,7 @@ internal.help_tags = function(opts)
|
|||||||
end
|
end
|
||||||
|
|
||||||
internal.man_pages = function(opts)
|
internal.man_pages = function(opts)
|
||||||
local cmd = opts.man_cmd or "apropos --sections=1 ''"
|
local pages = utils.get_os_command_output(opts.man_cmd or "apropos --sections=1 ''")
|
||||||
|
|
||||||
local pages = utils.get_os_command_output(cmd)
|
|
||||||
|
|
||||||
local lines = {}
|
local lines = {}
|
||||||
for s in pages:gmatch("[^\r\n]+") do
|
for s in pages:gmatch("[^\r\n]+") do
|
||||||
@@ -350,7 +349,9 @@ internal.reloader = function(opts)
|
|||||||
-- filter out packages we don't want and track the longest package name
|
-- filter out packages we don't want and track the longest package name
|
||||||
opts.column_len = 0
|
opts.column_len = 0
|
||||||
for index, module_name in pairs(package_list) do
|
for index, module_name in pairs(package_list) do
|
||||||
if type(require(module_name)) ~= 'table' or module_name:sub(1,1) == "_" or package.searchpath(module_name, package.path) == nil then
|
if type(require(module_name)) ~= 'table' or
|
||||||
|
module_name:sub(1,1) == "_" or
|
||||||
|
package.searchpath(module_name, package.path) == nil then
|
||||||
table.remove(package_list, index)
|
table.remove(package_list, index)
|
||||||
elseif #module_name > opts.column_len then
|
elseif #module_name > opts.column_len then
|
||||||
opts.column_len = #module_name
|
opts.column_len = #module_name
|
||||||
@@ -649,10 +650,10 @@ internal.autocommands = function(opts)
|
|||||||
previewer = previewers.autocommands.new(opts),
|
previewer = previewers.autocommands.new(opts),
|
||||||
sorter = conf.generic_sorter(opts),
|
sorter = conf.generic_sorter(opts),
|
||||||
attach_mappings = function(prompt_bufnr)
|
attach_mappings = function(prompt_bufnr)
|
||||||
actions._goto_file_selection:replace(function(_, cmd)
|
actions._goto_file_selection:replace(function(_, vim_cmd)
|
||||||
local selection = actions.get_selected_entry()
|
local selection = actions.get_selected_entry()
|
||||||
actions.close(prompt_bufnr)
|
actions.close(prompt_bufnr)
|
||||||
vim.cmd(cmd .. ' ' .. selection.value)
|
vim.cmd(vim_cmd .. ' ' .. selection.value)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ local actions = require('telescope.actions')
|
|||||||
local finders = require('telescope.finders')
|
local finders = require('telescope.finders')
|
||||||
local make_entry = require('telescope.make_entry')
|
local make_entry = require('telescope.make_entry')
|
||||||
local pickers = require('telescope.pickers')
|
local pickers = require('telescope.pickers')
|
||||||
local previewers = require('telescope.previewers')
|
|
||||||
local utils = require('telescope.utils')
|
local utils = require('telescope.utils')
|
||||||
|
|
||||||
local conf = require('telescope.config').values
|
local conf = require('telescope.config').values
|
||||||
|
|||||||
@@ -52,13 +52,17 @@ function config.set_defaults(defaults)
|
|||||||
set("border", {})
|
set("border", {})
|
||||||
set("borderchars", { '─', '│', '─', '│', '╭', '╮', '╯', '╰'})
|
set("borderchars", { '─', '│', '─', '│', '╭', '╮', '╯', '╰'})
|
||||||
|
|
||||||
set("get_status_text", function(self) return string.format("%s / %s", self.stats.processed - self.stats.filtered, self.stats.processed) end)
|
set("get_status_text", function(self)
|
||||||
|
return string.format("%s / %s", self.stats.processed - self.stats.filtered, self.stats.processed)
|
||||||
|
end)
|
||||||
|
|
||||||
-- Builtin configuration
|
-- Builtin configuration
|
||||||
|
|
||||||
-- List that will be executed.
|
-- List that will be executed.
|
||||||
-- Last argument will be the search term (passed in during execution)
|
-- Last argument will be the search term (passed in during execution)
|
||||||
set("vimgrep_arguments", {'rg', '--color=never', '--no-heading', '--with-filename', '--line-number', '--column', '--smart-case'})
|
set("vimgrep_arguments",
|
||||||
|
{'rg', '--color=never', '--no-heading', '--with-filename', '--line-number', '--column', '--smart-case'}
|
||||||
|
)
|
||||||
set("use_less", true)
|
set("use_less", true)
|
||||||
set("color_devicons", true)
|
set("color_devicons", true)
|
||||||
|
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ local function td_validate(fn, ms)
|
|||||||
fn = { fn, 'f' },
|
fn = { fn, 'f' },
|
||||||
ms = {
|
ms = {
|
||||||
ms,
|
ms,
|
||||||
function(ms)
|
function(v)
|
||||||
return type(ms) == 'number' and ms > 0
|
return type(v) == 'number' and v > 0
|
||||||
end,
|
end,
|
||||||
"number > 0",
|
"number > 0",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ function EntryManager:new(max_results, set_entry, info)
|
|||||||
return #entry_state
|
return #entry_state
|
||||||
end,
|
end,
|
||||||
|
|
||||||
get_ordinal = function(self, index)
|
get_ordinal = function(_, index)
|
||||||
return self:get_entry(index).ordinal
|
return self:get_entry(index).ordinal
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
|||||||
@@ -133,9 +133,9 @@ function OneshotJobFinder:new(opts)
|
|||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
local job_opts = finder:fn_command(prompt)
|
local job_opts = finder:fn_command(_)
|
||||||
if not job_opts then
|
if not job_opts then
|
||||||
error(debug.trackeback("expected `job_opts` from fn_command"))
|
error(debug.traceback("expected `job_opts` from fn_command"))
|
||||||
end
|
end
|
||||||
|
|
||||||
local writer = nil
|
local writer = nil
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ do
|
|||||||
|
|
||||||
mt_file_entry.cwd = cwd
|
mt_file_entry.cwd = cwd
|
||||||
mt_file_entry.display = function(entry)
|
mt_file_entry.display = function(entry)
|
||||||
local display, hl_group = entry.value, nil
|
local display, hl_group = entry.value
|
||||||
if shorten_path then
|
if shorten_path then
|
||||||
display = utils.path_shorten(display)
|
display = utils.path_shorten(display)
|
||||||
end
|
end
|
||||||
@@ -168,8 +168,6 @@ do
|
|||||||
|
|
||||||
mt_vimgrep_entry.cwd = vim.fn.expand(opts.cwd or vim.fn.getcwd())
|
mt_vimgrep_entry.cwd = vim.fn.expand(opts.cwd or vim.fn.getcwd())
|
||||||
mt_vimgrep_entry.display = function(entry)
|
mt_vimgrep_entry.display = function(entry)
|
||||||
local display, hl_group = entry.value, nil
|
|
||||||
|
|
||||||
local display_filename
|
local display_filename
|
||||||
if shorten_path then
|
if shorten_path then
|
||||||
display_filename = utils.path_shorten(entry.filename)
|
display_filename = utils.path_shorten(entry.filename)
|
||||||
@@ -182,7 +180,7 @@ do
|
|||||||
coordinates = string.format("%s:%s:", entry.lnum, entry.col)
|
coordinates = string.format("%s:%s:", entry.lnum, entry.col)
|
||||||
end
|
end
|
||||||
|
|
||||||
display, hl_group = transform_devicons(
|
local display, hl_group = transform_devicons(
|
||||||
entry.filename,
|
entry.filename,
|
||||||
string.format(display_string, display_filename, coordinates, entry.text),
|
string.format(display_string, display_filename, coordinates, entry.text),
|
||||||
disable_devicons
|
disable_devicons
|
||||||
@@ -215,9 +213,7 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function make_entry.gen_from_git_commits(opts)
|
function make_entry.gen_from_git_commits()
|
||||||
opts = opts or {}
|
|
||||||
|
|
||||||
return function(entry)
|
return function(entry)
|
||||||
if entry == "" then
|
if entry == "" then
|
||||||
return nil
|
return nil
|
||||||
@@ -361,7 +357,7 @@ function make_entry.gen_from_treesitter(opts)
|
|||||||
|
|
||||||
return function(entry)
|
return function(entry)
|
||||||
local ts_utils = require('nvim-treesitter.ts_utils')
|
local ts_utils = require('nvim-treesitter.ts_utils')
|
||||||
local start_row, start_col, end_row, end_col = ts_utils.get_node_range(entry.node)
|
local start_row, start_col, end_row, _ = ts_utils.get_node_range(entry.node)
|
||||||
local node_text = ts_utils.get_node_text(entry.node)[1]
|
local node_text = ts_utils.get_node_text(entry.node)[1]
|
||||||
return {
|
return {
|
||||||
valid = true,
|
valid = true,
|
||||||
@@ -420,9 +416,7 @@ function make_entry.gen_from_packages(opts)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function make_entry.gen_from_apropos(opts)
|
function make_entry.gen_from_apropos()
|
||||||
opts = opts or {}
|
|
||||||
|
|
||||||
return function(line)
|
return function(line)
|
||||||
local cmd, _, desc = line:match("^(.*)%s+%((.*)%)%s+%-%s(.*)$")
|
local cmd, _, desc = line:match("^(.*)%s+%((.*)%)%s+%-%s(.*)$")
|
||||||
|
|
||||||
@@ -481,7 +475,6 @@ function make_entry.gen_from_registers(_)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function make_entry.gen_from_highlights()
|
function make_entry.gen_from_highlights()
|
||||||
return function(entry)
|
|
||||||
local make_display = function(entry)
|
local make_display = function(entry)
|
||||||
local display = entry.value
|
local display = entry.value
|
||||||
return display, { { { 0, #display }, display } }
|
return display, { { { 0, #display }, display } }
|
||||||
@@ -496,6 +489,7 @@ function make_entry.gen_from_highlights()
|
|||||||
vim.api.nvim_buf_add_highlight(bufnr, -1, hl, 1, start - 1, start + 2)
|
vim.api.nvim_buf_add_highlight(bufnr, -1, hl, 1, start - 1, start + 2)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return function(entry)
|
||||||
return {
|
return {
|
||||||
value = entry,
|
value = entry,
|
||||||
display = make_display,
|
display = make_display,
|
||||||
@@ -508,12 +502,6 @@ function make_entry.gen_from_highlights()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function make_entry.gen_from_vimoptions()
|
function make_entry.gen_from_vimoptions()
|
||||||
|
|
||||||
-- TODO: Can we just remove this from `options.lua`?
|
|
||||||
function N_(s)
|
|
||||||
return s
|
|
||||||
end
|
|
||||||
|
|
||||||
local process_one_opt = function(o)
|
local process_one_opt = function(o)
|
||||||
local ok, value_origin
|
local ok, value_origin
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ local path = {}
|
|||||||
path.separator = package.config:sub(1, 1)
|
path.separator = package.config:sub(1, 1)
|
||||||
path.home = vim.fn.expand("~")
|
path.home = vim.fn.expand("~")
|
||||||
|
|
||||||
|
|
||||||
path.make_relative = function(filepath, cwd)
|
path.make_relative = function(filepath, cwd)
|
||||||
if not cwd or not filepath then return filepath end
|
if not cwd or not filepath then return filepath end
|
||||||
|
|
||||||
@@ -83,14 +82,14 @@ path.read_file = function(filepath)
|
|||||||
end
|
end
|
||||||
|
|
||||||
path.read_file_async = function(filepath, callback)
|
path.read_file_async = function(filepath, callback)
|
||||||
vim.loop.fs_open(filepath, "r", 438, function(err, fd)
|
vim.loop.fs_open(filepath, "r", 438, function(err_open, fd)
|
||||||
assert(not err, err)
|
assert(not err_open, err_open)
|
||||||
vim.loop.fs_fstat(fd, function(err, stat)
|
vim.loop.fs_fstat(fd, function(err_fstat, stat)
|
||||||
assert(not err, err)
|
assert(not err_fstat, err_fstat)
|
||||||
vim.loop.fs_read(fd, stat.size, 0, function(err, data)
|
vim.loop.fs_read(fd, stat.size, 0, function(err_read, data)
|
||||||
assert(not err, err)
|
assert(not err_read, err_read)
|
||||||
vim.loop.fs_close(fd, function(err)
|
vim.loop.fs_close(fd, function(err_close)
|
||||||
assert(not err, err)
|
assert(not err_close, err_close)
|
||||||
return callback(data)
|
return callback(data)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|||||||
@@ -328,7 +328,9 @@ function Picker:find()
|
|||||||
a.nvim_win_set_option(results_win, 'winhl', 'Normal:TelescopeNormal')
|
a.nvim_win_set_option(results_win, 'winhl', 'Normal:TelescopeNormal')
|
||||||
a.nvim_win_set_option(results_win, 'winblend', self.window.winblend)
|
a.nvim_win_set_option(results_win, 'winblend', self.window.winblend)
|
||||||
local results_border_win = results_opts.border and results_opts.border.win_id
|
local results_border_win = results_opts.border and results_opts.border.win_id
|
||||||
if results_border_win then vim.api.nvim_win_set_option(results_border_win, 'winhl', 'Normal:TelescopeResultsBorder') end
|
if results_border_win then
|
||||||
|
vim.api.nvim_win_set_option(results_border_win, 'winhl', 'Normal:TelescopeResultsBorder')
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
local preview_win, preview_opts, preview_bufnr
|
local preview_win, preview_opts, preview_bufnr
|
||||||
@@ -339,8 +341,9 @@ function Picker:find()
|
|||||||
a.nvim_win_set_option(preview_win, 'winhl', 'Normal:TelescopeNormal')
|
a.nvim_win_set_option(preview_win, 'winhl', 'Normal:TelescopeNormal')
|
||||||
a.nvim_win_set_option(preview_win, 'winblend', self.window.winblend)
|
a.nvim_win_set_option(preview_win, 'winblend', self.window.winblend)
|
||||||
local preview_border_win = preview_opts and preview_opts.border and preview_opts.border.win_id
|
local preview_border_win = preview_opts and preview_opts.border and preview_opts.border.win_id
|
||||||
if preview_border_win then vim.api.nvim_win_set_option(preview_border_win, 'winhl', 'Normal:TelescopePreviewBorder') end
|
if preview_border_win then
|
||||||
|
vim.api.nvim_win_set_option(preview_border_win, 'winhl', 'Normal:TelescopePreviewBorder')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- TODO: We need to center this and make it prettier...
|
-- TODO: We need to center this and make it prettier...
|
||||||
@@ -407,7 +410,9 @@ function Picker:find()
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local prompt = vim.trim(vim.api.nvim_buf_get_lines(prompt_bufnr, first_line, last_line, false)[1]:sub(#prompt_prefix))
|
local prompt = vim.trim(
|
||||||
|
vim.api.nvim_buf_get_lines(prompt_bufnr, first_line, last_line, false)[1]:sub(#prompt_prefix)
|
||||||
|
)
|
||||||
|
|
||||||
if self.sorter then
|
if self.sorter then
|
||||||
self.sorter:_start(prompt)
|
self.sorter:_start(prompt)
|
||||||
@@ -448,7 +453,8 @@ function Picker:find()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local sort_ok, sort_score = nil, 0
|
local sort_ok
|
||||||
|
local sort_score = 0
|
||||||
if self.sorter then
|
if self.sorter then
|
||||||
sort_ok, sort_score = self:_track("_sort_time", pcall, self.sorter.score, self.sorter, prompt, entry)
|
sort_ok, sort_score = self:_track("_sort_time", pcall, self.sorter.score, self.sorter, prompt, entry)
|
||||||
|
|
||||||
@@ -472,7 +478,7 @@ function Picker:find()
|
|||||||
local process_complete = function()
|
local process_complete = function()
|
||||||
if self:is_done() then return end
|
if self:is_done() then return end
|
||||||
|
|
||||||
-- TODO: We should either: always leave one result or make sure we actually clean up the results when nothing matches
|
-- TODO: Either: always leave one result or make sure we actually clean up the results when nothing matches
|
||||||
if selection_strategy == 'row' then
|
if selection_strategy == 'row' then
|
||||||
if self._selection_row == nil and self.default_selection_index ~= nil then
|
if self._selection_row == nil and self.default_selection_index ~= nil then
|
||||||
self:set_selection(self:get_row(self.default_selection_index))
|
self:set_selection(self:get_row(self.default_selection_index))
|
||||||
@@ -758,7 +764,9 @@ function Picker:set_selection(row)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local caret = '>'
|
local caret = '>'
|
||||||
local display = string.format('%s %s', caret, (a.nvim_buf_get_lines(results_bufnr, row, row + 1, false)[1] or ''):sub(3))
|
local display = string.format('%s %s', caret,
|
||||||
|
(a.nvim_buf_get_lines(results_bufnr, row, row + 1, false)[1] or ''):sub(3)
|
||||||
|
)
|
||||||
|
|
||||||
-- TODO: You should go back and redraw the highlights for this line from the sorter.
|
-- TODO: You should go back and redraw the highlights for this line from the sorter.
|
||||||
-- That's the only smart thing to do.
|
-- That's the only smart thing to do.
|
||||||
@@ -835,7 +843,7 @@ function Picker:entry_adder(index, entry, score)
|
|||||||
-- This is the two spaces to manage the '> ' stuff.
|
-- This is the two spaces to manage the '> ' stuff.
|
||||||
-- Maybe someday we can use extmarks or floaty text or something to draw this and not insert here.
|
-- Maybe someday we can use extmarks or floaty text or something to draw this and not insert here.
|
||||||
-- until then, insert two spaces
|
-- until then, insert two spaces
|
||||||
local prefix = TELESCOPE_DEBUG and (' ' .. score) or ' '
|
local prefix = ' '
|
||||||
display = prefix .. display
|
display = prefix .. display
|
||||||
|
|
||||||
self:_increment("displayed")
|
self:_increment("displayed")
|
||||||
@@ -851,7 +859,12 @@ function Picker:entry_adder(index, entry, score)
|
|||||||
if set_ok and display_highlights then
|
if set_ok and display_highlights then
|
||||||
-- TODO: This should actually be done during the cursor moving stuff annoyingly.... didn't see this bug yesterday.
|
-- TODO: This should actually be done during the cursor moving stuff annoyingly.... didn't see this bug yesterday.
|
||||||
for _, hl_block in ipairs(display_highlights) do
|
for _, hl_block in ipairs(display_highlights) do
|
||||||
a.nvim_buf_add_highlight(self.results_bufnr, ns_telescope_entry, hl_block[2], row, #prefix + hl_block[1][1], #prefix + hl_block[1][2])
|
a.nvim_buf_add_highlight(self.results_bufnr,
|
||||||
|
ns_telescope_entry,
|
||||||
|
hl_block[2],
|
||||||
|
row,
|
||||||
|
#prefix + hl_block[1][1],
|
||||||
|
#prefix + hl_block[1][2])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,46 +1,5 @@
|
|||||||
local log = require('telescope.log')
|
|
||||||
|
|
||||||
local entry_display = {}
|
local entry_display = {}
|
||||||
|
|
||||||
-- index are used to determine the correct order
|
|
||||||
-- elements = {
|
|
||||||
-- [1] = { element, max width }, -- max width should be greater than 0
|
|
||||||
-- [2] = { a, 0 } -- Use 0 to disable max width
|
|
||||||
-- [3] = { b, 0 } -- If b is nil, skip this column, should skip column for all rows
|
|
||||||
-- },
|
|
||||||
-- separator = " " -- either arbitrary string, when you wanna use the same separator between all elements
|
|
||||||
-- separator = { " ", ":" } -- or table, where [1] is separator between elements[1] and elements[2], etc
|
|
||||||
|
|
||||||
-- TODO: Remove this and move ONLY to create method.
|
|
||||||
|
|
||||||
local table_format = function(picker, elements, separator)
|
|
||||||
-- TODO: Truncate...
|
|
||||||
local win_width = vim.api.nvim_win_get_width(picker.results_win)
|
|
||||||
|
|
||||||
local output = ""
|
|
||||||
for k, v in ipairs(elements) do
|
|
||||||
local text = v[1]
|
|
||||||
local width = v[2]
|
|
||||||
if text ~= nil then
|
|
||||||
if k > 1 then
|
|
||||||
output = output .. (type(separator) == "table" and separator[k - 1] or separator)
|
|
||||||
end
|
|
||||||
if width then
|
|
||||||
if width == 0 then
|
|
||||||
output = output .. string.format("%s", text)
|
|
||||||
elseif width < 1 then
|
|
||||||
output = output .. string.format("%-" .. math.floor(width * win_width) .. "s", text)
|
|
||||||
else
|
|
||||||
output = output .. string.format("%-" .. width .."s", text)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
output = output .. text
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return output
|
|
||||||
end
|
|
||||||
|
|
||||||
local function truncate(str, len)
|
local function truncate(str, len)
|
||||||
-- TODO: This doesn't handle multi byte chars...
|
-- TODO: This doesn't handle multi byte chars...
|
||||||
if vim.fn.strdisplaywidth(str) > len then
|
if vim.fn.strdisplaywidth(str) > len then
|
||||||
@@ -94,9 +53,10 @@ entry_display.create = function(configuration)
|
|||||||
|
|
||||||
if configuration.separator_hl then
|
if configuration.separator_hl then
|
||||||
local width = #configuration.separator or 1
|
local width = #configuration.separator or 1
|
||||||
local hl_start, hl_end = 0, 0
|
|
||||||
|
local hl_start, hl_end
|
||||||
for _, v in ipairs(results) do
|
for _, v in ipairs(results) do
|
||||||
hl_start = hl_end + #tostring(v)
|
hl_start = (hl_end or 0) + #tostring(v)
|
||||||
hl_end = hl_start + width
|
hl_end = hl_start + width
|
||||||
table.insert(highlights, { { hl_start, hl_end }, configuration.separator_hl })
|
table.insert(highlights, { { hl_start, hl_end }, configuration.separator_hl })
|
||||||
end
|
end
|
||||||
@@ -122,8 +82,6 @@ entry_display.resolve = function(self, entry)
|
|||||||
|
|
||||||
if type(display) == 'string' then
|
if type(display) == 'string' then
|
||||||
return display, display_highlights
|
return display, display_highlights
|
||||||
elseif type(display) == 'table' then
|
|
||||||
return table_format(self, display, "│"), display_highlights
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ local context_manager = require('plenary.context_manager')
|
|||||||
local conf = require('telescope.config').values
|
local conf = require('telescope.config').values
|
||||||
local debounce = require('telescope.debounce')
|
local debounce = require('telescope.debounce')
|
||||||
local from_entry = require('telescope.from_entry')
|
local from_entry = require('telescope.from_entry')
|
||||||
local log = require('telescope.log')
|
|
||||||
local utils = require('telescope.utils')
|
local utils = require('telescope.utils')
|
||||||
local path = require('telescope.path')
|
local path = require('telescope.path')
|
||||||
|
|
||||||
@@ -332,7 +331,7 @@ previewers.new_buffer_previewer = function(opts)
|
|||||||
self.state.bufnr = get_bufnr_by_bufname(self, self.state.bufname)
|
self.state.bufnr = get_bufnr_by_bufname(self, self.state.bufname)
|
||||||
vim.api.nvim_win_set_buf(status.preview_win, self.state.bufnr)
|
vim.api.nvim_win_set_buf(status.preview_win, self.state.bufnr)
|
||||||
else
|
else
|
||||||
bufnr = vim.api.nvim_create_buf(false, true)
|
local bufnr = vim.api.nvim_create_buf(false, true)
|
||||||
set_bufnr(self, bufnr)
|
set_bufnr(self, bufnr)
|
||||||
|
|
||||||
vim.api.nvim_win_set_buf(status.preview_win, bufnr)
|
vim.api.nvim_win_set_buf(status.preview_win, bufnr)
|
||||||
@@ -454,16 +453,16 @@ previewers.new_termopen_previewer = function(opts)
|
|||||||
}
|
}
|
||||||
|
|
||||||
-- TODO(conni2461): Workaround for neovim/neovim#11751.
|
-- TODO(conni2461): Workaround for neovim/neovim#11751.
|
||||||
local get_cmd = function(status)
|
local get_cmd = function(st)
|
||||||
local shell = vim.o.shell
|
local shell = vim.o.shell
|
||||||
if string.find(shell, 'powershell.exe') or string.find(shell, 'cmd.exe') then
|
if string.find(shell, 'powershell.exe') or string.find(shell, 'cmd.exe') then
|
||||||
return opts.get_command(entry, status)
|
return opts.get_command(entry, st)
|
||||||
else
|
else
|
||||||
local env = {}
|
local env = {}
|
||||||
for k, v in pairs(termopen_env) do
|
for k, v in pairs(termopen_env) do
|
||||||
table.insert(env, k .. '=' .. v)
|
table.insert(env, k .. '=' .. v)
|
||||||
end
|
end
|
||||||
return table.concat(env, ' ') .. ' ' .. table.concat(opts.get_command(entry, status), ' ')
|
return table.concat(env, ' ') .. ' ' .. table.concat(opts.get_command(entry, st), ' ')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -514,7 +513,8 @@ previewers.git_branch_log = defaulter(function(_)
|
|||||||
return previewers.new_termopen_previewer {
|
return previewers.new_termopen_previewer {
|
||||||
get_command = function(entry)
|
get_command = function(entry)
|
||||||
return { 'git', '-p', 'log', '--graph',
|
return { 'git', '-p', 'log', '--graph',
|
||||||
"--pretty=format:" .. add_quotes .. "%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset" .. add_quotes,
|
"--pretty=format:" .. add_quotes .. "%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset"
|
||||||
|
.. add_quotes,
|
||||||
'--abbrev-commit', '--date=relative', entry.value }
|
'--abbrev-commit', '--date=relative', entry.value }
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
@@ -533,10 +533,10 @@ previewers.cat = defaulter(function(opts)
|
|||||||
|
|
||||||
return previewers.new_termopen_previewer {
|
return previewers.new_termopen_previewer {
|
||||||
get_command = function(entry)
|
get_command = function(entry)
|
||||||
local path = from_entry.path(entry, true)
|
local p = from_entry.path(entry, true)
|
||||||
if path == nil or path == '' then return end
|
if p == nil or p == '' then return end
|
||||||
|
|
||||||
return maker(path)
|
return maker(p)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
end, {})
|
end, {})
|
||||||
@@ -569,9 +569,9 @@ previewers.vim_buffer_cat = defaulter(function(_)
|
|||||||
|
|
||||||
define_preview = function(self, entry, status)
|
define_preview = function(self, entry, status)
|
||||||
with_preview_window(status, nil, function()
|
with_preview_window(status, nil, function()
|
||||||
local path = from_entry.path(entry, true)
|
local p = from_entry.path(entry, true)
|
||||||
if path == nil or path == '' then return end
|
if p == nil or p == '' then return end
|
||||||
file_maker_async(path, self.state.bufnr, self.state.bufname)
|
file_maker_async(p, self.state.bufnr, self.state.bufname)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
@@ -598,10 +598,10 @@ previewers.vim_buffer_vimgrep = defaulter(function(_)
|
|||||||
define_preview = function(self, entry, status)
|
define_preview = function(self, entry, status)
|
||||||
with_preview_window(status, nil, function()
|
with_preview_window(status, nil, function()
|
||||||
local lnum = entry.lnum or 0
|
local lnum = entry.lnum or 0
|
||||||
local path = from_entry.path(entry, true)
|
local p = from_entry.path(entry, true)
|
||||||
if path == nil or path == '' then return end
|
if p == nil or p == '' then return end
|
||||||
|
|
||||||
file_maker_sync(path, self.state.bufnr, self.state.bufname)
|
file_maker_sync(p, self.state.bufnr, self.state.bufname)
|
||||||
|
|
||||||
if lnum ~= 0 then
|
if lnum ~= 0 then
|
||||||
if self.state.last_set_bufnr then
|
if self.state.last_set_bufnr then
|
||||||
@@ -739,15 +739,14 @@ previewers.help = defaulter(function(_)
|
|||||||
local escaped = vim.fn.escape(entry.value, special_chars)
|
local escaped = vim.fn.escape(entry.value, special_chars)
|
||||||
local tags = {}
|
local tags = {}
|
||||||
|
|
||||||
local find_rtp_file = function(path, count)
|
local find_rtp_file = function(p, count)
|
||||||
return vim.fn.findfile(path, vim.o.runtimepath, count)
|
return vim.fn.findfile(p, vim.o.runtimepath, count)
|
||||||
end
|
end
|
||||||
|
|
||||||
local matches = {}
|
|
||||||
for _,file in pairs(find_rtp_file('doc/tags', -1)) do
|
for _,file in pairs(find_rtp_file('doc/tags', -1)) do
|
||||||
local f = assert(io.open(file, "rb"))
|
local f = assert(io.open(file, "rb"))
|
||||||
for line in f:lines() do
|
for line in f:lines() do
|
||||||
matches = {}
|
local matches = {}
|
||||||
|
|
||||||
for match in (line..delim):gmatch("(.-)" .. delim) do
|
for match in (line..delim):gmatch("(.-)" .. delim) do
|
||||||
table.insert(matches, match)
|
table.insert(matches, match)
|
||||||
|
|||||||
@@ -79,10 +79,6 @@ utils.quickfix_items_to_entries = function(locations)
|
|||||||
return results
|
return results
|
||||||
end
|
end
|
||||||
|
|
||||||
utils.new_ngram = function()
|
|
||||||
return require("telescope._private.NGram"):new()
|
|
||||||
end
|
|
||||||
|
|
||||||
-- TODO: Figure out how to do this... could include in plenary :)
|
-- TODO: Figure out how to do this... could include in plenary :)
|
||||||
-- NOTE: Don't use this yet. It will segfault sometimes.
|
-- NOTE: Don't use this yet. It will segfault sometimes.
|
||||||
--
|
--
|
||||||
@@ -142,7 +138,7 @@ function utils.buf_delete(bufnr)
|
|||||||
if bufnr == nil then return end
|
if bufnr == nil then return end
|
||||||
|
|
||||||
-- Suppress the buffer deleted message for those with &report<2
|
-- Suppress the buffer deleted message for those with &report<2
|
||||||
start_report = vim.o.report
|
local start_report = vim.o.report
|
||||||
if start_report < 2 then vim.o.report = 2 end
|
if start_report < 2 then vim.o.report = 2 end
|
||||||
|
|
||||||
if vim.api.nvim_buf_is_valid(bufnr) and vim.api.nvim_buf_is_loaded(bufnr) then
|
if vim.api.nvim_buf_is_valid(bufnr) and vim.api.nvim_buf_is_loaded(bufnr) then
|
||||||
|
|||||||
@@ -115,95 +115,6 @@ describe('Picker', function()
|
|||||||
assert.are.same(1, counts_executed)
|
assert.are.same(1, counts_executed)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- describe('ngrams', function()
|
|
||||||
-- it('should capture intself in the ngram', function()
|
|
||||||
-- local n = utils.new_ngram()
|
|
||||||
|
|
||||||
-- n:add("hi")
|
|
||||||
-- assert.are.same(n._grams.hi, {hi = 1})
|
|
||||||
-- end)
|
|
||||||
|
|
||||||
-- it('should have repeated strings count more than once', function()
|
|
||||||
-- local n = utils.new_ngram()
|
|
||||||
|
|
||||||
-- n:add("llll")
|
|
||||||
-- assert.are.same(n._grams.ll, {llll = 3})
|
|
||||||
-- end)
|
|
||||||
|
|
||||||
-- describe('_items_sharing_ngrams', function()
|
|
||||||
-- -- it('should be able to find similar strings', function()
|
|
||||||
-- -- end)
|
|
||||||
-- local n
|
|
||||||
-- before_each(function()
|
|
||||||
-- n = utils.new_ngram()
|
|
||||||
|
|
||||||
-- n:add("SPAM")
|
|
||||||
-- n:add("SPAN")
|
|
||||||
-- n:add("EG")
|
|
||||||
-- end)
|
|
||||||
|
|
||||||
-- it('should find items at the start', function()
|
|
||||||
-- assert.are.same({ SPAM = 1, SPAN = 1 }, n:_items_sharing_ngrams("SP"))
|
|
||||||
-- end)
|
|
||||||
|
|
||||||
-- it('should find items at the end', function()
|
|
||||||
-- assert.are.same({ SPAM = 1, }, n:_items_sharing_ngrams("AM"))
|
|
||||||
-- end)
|
|
||||||
|
|
||||||
-- it('should find items at the end', function()
|
|
||||||
-- assert.are.same({ SPAM = 2, SPAN = 1}, n:_items_sharing_ngrams("PAM"))
|
|
||||||
-- end)
|
|
||||||
-- end)
|
|
||||||
|
|
||||||
-- describe('search', function()
|
|
||||||
-- describe('for simple strings', function()
|
|
||||||
-- local n
|
|
||||||
-- before_each(function()
|
|
||||||
-- n = utils.new_ngram()
|
|
||||||
|
|
||||||
-- n:add("SPAM")
|
|
||||||
-- n:add("SPAN")
|
|
||||||
-- n:add("EG")
|
|
||||||
-- end)
|
|
||||||
|
|
||||||
-- it('should sort for equal cases', function()
|
|
||||||
-- assert.are.same({ "SPAM", "SPAN" }, n:search("SPAM"))
|
|
||||||
-- end)
|
|
||||||
|
|
||||||
-- it('should sort for obvious cases', function()
|
|
||||||
-- assert.are.same({ "SPAM", "SPAN" }, n:search("PAM"))
|
|
||||||
-- end)
|
|
||||||
-- end)
|
|
||||||
|
|
||||||
-- describe('for file paths', function()
|
|
||||||
-- local n
|
|
||||||
-- before_each(function()
|
|
||||||
-- n = utils.new_ngram()
|
|
||||||
|
|
||||||
-- n:add("sho/rt")
|
|
||||||
-- n:add("telescope/init.lua")
|
|
||||||
-- n:add("telescope/utils.lua")
|
|
||||||
-- n:add("telescope/pickers.lua")
|
|
||||||
-- n:add("a/random/file/pickers.lua")
|
|
||||||
-- n:add("microscope/init.lua")
|
|
||||||
-- end)
|
|
||||||
|
|
||||||
-- it("should find exact match", function()
|
|
||||||
-- assert.are.same(n:find("telescope/init.lua"), "telescope/init.lua")
|
|
||||||
-- assert.are.same(n:score("telescope/init.lua"), 1)
|
|
||||||
-- end)
|
|
||||||
|
|
||||||
-- it("should find unique match", function()
|
|
||||||
-- assert.are.same(n:find("micro"), "microscope/init.lua")
|
|
||||||
-- end)
|
|
||||||
|
|
||||||
-- it("should find some match", function()
|
|
||||||
-- assert.are.same(n:find("telini"), "telescope/init.lua")
|
|
||||||
-- end)
|
|
||||||
-- end)
|
|
||||||
-- end)
|
|
||||||
-- end)
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('Sorters', function()
|
describe('Sorters', function()
|
||||||
|
|||||||
Reference in New Issue
Block a user