fix: fix type names to avoid conflicting (#186)

This commit is contained in:
JINNOUCHI Yasushi 2024-03-23 16:49:39 +09:00 committed by GitHub
parent dde0b71e40
commit 9126d6bc0c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 78 additions and 78 deletions

View File

@ -2,8 +2,8 @@ local Table = require "frecency.database.table"
local FileLock = require "frecency.file_lock" local FileLock = require "frecency.file_lock"
local watcher = require "frecency.watcher" local watcher = require "frecency.watcher"
local log = require "plenary.log" local log = require "plenary.log"
local async = require "plenary.async" --[[@as PlenaryAsync]] local async = require "plenary.async" --[[@as FrecencyPlenaryAsync]]
local Path = require "plenary.path" --[[@as PlenaryPath]] local Path = require "plenary.path" --[[@as FrecencyPlenaryPath]]
---@class FrecencyDatabaseConfig ---@class FrecencyDatabaseConfig
---@field root string ---@field root string
@ -19,7 +19,7 @@ local Path = require "plenary.path" --[[@as PlenaryPath]]
---@field score number ---@field score number
---@class FrecencyDatabase ---@class FrecencyDatabase
---@field tx PlenaryAsyncControlChannelTx ---@field tx FrecencyPlenaryAsyncControlChannelTx
---@field private config FrecencyDatabaseConfig ---@field private config FrecencyDatabaseConfig
---@field private file_lock FrecencyFileLock ---@field private file_lock FrecencyFileLock
---@field private filename string ---@field private filename string

View File

@ -1,6 +1,6 @@
local Path = require "plenary.path" --[[@as PlenaryPath]] local Path = require "plenary.path" --[[@as FrecencyPlenaryPath]]
local entry_display = require "telescope.pickers.entry_display" --[[@as TelescopeEntryDisplay]] local entry_display = require "telescope.pickers.entry_display" --[[@as FrecencyTelescopeEntryDisplay]]
local utils = require "telescope.utils" --[[@as TelescopeUtils]] local utils = require "telescope.utils" --[[@as FrecencyTelescopeUtils]]
---@class FrecencyEntryMaker ---@class FrecencyEntryMaker
---@field config FrecencyEntryMakerConfig ---@field config FrecencyEntryMakerConfig

View File

@ -1,4 +1,4 @@
local async = require "plenary.async" --[[@as PlenaryAsync]] local async = require "plenary.async" --[[@as FrecencyPlenaryAsync]]
local log = require "plenary.log" local log = require "plenary.log"
---@class FrecencyFileLock ---@class FrecencyFileLock

View File

@ -1,6 +1,6 @@
local os_util = require "frecency.os_util" local os_util = require "frecency.os_util"
local Job = require "plenary.job" local Job = require "plenary.job"
local async = require "plenary.async" --[[@as PlenaryAsync]] local async = require "plenary.async" --[[@as FrecencyPlenaryAsync]]
local log = require "plenary.log" local log = require "plenary.log"
---@class FrecencyFinder ---@class FrecencyFinder
@ -12,10 +12,10 @@ local log = require "plenary.log"
---@field fs FrecencyFS ---@field fs FrecencyFS
---@field path string? ---@field path string?
---@field private database FrecencyDatabase ---@field private database FrecencyDatabase
---@field private rx PlenaryAsyncControlChannelRx ---@field private rx FrecencyPlenaryAsyncControlChannelRx
---@field private tx PlenaryAsyncControlChannelTx ---@field private tx FrecencyPlenaryAsyncControlChannelTx
---@field private scan_rx PlenaryAsyncControlChannelRx ---@field private scan_rx FrecencyPlenaryAsyncControlChannelRx
---@field private scan_tx PlenaryAsyncControlChannelTx ---@field private scan_tx FrecencyPlenaryAsyncControlChannelTx
---@field private need_scan_db boolean ---@field private need_scan_db boolean
---@field private need_scan_dir boolean ---@field private need_scan_dir boolean
---@field private seen table<string, boolean> ---@field private seen table<string, boolean>
@ -226,7 +226,7 @@ end
---@async ---@async
---@param process_result fun(entry: FrecencyEntry): nil ---@param process_result fun(entry: FrecencyEntry): nil
---@param entries FrecencyEntry[] ---@param entries FrecencyEntry[]
---@param rx PlenaryAsyncControlChannelRx ---@param rx FrecencyPlenaryAsyncControlChannelRx
---@param start_index integer? ---@param start_index integer?
---@return boolean? ---@return boolean?
function Finder:process_channel(process_result, entries, rx, start_index) function Finder:process_channel(process_result, entries, rx, start_index)

View File

@ -1,5 +1,5 @@
local os_util = require "frecency.os_util" 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 scandir = require "plenary.scandir"
local log = require "plenary.log" local log = require "plenary.log"
local uv = vim.uv or vim.loop local uv = vim.uv or vim.loop

View File

@ -2,11 +2,11 @@ local State = require "frecency.state"
local Finder = require "frecency.finder" local Finder = require "frecency.finder"
local sorters = require "telescope.sorters" local sorters = require "telescope.sorters"
local log = require "plenary.log" 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 actions = require "telescope.actions"
local config_values = require("telescope.config").values local config_values = require("telescope.config").values
local pickers = require "telescope.pickers" 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 local uv = vim.loop or vim.uv
---@class FrecencyPicker ---@class FrecencyPicker

View File

@ -1,5 +1,5 @@
---@class FrecencyState ---@class FrecencyState
---@field picker TelescopePicker? ---@field picker FrecencyTelescopePicker?
local State = {} local State = {}
---@return FrecencyState ---@return FrecencyState
@ -7,13 +7,13 @@ State.new = function()
return setmetatable({}, { __index = State, __meta = "kv" }) return setmetatable({}, { __index = State, __meta = "kv" })
end end
---@param picker TelescopePicker? ---@param picker FrecencyTelescopePicker?
---@return nil ---@return nil
function State:set(picker) function State:set(picker)
self.picker = picker self.picker = picker
end end
---@return TelescopePicker? ---@return FrecencyTelescopePicker?
function State:get() function State:get()
return self.picker return self.picker
end end

View File

@ -1,6 +1,6 @@
local FS = require "frecency.fs" local FS = require "frecency.fs"
local Database = require "frecency.database" 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" local util = require "frecency.tests.util"
async.tests.add_to_env() async.tests.add_to_env()

View File

@ -1,7 +1,7 @@
---@diagnostic disable: undefined-field ---@diagnostic disable: undefined-field
local FileLock = require "frecency.file_lock" local FileLock = require "frecency.file_lock"
local util = require "frecency.tests.util" 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() require("plenary.async").tests.add_to_env()
local function with_dir(f) local function with_dir(f)

View File

@ -11,8 +11,8 @@ local Path = require "plenary.path"
local config = require "frecency.config" local config = require "frecency.config"
---@param files string[] ---@param files string[]
---@param cb_or_config table|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: PlenaryPath): nil ---@param callback? fun(frecency: Frecency, finder: FrecencyFinder, dir: FrecencyPlenaryPath): nil
---@return nil ---@return nil
local function with_files(files, cb_or_config, callback) local function with_files(files, cb_or_config, callback)
local dir, close = util.make_tree(files) local dir, close = util.make_tree(files)
@ -45,7 +45,7 @@ local function filepath(dir, file)
end end
---@param frecency Frecency ---@param frecency Frecency
---@param dir PlenaryPath ---@param dir FrecencyPlenaryPath
---@return fun(file: string, datetime: string, reset: boolean?): nil ---@return fun(file: string, datetime: string, reset: boolean?): nil
local function make_register(frecency, dir) local function make_register(frecency, dir)
return function(file, datetime, reset) return function(file, datetime, reset)
@ -60,7 +60,7 @@ local function make_register(frecency, dir)
end end
---@param frecency Frecency ---@param frecency Frecency
---@param dir PlenaryPath ---@param dir FrecencyPlenaryPath
---@param callback fun(register: fun(file: string, datetime: string?): nil): nil ---@param callback fun(register: fun(file: string, datetime: string?): nil): nil
---@return nil ---@return nil
local function with_fake_register(frecency, dir, callback) local function with_fake_register(frecency, dir, callback)

