Skip to content

Commit

Permalink
refactor(config): remove testing from user-facing config
Browse files Browse the repository at this point in the history
  • Loading branch information
jghauser committed Jul 4, 2024
1 parent 3f046e9 commit 337e63c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -279,14 +279,9 @@ yq_bin = "yq",
-- Function to execute when adding a new note. `ref` is the citation key of the
-- relevant entry and `notes_name` is the name of the notes file.
create_new_note_fn = function(papis_id, notes_name)
local testing_session = require("papis.config")["enable_modules"]["testing"]
local testing_conf_path = ""
if testing_session then
testing_conf_path = "-c ./tests/papis_config "
end
vim.fn.system(
string.format(
"papis " .. testing_conf_path .. "update --set notes %s papis_id:%s",
"papis update --set notes %s papis_id:%s",
vim.fn.shellescape(notes_name),
vim.fn.shellescape(papis_id)
)
Expand Down
19 changes: 13 additions & 6 deletions lua/papis/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,9 @@ local default_config = {
db_path = vim.fn.stdpath("data") .. "/papis_db/papis-nvim.sqlite3",
yq_bin = "yq",
create_new_note_fn = function(papis_id, notes_name)
local testing_session = require("papis.config").enable_modules["testing"]
local testing_conf_path = ""
if testing_session then
testing_conf_path = "-c ./tests/papis_config "
end
vim.fn.system(
string.format(
"papis " .. testing_conf_path .. "update --set notes %s papis_id:%s",
"papis update --set notes %s papis_id:%s",
vim.fn.shellescape(notes_name),
vim.fn.shellescape(papis_id)
)
Expand Down Expand Up @@ -174,6 +169,18 @@ function M:update(opts)
}
end

if newconf.enable_modules["testing"] == true then
newconf.create_new_note_fn = function(papis_id, notes_name)
vim.fn.system(
string.format(
"papis -c ./tests/papis_config update --set notes %s papis_id:%s",
vim.fn.shellescape(notes_name),
vim.fn.shellescape(papis_id)
)
)
end
end

-- set main config table
for k, v in pairs(newconf) do
self[k] = v
Expand Down

0 comments on commit 337e63c

Please sign in to comment.