From 0611482899150bfe3a02afa3dc256ffb58298e9a Mon Sep 17 00:00:00 2001 From: delphinus Date: Wed, 26 Jul 2023 10:16:33 +0900 Subject: [PATCH] hoge --- lua/frecency/database.lua | 3 ++- lua/frecency/db.lua | 3 +-- lua/frecency/fs.lua | 16 +++++++++++++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/lua/frecency/database.lua b/lua/frecency/database.lua index a4c7852d..508e38ce 100644 --- a/lua/frecency/database.lua +++ b/lua/frecency/database.lua @@ -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 @@ -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 diff --git a/lua/frecency/db.lua b/lua/frecency/db.lua index 2cf401b4..161b0579 100644 --- a/lua/frecency/db.lua +++ b/lua/frecency/db.lua @@ -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 diff --git a/lua/frecency/fs.lua b/lua/frecency/fs.lua index 0d217a20..d9a9737b 100644 --- a/lua/frecency/fs.lua +++ b/lua/frecency/fs.lua @@ -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[] @@ -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, { @@ -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 @@ -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