mirror of
https://github.com/kristoferssolo/telescope-frecency.nvim.git
synced 2025-10-21 20:10:38 +00:00
use vim.startswith instead of utils string function
This commit is contained in:
parent
098edfc941
commit
a770d59b92
@ -13,7 +13,6 @@ local path = require('telescope.path')
|
|||||||
local pickers = require "telescope.pickers"
|
local pickers = require "telescope.pickers"
|
||||||
local sorters = require "telescope.sorters"
|
local sorters = require "telescope.sorters"
|
||||||
local utils = require('telescope.utils')
|
local utils = require('telescope.utils')
|
||||||
local frecency_utils = require("telescope._extensions.frecency.util")
|
|
||||||
|
|
||||||
local os_home = vim.loop.os_homedir()
|
local os_home = vim.loop.os_homedir()
|
||||||
local os_path_sep = utils.get_separator()
|
local os_path_sep = utils.get_separator()
|
||||||
@ -56,7 +55,7 @@ local frecency = function(opts)
|
|||||||
filename = utils.path_shorten(filename)
|
filename = utils.path_shorten(filename)
|
||||||
else -- check relative to home/current
|
else -- check relative to home/current
|
||||||
filename = path.make_relative(filename, cwd)
|
filename = path.make_relative(filename, cwd)
|
||||||
if frecency_utils.string_starts(filename, os_home) then
|
if vim.startswith(filename, os_home) then
|
||||||
filename = "~/" .. path.make_relative(filename, os_home)
|
filename = "~/" .. path.make_relative(filename, os_home)
|
||||||
elseif filename ~= original_filename then
|
elseif filename ~= original_filename then
|
||||||
filename = "./" .. filename
|
filename = "./" .. filename
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
local sqlwrap = require("telescope._extensions.frecency.sql_wrapper")
|
local sqlwrap = require("telescope._extensions.frecency.sql_wrapper")
|
||||||
local util = require("telescope._extensions.frecency.util")
|
local util = require("telescope._extensions.frecency.util")
|
||||||
local conf = require('telescope.config').values
|
|
||||||
|
|
||||||
local MAX_TIMESTAMPS = 10
|
local MAX_TIMESTAMPS = 10
|
||||||
local DB_REMOVE_SAFETY_THRESHOLD = 10
|
local DB_REMOVE_SAFETY_THRESHOLD = 10
|
||||||
|
|
||||||
@ -79,7 +77,6 @@ end
|
|||||||
|
|
||||||
local function init(config_ignore_patterns)
|
local function init(config_ignore_patterns)
|
||||||
if sql_wrapper then return end
|
if sql_wrapper then return end
|
||||||
|
|
||||||
sql_wrapper = sqlwrap:new()
|
sql_wrapper = sqlwrap:new()
|
||||||
local first_run = sql_wrapper:bootstrap()
|
local first_run = sql_wrapper:bootstrap()
|
||||||
validate_db()
|
validate_db()
|
||||||
@ -126,14 +123,14 @@ end
|
|||||||
local function filter_workspace(filelist, workspace_path)
|
local function filter_workspace(filelist, workspace_path)
|
||||||
local res = {}
|
local res = {}
|
||||||
for _, entry in pairs(filelist) do
|
for _, entry in pairs(filelist) do
|
||||||
if util.string_starts(entry.path, workspace_path) then
|
if vim.startwith(entry.path, workspace_path) then
|
||||||
table.insert(res, entry)
|
table.insert(res, entry)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return res
|
return res
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_file_scores(opts)
|
local function get_file_scores(opts) -- TODO: no need to pass in all opts here
|
||||||
if not sql_wrapper then return {} end
|
if not sql_wrapper then return {} end
|
||||||
|
|
||||||
local queries = sql_wrapper.queries
|
local queries = sql_wrapper.queries
|
||||||
|
|||||||
@ -24,10 +24,6 @@ util.string_isempty = function(str)
|
|||||||
return str == nil or str == ''
|
return str == nil or str == ''
|
||||||
end
|
end
|
||||||
|
|
||||||
util.string_starts = function(str, token)
|
|
||||||
return str:sub(1, token:len()) == token
|
|
||||||
end
|
|
||||||
|
|
||||||
util.string_ends = function(str, token)
|
util.string_ends = function(str, token)
|
||||||
return str:sub(str:len() - token:len() + 1, -1) == token
|
return str:sub(str:len() - token:len() + 1, -1) == token
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user