Skip to content

Commit

Permalink
hoge
Browse files Browse the repository at this point in the history
  • Loading branch information
delphinus committed Aug 3, 2023
1 parent 93130ed commit 7dc382c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 10 deletions.
31 changes: 23 additions & 8 deletions lua/frecency/frecency.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ local WebDevicons = require "frecency.web_devicons"

---@class Frecency
---@field config FrecencyConfig
---@field picker FrecencyPicker
---@field private buf_registered table<integer, boolean> flag to indicate the buffer is registered to the database.
---@field private database FrecencyDatabase
---@field private finder FrecencyFinder
---@field private fs FrecencyFS
---@field private picker FrecencyPicker
---@field private recency FrecencyRecency
local Frecency = {}

Expand Down Expand Up @@ -55,14 +56,8 @@ Frecency.new = function(opts)
show_filter_column = config.show_filter_column,
show_scores = config.show_scores,
})
local finder = Finder.new(entry_maker, self.fs)
self.finder = Finder.new(entry_maker, self.fs)
self.recency = Recency.new()
self.picker = Picker.new(self.database, finder, self.fs, self.recency, {
default_workspace = config.default_workspace,
filter_delimiter = config.filter_delimiter,
show_unindexed = config.show_unindexed,
workspaces = config.workspaces,
})
return self
end

Expand Down Expand Up @@ -94,6 +89,26 @@ function Frecency:setup()
})
end

---@param opts FrecencyPickerOptions
---@return nil
function Frecency:start(opts)
self.picker = Picker.new(self.database, self.finder, self.fs, self.recency, {
default_workspace = self.config.default_workspace,
filter_delimiter = self.config.filter_delimiter,
initial_workspace = opts.workspace,
show_unindexed = self.config.show_unindexed,
workspaces = self.config.workspaces,
})
self.picker:start(opts)
end

---@param findstart 1|0
---@param base string
---@return integer|''|string[]
function Frecency:complete(findstart, base)
return self.picker:complete(findstart, base)
end

---@param force boolean?
---@return nil
function Frecency:validate_database(force)
Expand Down
4 changes: 2 additions & 2 deletions lua/frecency/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ return {
end,
start = function(opts)
if frecency then
frecency.picker:start(opts)
frecency:start(opts)
end
end,
complete = function(findstart, base)
if frecency then
return frecency.picker:complete(findstart, base)
return frecency:complete(findstart, base)
end
end,
frecency = function()
Expand Down
1 change: 1 addition & 0 deletions lua/frecency/picker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ local Path = require "plenary.path"
---@class FrecencyPickerConfig
---@field default_workspace string
---@field filter_delimiter string
---@field initial_workspace string?
---@field show_unindexed boolean
---@field workspaces table<string, string>

Expand Down

0 comments on commit 7dc382c

Please sign in to comment.