mirror of
https://github.com/kristoferssolo/telescope-frecency.nvim.git
synced 2025-10-21 20:10:38 +00:00
fix: fix type names to avoid conflicting (#186)
This commit is contained in:
parent
dde0b71e40
commit
9126d6bc0c
@ -2,8 +2,8 @@ local Table = require "frecency.database.table"
|
||||
local FileLock = require "frecency.file_lock"
|
||||
local watcher = require "frecency.watcher"
|
||||
local log = require "plenary.log"
|
||||
local async = require "plenary.async" --[[@as PlenaryAsync]]
|
||||
local Path = require "plenary.path" --[[@as PlenaryPath]]
|
||||
local async = require "plenary.async" --[[@as FrecencyPlenaryAsync]]
|
||||
local Path = require "plenary.path" --[[@as FrecencyPlenaryPath]]
|
||||
|
||||
---@class FrecencyDatabaseConfig
|
||||
---@field root string
|
||||
@ -19,7 +19,7 @@ local Path = require "plenary.path" --[[@as PlenaryPath]]
|
||||
---@field score number
|
||||
|
||||
---@class FrecencyDatabase
|
||||
---@field tx PlenaryAsyncControlChannelTx
|
||||
---@field tx FrecencyPlenaryAsyncControlChannelTx
|
||||
---@field private config FrecencyDatabaseConfig
|
||||
---@field private file_lock FrecencyFileLock
|
||||
---@field private filename string
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
local Path = require "plenary.path" --[[@as PlenaryPath]]
|
||||
local entry_display = require "telescope.pickers.entry_display" --[[@as TelescopeEntryDisplay]]
|
||||
local utils = require "telescope.utils" --[[@as TelescopeUtils]]
|
||||
local Path = require "plenary.path" --[[@as FrecencyPlenaryPath]]
|
||||
local entry_display = require "telescope.pickers.entry_display" --[[@as FrecencyTelescopeEntryDisplay]]
|
||||
local utils = require "telescope.utils" --[[@as FrecencyTelescopeUtils]]
|
||||
|
||||
---@class FrecencyEntryMaker
|
||||
---@field config FrecencyEntryMakerConfig
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
local async = require "plenary.async" --[[@as PlenaryAsync]]
|
||||
local async = require "plenary.async" --[[@as FrecencyPlenaryAsync]]
|
||||
local log = require "plenary.log"
|
||||
|
||||
---@class FrecencyFileLock
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
local os_util = require "frecency.os_util"
|
||||
local Job = require "plenary.job"
|
||||
local async = require "plenary.async" --[[@as PlenaryAsync]]
|
||||
local async = require "plenary.async" --[[@as FrecencyPlenaryAsync]]
|
||||
local log = require "plenary.log"
|
||||
|
||||
---@class FrecencyFinder
|
||||
@ -12,10 +12,10 @@ local log = require "plenary.log"
|
||||
---@field fs FrecencyFS
|
||||
---@field path string?
|
||||
---@field private database FrecencyDatabase
|
||||
---@field private rx PlenaryAsyncControlChannelRx
|
||||
---@field private tx PlenaryAsyncControlChannelTx
|
||||
---@field private scan_rx PlenaryAsyncControlChannelRx
|
||||
---@field private scan_tx PlenaryAsyncControlChannelTx
|
||||
---@field private rx FrecencyPlenaryAsyncControlChannelRx
|
||||
---@field private tx FrecencyPlenaryAsyncControlChannelTx
|
||||
---@field private scan_rx FrecencyPlenaryAsyncControlChannelRx
|
||||
---@field private scan_tx FrecencyPlenaryAsyncControlChannelTx
|
||||
---@field private need_scan_db boolean
|
||||
---@field private need_scan_dir boolean
|
||||
---@field private seen table<string, boolean>
|
||||
@ -226,7 +226,7 @@ end
|
||||
---@async
|
||||
---@param process_result fun(entry: FrecencyEntry): nil
|
||||
---@param entries FrecencyEntry[]
|
||||
---@param rx PlenaryAsyncControlChannelRx
|
||||
---@param rx FrecencyPlenaryAsyncControlChannelRx
|
||||
---@param start_index integer?
|
||||
---@return boolean?
|
||||
function Finder:process_channel(process_result, entries, rx, start_index)
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
local os_util = require "frecency.os_util"
|
||||
local Path = require "plenary.path" --[[@as PlenaryPath]]
|
||||
local Path = require "plenary.path" --[[@as FrecencyPlenaryPath]]
|
||||
local scandir = require "plenary.scandir"
|
||||
local log = require "plenary.log"
|
||||
local uv = vim.uv or vim.loop
|
||||
|
||||
@ -2,11 +2,11 @@ local State = require "frecency.state"
|
||||
local Finder = require "frecency.finder"
|
||||
local sorters = require "telescope.sorters"
|
||||
local log = require "plenary.log"
|
||||
local Path = require "plenary.path" --[[@as PlenaryPath]]
|
||||
local Path = require "plenary.path" --[[@as FrecencyPlenaryPath]]
|
||||
local actions = require "telescope.actions"
|
||||
local config_values = require("telescope.config").values
|
||||
local pickers = require "telescope.pickers"
|
||||
local utils = require "telescope.utils" --[[@as TelescopeUtils]]
|
||||
local utils = require "telescope.utils" --[[@as FrecencyTelescopeUtils]]
|
||||
local uv = vim.loop or vim.uv
|
||||
|
||||
---@class FrecencyPicker
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
---@class FrecencyState
|
||||
---@field picker TelescopePicker?
|
||||
---@field picker FrecencyTelescopePicker?
|
||||
local State = {}
|
||||
|
||||
---@return FrecencyState
|
||||
@ -7,13 +7,13 @@ State.new = function()
|
||||
return setmetatable({}, { __index = State, __meta = "kv" })
|
||||
end
|
||||
|
||||
---@param picker TelescopePicker?
|
||||
---@param picker FrecencyTelescopePicker?
|
||||
---@return nil
|
||||
function State:set(picker)
|
||||
self.picker = picker
|
||||
end
|
||||
|
||||
---@return TelescopePicker?
|
||||
---@return FrecencyTelescopePicker?
|
||||
function State:get()
|
||||
return self.picker
|
||||
end
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
local FS = require "frecency.fs"
|
||||
local Database = require "frecency.database"
|
||||
local async = require "plenary.async" --[[@as PlenaryAsync]]
|
||||
local async = require "plenary.async" --[[@as FrecencyPlenaryAsync]]
|
||||
local util = require "frecency.tests.util"
|
||||
async.tests.add_to_env()
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
---@diagnostic disable: undefined-field
|
||||
local FileLock = require "frecency.file_lock"
|
||||
local util = require "frecency.tests.util"
|
||||
local async = require "plenary.async" --[[@as PlenaryAsync]]
|
||||
local async = require "plenary.async" --[[@as FrecencyPlenaryAsync]]
|
||||
require("plenary.async").tests.add_to_env()
|
||||
|
||||
local function with_dir(f)
|
||||
|
||||
@ -11,8 +11,8 @@ local Path = require "plenary.path"
|
||||
local config = require "frecency.config"
|
||||
|
||||
---@param files string[]
|
||||
---@param cb_or_config table|fun(frecency: Frecency, finder: FrecencyFinder, dir: PlenaryPath): nil
|
||||
---@param callback? fun(frecency: Frecency, finder: FrecencyFinder, dir: PlenaryPath): nil
|
||||
---@param cb_or_config table|fun(frecency: Frecency, finder: FrecencyFinder, dir: FrecencyPlenaryPath): nil
|
||||
---@param callback? fun(frecency: Frecency, finder: FrecencyFinder, dir: FrecencyPlenaryPath): nil
|
||||
---@return nil
|
||||
local function with_files(files, cb_or_config, callback)
|
||||
local dir, close = util.make_tree(files)
|
||||
@ -45,7 +45,7 @@ local function filepath(dir, file)
|
||||
end
|
||||
|
||||
---@param frecency Frecency
|
||||
---@param dir PlenaryPath
|
||||
---@param dir FrecencyPlenaryPath
|
||||
---@return fun(file: string, datetime: string, reset: boolean?): nil
|
||||
local function make_register(frecency, dir)
|
||||
return function(file, datetime, reset)
|
||||
@ -60,7 +60,7 @@ local function make_register(frecency, dir)
|
||||
end
|
||||
|
||||
---@param frecency Frecency
|
||||
---@param dir PlenaryPath
|
||||
---@param dir FrecencyPlenaryPath
|
||||
---@param callback fun(register: fun(file: string, datetime: string?): nil): nil
|
||||
---@return nil
|
||||
local function with_fake_register(frecency, dir, callback)
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
local uv = vim.uv or vim.loop
|
||||
local async = require "plenary.async" --[[@as PlenaryAsync]]
|
||||
local async = require "plenary.async" --[[@as FrecencyPlenaryAsync]]
|
||||
local Path = require "plenary.path"
|
||||
local Job = require "plenary.job"
|
||||
local wait = require "frecency.tests.wait"
|
||||
|
||||
---@return PlenaryPath
|
||||
---@return FrecencyPlenaryPath
|
||||
---@return fun(): nil close swwp all entries
|
||||
local function tmpdir()
|
||||
local dir = Path:new(Path:new(assert(uv.fs_mkdtemp "tests_XXXXXX")):absolute())
|
||||
@ -14,7 +14,7 @@ local function tmpdir()
|
||||
end
|
||||
|
||||
---@param entries string[]
|
||||
---@return PlenaryPath dir the top dir of tree
|
||||
---@return FrecencyPlenaryPath dir the top dir of tree
|
||||
---@return fun(): nil close sweep all entries
|
||||
local function make_tree(entries)
|
||||
local dir, close = tmpdir()
|
||||
|
||||
@ -2,19 +2,19 @@
|
||||
|
||||
-- NOTE: types are borrowed from plenary.nvim
|
||||
|
||||
---@class PlenaryPath
|
||||
---@field new fun(self: PlenaryPath|string, path: string?): PlenaryPath
|
||||
---@class FrecencyPlenaryPath
|
||||
---@field new fun(self: FrecencyPlenaryPath|string, path: string?): FrecencyPlenaryPath
|
||||
---@field absolute fun(): string
|
||||
---@field is_file fun(self: PlenaryPath): boolean
|
||||
---@field is_file fun(self: FrecencyPlenaryPath): boolean
|
||||
---@field filename string
|
||||
---@field joinpath fun(self: PlenaryPath, ...): PlenaryPath
|
||||
---@field make_relative fun(self: PlenaryPath, cwd: string): string
|
||||
---@field parent PlenaryPath
|
||||
---@field joinpath fun(self: FrecencyPlenaryPath, ...): FrecencyPlenaryPath
|
||||
---@field make_relative fun(self: FrecencyPlenaryPath, cwd: string): string
|
||||
---@field parent FrecencyPlenaryPath
|
||||
---@field path { sep: string }
|
||||
---@field rm fun(self: PlenaryPath, opts: { recursive: boolean }?): nil
|
||||
---@field touch fun(self: PlenaryPath, opts: { parents: boolean }?): nil
|
||||
---@field rm fun(self: FrecencyPlenaryPath, opts: { recursive: boolean }?): nil
|
||||
---@field touch fun(self: FrecencyPlenaryPath, opts: { parents: boolean }?): nil
|
||||
|
||||
---@class PlenaryScanDirOptions
|
||||
---@class FrecencyPlenaryScanDirOptions
|
||||
---@field hidden boolean if true hidden files will be added
|
||||
---@field add_dirs boolean if true dirs will also be added to the results
|
||||
---@field only_dirs boolean if true only dirs will be added to the results
|
||||
@ -24,49 +24,49 @@
|
||||
---@field on_insert fun(path: string): boolean Will be called for each element
|
||||
---@field silent boolean if true will not echo messages that are not accessible
|
||||
|
||||
---@alias scan_dir fun(path: string, opts: PlenaryScanDirOptions): string[]
|
||||
---@alias scan_dir fun(path: string, opts: FrecencyPlenaryScanDirOptions): string[]
|
||||
|
||||
---@class PlenaryAsync
|
||||
---@field control PlenaryAsyncControl
|
||||
---@class FrecencyPlenaryAsync
|
||||
---@field control FrecencyPlenaryAsyncControl
|
||||
---@field tests { add_to_env: fun(): nil }
|
||||
---@field util PlenaryAsyncUtil
|
||||
---@field uv PlenaryAsyncUv
|
||||
---@field util FrecencyPlenaryAsyncUtil
|
||||
---@field uv FrecencyPlenaryAsyncUv
|
||||
---@field void fun(f: fun(): nil): fun(): nil
|
||||
---@field wrap fun(f: (fun(...): any), args: integer): (fun(...): any)
|
||||
local PlenaryAsync = {}
|
||||
local FrecencyPlenaryAsync = {}
|
||||
|
||||
---@async
|
||||
---@param f fun(): nil
|
||||
---@return nil
|
||||
function PlenaryAsync.run(f) end
|
||||
function FrecencyPlenaryAsync.run(f) end
|
||||
|
||||
---@class PlenaryAsyncControl
|
||||
---@field channel PlenaryAsyncControlChannel
|
||||
---@class FrecencyPlenaryAsyncControl
|
||||
---@field channel FrecencyPlenaryAsyncControlChannel
|
||||
|
||||
---@class PlenaryAsyncControlChannel
|
||||
---@field mpsc fun(): PlenaryAsyncControlChannelTx, PlenaryAsyncControlChannelRx
|
||||
---@field counter fun(): PlenaryAsyncControlChannelTx, PlenaryAsyncControlChannelRx
|
||||
---@class FrecencyPlenaryAsyncControlChannel
|
||||
---@field mpsc fun(): FrecencyPlenaryAsyncControlChannelTx, FrecencyPlenaryAsyncControlChannelRx
|
||||
---@field counter fun(): FrecencyPlenaryAsyncControlChannelTx, FrecencyPlenaryAsyncControlChannelRx
|
||||
|
||||
---@class PlenaryAsyncControlChannelTx
|
||||
---@class FrecencyPlenaryAsyncControlChannelTx
|
||||
---@field send fun(entry: any?): nil
|
||||
local PlenaryAsyncControlChannelTx = {}
|
||||
local FrecencyPlenaryAsyncControlChannelTx = {}
|
||||
|
||||
---@class PlenaryAsyncControlChannelRx
|
||||
local PlenaryAsyncControlChannelRx = {}
|
||||
---@class FrecencyPlenaryAsyncControlChannelRx
|
||||
local FrecencyPlenaryAsyncControlChannelRx = {}
|
||||
|
||||
---@async
|
||||
---@return any?
|
||||
function PlenaryAsyncControlChannelRx.recv() end
|
||||
function FrecencyPlenaryAsyncControlChannelRx.recv() end
|
||||
|
||||
---@async
|
||||
---@return any?
|
||||
function PlenaryAsyncControlChannelRx.last() end
|
||||
function FrecencyPlenaryAsyncControlChannelRx.last() end
|
||||
|
||||
---@class PlenaryAsyncUtil
|
||||
local PlenaryAsyncUtil = {}
|
||||
---@class FrecencyPlenaryAsyncUtil
|
||||
local FrecencyPlenaryAsyncUtil = {}
|
||||
|
||||
---@class PlenaryAsyncUv
|
||||
local PlenaryAsyncUv = {}
|
||||
---@class FrecencyPlenaryAsyncUv
|
||||
local FrecencyPlenaryAsyncUv = {}
|
||||
|
||||
---@class FsStatMtime
|
||||
---@field sec integer
|
||||
@ -81,7 +81,7 @@ local PlenaryAsyncUv = {}
|
||||
---@param path string
|
||||
---@return string? err
|
||||
---@return { mtime: FsStatMtime, size: integer, type: "file"|"directory" }
|
||||
function PlenaryAsyncUv.fs_stat(path) end
|
||||
function FrecencyPlenaryAsyncUv.fs_stat(path) end
|
||||
|
||||
---@async
|
||||
---@param path string
|
||||
@ -89,7 +89,7 @@ function PlenaryAsyncUv.fs_stat(path) end
|
||||
---@param mode integer
|
||||
---@return string? err
|
||||
---@return integer fd
|
||||
function PlenaryAsyncUv.fs_open(path, flags, mode) end
|
||||
function FrecencyPlenaryAsyncUv.fs_open(path, flags, mode) end
|
||||
|
||||
---@async
|
||||
---@param fd integer
|
||||
@ -97,7 +97,7 @@ function PlenaryAsyncUv.fs_open(path, flags, mode) end
|
||||
---@param offset integer?
|
||||
---@return string? err
|
||||
---@return string data
|
||||
function PlenaryAsyncUv.fs_read(fd, size, offset) end
|
||||
function FrecencyPlenaryAsyncUv.fs_read(fd, size, offset) end
|
||||
|
||||
---@async
|
||||
---@param fd integer
|
||||
@ -105,56 +105,56 @@ function PlenaryAsyncUv.fs_read(fd, size, offset) end
|
||||
---@param offset integer?
|
||||
---@return string? err
|
||||
---@return integer bytes
|
||||
function PlenaryAsyncUv.fs_write(fd, data, offset) end
|
||||
function FrecencyPlenaryAsyncUv.fs_write(fd, data, offset) end
|
||||
|
||||
---@async
|
||||
---@param path string
|
||||
---@return string? err
|
||||
---@return boolean? success
|
||||
function PlenaryAsyncUv.fs_unlink(path) end
|
||||
function FrecencyPlenaryAsyncUv.fs_unlink(path) end
|
||||
|
||||
---@async
|
||||
---@param fd integer
|
||||
---@return string? err
|
||||
function PlenaryAsyncUv.fs_close(fd) end
|
||||
function FrecencyPlenaryAsyncUv.fs_close(fd) end
|
||||
|
||||
---@async
|
||||
---@param ms integer
|
||||
---@return nil
|
||||
function PlenaryAsyncUtil.sleep(ms) end
|
||||
function FrecencyPlenaryAsyncUtil.sleep(ms) end
|
||||
|
||||
---@async
|
||||
---@return nil
|
||||
function PlenaryAsyncUtil.scheduler() end
|
||||
function FrecencyPlenaryAsyncUtil.scheduler() end
|
||||
|
||||
-- NOTE: types are for telescope.nvim
|
||||
|
||||
---@alias TelescopeEntryDisplayer fun(items: string[]): table
|
||||
---@alias FrecencyTelescopeEntryDisplayer fun(items: string[]): table
|
||||
|
||||
---@class TelescopeEntryDisplayOptions
|
||||
---@class FrecencyTelescopeEntryDisplayOptions
|
||||
---@field separator string?
|
||||
---@field hl_chars table<string, string>?
|
||||
---@field items string[]
|
||||
|
||||
---@class TelescopeEntryDisplay
|
||||
---@field create fun(opts: TelescopeEntryDisplayOptions): TelescopeEntryDisplayer
|
||||
---@class FrecencyTelescopeEntryDisplay
|
||||
---@field create fun(opts: FrecencyTelescopeEntryDisplayOptions): FrecencyTelescopeEntryDisplayer
|
||||
|
||||
---@class TelescopeUtils
|
||||
---@class FrecencyTelescopeUtils
|
||||
---@field path_tail fun(path: string): string
|
||||
---@field transform_path fun(opts: table, path: string): string
|
||||
---@field buf_is_loaded fun(filename: string): boolean
|
||||
|
||||
---@class TelescopePicker
|
||||
---@field clear_extra_rows fun(self: TelescopePicker, results_bufnr: integer): nil
|
||||
---@field get_row fun(self: TelescopePicker, index: integer): integer
|
||||
---@field manager TelescopeEntryManager|false
|
||||
---@class FrecencyTelescopePicker
|
||||
---@field clear_extra_rows fun(self: FrecencyTelescopePicker, results_bufnr: integer): nil
|
||||
---@field get_row fun(self: FrecencyTelescopePicker, index: integer): integer
|
||||
---@field manager FrecencyTelescopeEntryManager|false
|
||||
---@field prompt_bufnr integer
|
||||
---@field prompt_prefix string
|
||||
---@field results_bufnr integer?
|
||||
---@field results_win integer?
|
||||
---@field sorting_strategy 'ascending'|'descending'
|
||||
|
||||
---@class TelescopeEntryManager
|
||||
---@class FrecencyTelescopeEntryManager
|
||||
---@field num_results fun(): integer
|
||||
|
||||
-- NOTE: types for default functions
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
local async = require "plenary.async" --[[@as PlenaryAsync]]
|
||||
local async = require "plenary.async" --[[@as FrecencyPlenaryAsync]]
|
||||
local log = require "plenary.log"
|
||||
local uv = vim.loop or vim.uv
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user