View File

@ -1,10 +1,10 @@
local uv = vim.uv or vim.loop 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 Path = require "plenary.path"
local Job = require "plenary.job" local Job = require "plenary.job"
local wait = require "frecency.tests.wait" local wait = require "frecency.tests.wait"
---@return PlenaryPath ---@return FrecencyPlenaryPath
---@return fun(): nil close swwp all entries ---@return fun(): nil close swwp all entries
local function tmpdir() local function tmpdir()
local dir = Path:new(Path:new(assert(uv.fs_mkdtemp "tests_XXXXXX")):absolute()) local dir = Path:new(Path:new(assert(uv.fs_mkdtemp "tests_XXXXXX")):absolute())
@ -14,7 +14,7 @@ local function tmpdir()
end end
---@param entries string[] ---@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 ---@return fun(): nil close sweep all entries
local function make_tree(entries) local function make_tree(entries)
local dir, close = tmpdir() local dir, close = tmpdir()

View File

@ -2,19 +2,19 @@
-- NOTE: types are borrowed from plenary.nvim -- NOTE: types are borrowed from plenary.nvim
---@class PlenaryPath ---@class FrecencyPlenaryPath
---@field new fun(self: PlenaryPath|string, path: string?): PlenaryPath ---@field new fun(self: FrecencyPlenaryPath|string, path: string?): FrecencyPlenaryPath
---@field absolute fun(): string ---@field absolute fun(): string
---@field is_file fun(self: PlenaryPath): boolean ---@field is_file fun(self: FrecencyPlenaryPath): boolean
---@field filename string ---@field filename string
---@field joinpath fun(self: PlenaryPath, ...): PlenaryPath ---@field joinpath fun(self: FrecencyPlenaryPath, ...): FrecencyPlenaryPath
---@field make_relative fun(self: PlenaryPath, cwd: string): string ---@field make_relative fun(self: FrecencyPlenaryPath, cwd: string): string
---@field parent PlenaryPath ---@field parent FrecencyPlenaryPath
---@field path { sep: string } ---@field path { sep: string }
---@field rm fun(self: PlenaryPath, opts: { recursive: boolean }?): nil ---@field rm fun(self: FrecencyPlenaryPath, opts: { recursive: boolean }?): nil
---@field touch fun(self: PlenaryPath, opts: { parents: 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 hidden boolean if true hidden files will be added
---@field add_dirs boolean if true dirs will also be added to the results ---@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 ---@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 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 ---@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 ---@class FrecencyPlenaryAsync
---@field control PlenaryAsyncControl ---@field control FrecencyPlenaryAsyncControl
---@field tests { add_to_env: fun(): nil } ---@field tests { add_to_env: fun(): nil }
---@field util PlenaryAsyncUtil ---@field util FrecencyPlenaryAsyncUtil
---@field uv PlenaryAsyncUv ---@field uv FrecencyPlenaryAsyncUv
---@field void fun(f: fun(): nil): fun(): nil ---@field void fun(f: fun(): nil): fun(): nil
---@field wrap fun(f: (fun(...): any), args: integer): (fun(...): any) ---@field wrap fun(f: (fun(...): any), args: integer): (fun(...): any)
local PlenaryAsync = {} local FrecencyPlenaryAsync = {}
---@async ---@async
---@param f fun(): nil ---@param f fun(): nil
---@return nil ---@return nil
function PlenaryAsync.run(f) end function FrecencyPlenaryAsync.run(f) end
---@class PlenaryAsyncControl ---@class FrecencyPlenaryAsyncControl
---@field channel PlenaryAsyncControlChannel ---@field channel FrecencyPlenaryAsyncControlChannel
---@class PlenaryAsyncControlChannel ---@class FrecencyPlenaryAsyncControlChannel
---@field mpsc fun(): PlenaryAsyncControlChannelTx, PlenaryAsyncControlChannelRx ---@field mpsc fun(): FrecencyPlenaryAsyncControlChannelTx, FrecencyPlenaryAsyncControlChannelRx
---@field counter fun(): PlenaryAsyncControlChannelTx, PlenaryAsyncControlChannelRx ---@field counter fun(): FrecencyPlenaryAsyncControlChannelTx, FrecencyPlenaryAsyncControlChannelRx
---@class PlenaryAsyncControlChannelTx ---@class FrecencyPlenaryAsyncControlChannelTx
---@field send fun(entry: any?): nil ---@field send fun(entry: any?): nil
local PlenaryAsyncControlChannelTx = {} local FrecencyPlenaryAsyncControlChannelTx = {}
---@class PlenaryAsyncControlChannelRx ---@class FrecencyPlenaryAsyncControlChannelRx
local PlenaryAsyncControlChannelRx = {} local FrecencyPlenaryAsyncControlChannelRx = {}
---@async ---@async
---@return any? ---@return any?
function PlenaryAsyncControlChannelRx.recv() end function FrecencyPlenaryAsyncControlChannelRx.recv() end
---@async ---@async
---@return any? ---@return any?
function PlenaryAsyncControlChannelRx.last() end function FrecencyPlenaryAsyncControlChannelRx.last() end
---@class PlenaryAsyncUtil ---@class FrecencyPlenaryAsyncUtil
local PlenaryAsyncUtil = {} local FrecencyPlenaryAsyncUtil = {}
---@class PlenaryAsyncUv ---@class FrecencyPlenaryAsyncUv
local PlenaryAsyncUv = {} local FrecencyPlenaryAsyncUv = {}
---@class FsStatMtime ---@class FsStatMtime
---@field sec integer ---@field sec integer
@ -81,7 +81,7 @@ local PlenaryAsyncUv = {}
---@param path string ---@param path string
---@return string? err ---@return string? err
---@return { mtime: FsStatMtime, size: integer, type: "file"|"directory" } ---@return { mtime: FsStatMtime, size: integer, type: "file"|"directory" }
function PlenaryAsyncUv.fs_stat(path) end function FrecencyPlenaryAsyncUv.fs_stat(path) end
---@async ---@async
---@param path string ---@param path string
@ -89,7 +89,7 @@ function PlenaryAsyncUv.fs_stat(path) end
---@param mode integer ---@param mode integer
---@return string? err ---@return string? err
---@return integer fd ---@return integer fd
function PlenaryAsyncUv.fs_open(path, flags, mode) end function FrecencyPlenaryAsyncUv.fs_open(path, flags, mode) end
---@async ---@async
---@param fd integer ---@param fd integer
@ -97,7 +97,7 @@ function PlenaryAsyncUv.fs_open(path, flags, mode) end
---@param offset integer? ---@param offset integer?
---@return string? err ---@return string? err
---@return string data ---@return string data
function PlenaryAsyncUv.fs_read(fd, size, offset) end function FrecencyPlenaryAsyncUv.fs_read(fd, size, offset) end
---@async ---@async
---@param fd integer ---@param fd integer
@ -105,56 +105,56 @@ function PlenaryAsyncUv.fs_read(fd, size, offset) end
---@param offset integer? ---@param offset integer?
---@return string? err ---@return string? err
---@return integer bytes ---@return integer bytes
function PlenaryAsyncUv.fs_write(fd, data, offset) end function FrecencyPlenaryAsyncUv.fs_write(fd, data, offset) end
---@async ---@async
---@param path string ---@param path string
---@return string? err ---@return string? err
---@return boolean? success ---@return boolean? success
function PlenaryAsyncUv.fs_unlink(path) end function FrecencyPlenaryAsyncUv.fs_unlink(path) end
---@async ---@async
---@param fd integer ---@param fd integer
---@return string? err ---@return string? err
function PlenaryAsyncUv.fs_close(fd) end function FrecencyPlenaryAsyncUv.fs_close(fd) end
---@async ---@async
---@param ms integer ---@param ms integer
---@return nil ---@return nil
function PlenaryAsyncUtil.sleep(ms) end function FrecencyPlenaryAsyncUtil.sleep(ms) end
---@async ---@async
---@return nil ---@return nil
function PlenaryAsyncUtil.scheduler() end function FrecencyPlenaryAsyncUtil.scheduler() end
-- NOTE: types are for telescope.nvim -- 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 separator string?
---@field hl_chars table<string, string>? ---@field hl_chars table<string, string>?
---@field items string[] ---@field items string[]
---@class TelescopeEntryDisplay ---@class FrecencyTelescopeEntryDisplay
---@field create fun(opts: TelescopeEntryDisplayOptions): TelescopeEntryDisplayer ---@field create fun(opts: FrecencyTelescopeEntryDisplayOptions): FrecencyTelescopeEntryDisplayer
---@class TelescopeUtils ---@class FrecencyTelescopeUtils
---@field path_tail fun(path: string): string ---@field path_tail fun(path: string): string
---@field transform_path fun(opts: table, path: string): string ---@field transform_path fun(opts: table, path: string): string
---@field buf_is_loaded fun(filename: string): boolean ---@field buf_is_loaded fun(filename: string): boolean
---@class TelescopePicker ---@class FrecencyTelescopePicker
---@field clear_extra_rows fun(self: TelescopePicker, results_bufnr: integer): nil ---@field clear_extra_rows fun(self: FrecencyTelescopePicker, results_bufnr: integer): nil
---@field get_row fun(self: TelescopePicker, index: integer): integer ---@field get_row fun(self: FrecencyTelescopePicker, index: integer): integer
---@field manager TelescopeEntryManager|false ---@field manager FrecencyTelescopeEntryManager|false
---@field prompt_bufnr integer ---@field prompt_bufnr integer
---@field prompt_prefix string ---@field prompt_prefix string
---@field results_bufnr integer? ---@field results_bufnr integer?
---@field results_win integer? ---@field results_win integer?
---@field sorting_strategy 'ascending'|'descending' ---@field sorting_strategy 'ascending'|'descending'
---@class TelescopeEntryManager ---@class FrecencyTelescopeEntryManager
---@field num_results fun(): integer ---@field num_results fun(): integer
-- NOTE: types for default functions -- NOTE: types for default functions

View File

@ -1,4 +1,4 @@
local async = require "plenary.async" --[[@as PlenaryAsync]] local async = require "plenary.async" --[[@as FrecencyPlenaryAsync]]
local log = require "plenary.log" local log = require "plenary.log"
local uv = vim.loop or vim.uv local uv = vim.loop or vim.uv