Skip to content

Commit

Permalink
hoge
Browse files Browse the repository at this point in the history
  • Loading branch information
delphinus committed Jul 26, 2023
1 parent f8279ad commit 0611482
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lua/frecency/database.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local scandir = require "plenary.scandir" --[[@as { scan_dir: scan_dir }]]
local sqlite = require "sqlite"
local log = require "frecency.log"

---@class FrecencyDatabaseConfig
---@field auto_validate boolean
Expand Down Expand Up @@ -78,6 +78,7 @@ end
---@return FrecencyFile[]
function Database:get_files(workspace)
local query = workspace and { contains = { path = { workspace .. "*" } } } or {}
log:debug("%s", { query = query })
return self.sqlite.files:get(query)
end

Expand Down
3 changes: 1 addition & 2 deletions lua/frecency/db.lua
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ function db.get_files(opts)
end

if opts.ws_path and opts.show_unindexed then
--util.include_unindexed(files, opts.ws_path)
log:debug("%s", opts)
util.include_unindexed(files, opts.ws_path)
end

return files
Expand Down
16 changes: 15 additions & 1 deletion lua/frecency/fs.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
local Path = require "plenary.path" --[[@as PlenaryPath]]
local scandir = require "plenary.scandir"
local log = require "frecency.log"

---@class FrecencyFS
---@field private ignore_regexes string[]
Expand Down Expand Up @@ -28,6 +30,8 @@ end

---@param path string
function FS:scan_dir(path)
log:debug("%s", { path = path })
local gitignore = self:make_gitignore(path)
return coroutine.wrap(function()
for name, type in
vim.fs.dir(path, {
Expand All @@ -39,7 +43,8 @@ function FS:scan_dir(path)
end,
})
do
if type == "file" and not self:is_ignored(vim.fs.joinpath(path, name)) then
local fullpath = vim.fs.joinpath(path, name)
if type == "file" and not self:is_ignored(fullpath) and gitignore({ path }, fullpath) then
coroutine.yield(name)
end
end
Expand All @@ -58,4 +63,13 @@ function FS:is_ignored(path)
return false
end

---@private
---@param basepath string
---@return fun(base_paths: string[], entry: string): boolean
function FS:make_gitignore(basepath)
return scandir.__make_gitignore { basepath } or function(_, _)
return true
end
end

return FS

0 comments on commit 0611482

Please sign in to comment.