diff --git a/lua/telescope/_extensions/frecency.lua b/lua/telescope/_extensions/frecency.lua index 86008a6..360428a 100644 --- a/lua/telescope/_extensions/frecency.lua +++ b/lua/telescope/_extensions/frecency.lua @@ -117,10 +117,9 @@ local frecency = function(opts) local make_display = function(entry) bufnr = vim.fn.bufnr buf_is_loaded = vim.api.nvim_buf_is_loaded - - filename = entry.name - hl_filename = buf_is_loaded(bufnr(filename)) and "TelescopeBufferLoaded" or "" - filename = format_filepath(filename, opts) + filename = entry.name + hl_filename = buf_is_loaded(bufnr(filename)) and "TelescopeBufferLoaded" or "" + filename = format_filepath(filename, opts) display_items = state.show_scores and {{entry.score, "TelescopeFrecencyScores"}} or {} @@ -256,13 +255,14 @@ end return telescope.register_extension { setup = function(ext_config) + set_config_state('db_root', ext_config.db_root, nil) set_config_state('show_scores', ext_config.show_scores, false) set_config_state('show_unindexed', ext_config.show_unindexed, true) set_config_state('show_filter_column', ext_config.show_filter_column, true) set_config_state('user_workspaces', ext_config.workspaces, {}) -- start the database client - db_client.init(ext_config.ignore_patterns, ext_config.db_safe_mode or true, ext_config.auto_validate or true) + db_client.init(ext_config.db_root, ext_config.ignore_patterns, ext_config.db_safe_mode or true, ext_config.auto_validate or true) end, exports = { frecency = frecency, diff --git a/lua/telescope/_extensions/frecency/db_client.lua b/lua/telescope/_extensions/frecency/db_client.lua index f8fb6dd..a5d64e0 100644 --- a/lua/telescope/_extensions/frecency/db_client.lua +++ b/lua/telescope/_extensions/frecency/db_client.lua @@ -85,10 +85,11 @@ local function validate_db(safe_mode) end end -local function init(config_ignore_patterns, safe_mode, auto_validate) +-- TODO: make init params a keyed table +local function init(db_root, config_ignore_patterns, safe_mode, auto_validate) if sql_wrapper then return end sql_wrapper = sqlwrap:new() - local first_run = sql_wrapper:bootstrap() + local first_run = sql_wrapper:bootstrap(db_root) ignore_patterns = config_ignore_patterns or default_ignore_patterns if auto_validate then diff --git a/lua/telescope/_extensions/frecency/sql_wrapper.lua b/lua/telescope/_extensions/frecency/sql_wrapper.lua index 3c2f4d3..8af1291 100644 --- a/lua/telescope/_extensions/frecency/sql_wrapper.lua +++ b/lua/telescope/_extensions/frecency/sql_wrapper.lua @@ -34,14 +34,14 @@ function M:new() return o end -function M:bootstrap(opts) +function M:bootstrap(db_root) if self.db then return end - opts = opts or {} - self.max_entries = opts.max_entries or 2000 + -- opts = opts or {} + -- self.max_entries = opts.max_entries or 2000 -- create the db if it doesn't exist - local db_root = opts.docs_root or vim.fn.stdpath('data') + db_root = db_root or vim.fn.stdpath('data') local db_filename = db_root .. "/file_frecency.sqlite3" self.db = sql:open(db_filename) if not self.db then