mirror of
https://github.com/kristoferssolo/telescope-frecency.nvim.git
synced 2025-10-21 20:10:38 +00:00
feat: make database location configurable
This commit is contained in:
parent
8b6f4b8981
commit
65a7d89eb8
@ -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,
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user