mirror of
https://github.com/kristoferssolo/telescope-frecency.nvim.git
synced 2025-10-21 20:10:38 +00:00
* refactor: simplify logic to load web_devicons * refactor: make register() asynchronous * fix: load lazily modules outside this plugin * refactor: simplify logic to wait initialization * refactor: use uv.hrtime() instead of os.clock() * fix: avoid errors in calling plenary.log in async * test: store elapsed time to check in tests * test: fix module names This becomes a problem only in Ubuntu because macOS and Windows does not care cases in filenames. * test: fix types and unused modules * style: fix by stylua * refactor: make recency / entry_maker loaded lazily
33 lines
911 B
Lua
33 lines
911 B
Lua
local lazy_require = require "frecency.lazy_require"
|
|
local Path = lazy_require "plenary.path" --[[@as FrecencyPlenaryPath]]
|
|
local uv = vim.uv or vim.loop
|
|
|
|
---@class FrecencyOSUtil
|
|
local M = {
|
|
is_windows = uv.os_uname().sysname == "Windows_NT",
|
|
}
|
|
|
|
---@type fun(filename: string): string
|
|
M.normalize_sep = M.is_windows
|
|
and function(filename)
|
|
if not filename:find("/", 1, true) or filename:match "^%a+://" then
|
|
return filename
|
|
end
|
|
local replaced = filename:gsub("/", Path.path.sep)
|
|
return replaced
|
|
end
|
|
or function(filename)
|
|
return filename
|
|
end
|
|
|
|
--- Join path segments into a single path string.
|
|
--- NOTE: Do not use vim.fs.joinpath because it does not work on Windows.
|
|
---@type fun(...: string): string
|
|
M.join_path = M.is_windows and function(...)
|
|
return M.normalize_sep(Path:new(...).filename)
|
|
end or function(...)
|
|
return Path:new(...).filename
|
|
end
|
|
|
|
return M
|