Open uloco opened 1 month ago
I recommend you to try with lazy.nvim and a minimal config.
@delphinus How is the my package manager related to this issue? All other plugins I am using don't cause any problems.
I can't support envs with deprecated products. Especially, plugin managers are the fundamental product that can cause various problems. I cannot debug them because I'm not the author of packer.nvim.
I created a minimal config with lazy.nvim, still the same issue. Reproduction steps are there in the readme. https://github.com/uloco/repro-frecency-background-issue
Oh, yes. Thank you. I could reproduce it with macOS and Wezterm. I will look into further.
Hmm... I found this diff below can solve this. But why……
diff --git a/lua/frecency/database.lua b/lua/frecency/database.lua
index 27c5bf4..af24a4e 100644
--- a/lua/frecency/database.lua
+++ b/lua/frecency/database.lua
@@ -30,6 +30,7 @@ Database.new = function(fs)
tbl = Table.new(version),
version = version,
}, { __index = Database })
+ self.tbl:set()
self.filename = (function()
-- NOTE: for backward compatibility
-- If the user does not set db_root specifically, search DB in
Maybe, vim.wait
causes this, I think.
diff --git a/lua/frecency/database.lua b/lua/frecency/database.lua
index 27c5bf4..79c197e 100644
--- a/lua/frecency/database.lua
+++ b/lua/frecency/database.lua
@@ -70,7 +70,7 @@ end
---@return boolean
function Database:has_entry()
- return not vim.tbl_isempty(self.tbl.records)
+ return not vim.tbl_isempty(self.tbl and self.tbl.records or {})
end
---@param paths string[]
@@ -80,7 +80,9 @@ function Database:insert_files(paths)
return
end
for _, path in ipairs(paths) do
- self.tbl.records[path] = { count = 1, timestamps = { 0 } }
+ if self.tbl and self.tbl.records then
+ self.tbl.records[path] = { count = 1, timestamps = { 0 } }
+ end
end
self.tx.send "save"
end
@@ -88,7 +90,7 @@ end
---@return string[]
function Database:unlinked_entries()
local paths = {}
- for file in pairs(self.tbl.records) do
+ for file in pairs(self.tbl.records or {}) do
if not self.fs:is_valid_path(file) then
table.insert(paths, file)
end
diff --git a/lua/frecency/database/table.lua b/lua/frecency/database/table.lua
index 79a4945..34ed094 100644
--- a/lua/frecency/database/table.lua
+++ b/lua/frecency/database/table.lua
@@ -48,7 +48,8 @@ end
---@return nil
function Table:wait_ready()
vim.wait(2000, function()
- return rawget(self, "is_ready")
+ -- return rawget(self, "is_ready")
+ return true
end)
end
@uloco FYI
I still have been inquiring, but a stopgap measure exists for this.
This problem is caused by calling telescope.load_extension "frecency"
in startup. In fact, this is not needed for calling frecency by commands, such as :Telescope frecency
.
require("lazy").setup({
"nvim-lua/plenary.nvim",
"nvim-telescope/telescope.nvim",
"nvim-telescope/telescope-frecency.nvim",
})
vim.keymap.set("n", ",tf", "<CMD>Telescope frecency<CR>")
With this setup, you can call :Telescope frecency
with no errors. But you want to call by Lua code, such as code below, then you need load_extension
before that.
local loaded
vim.keymap.set("n", ",tf", function()
local telescope = require "telescope"
if not loaded then
telescope.load_extension "frecency"
loaded = true
end
telescope.extensions.frecency.frecency {}
end)
I found #213 can solve this. But I can't understand the reason. 🤔 🤔 🤔
I think nvim introduced changes regarding the detection when they introduced the default theme. On my phone right now, I can post more later.
I unfortunately can't find the changes anymore.... But I think they set some default background when it takes too long to load a plugin or so. Can't remember sorry.
Could this PR, change be the reason? https://github.com/neovim/neovim/pull/28676/files
I have no idea how this is related but I am on nvim 0.10.0 and this is my used config in packer:
When I enable this plugin and my terminal background is light, neovim accidentally sets background to dark. I removed all other plugins to test this and it is only causing the issue when installed.