Skip to content

Commit 542eff0

Browse files
author
jghauser
committed
feat: default format_function_fn for markdown, not norg
1 parent 6234a84 commit 542eff0

File tree

2 files changed

+9
-25
lines changed

2 files changed

+9
-25
lines changed

README.md

+6-14
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Commands:
5757

5858
![formatter_trimmed](https://user-images.githubusercontent.com/10319377/193469179-35e1a3b5-bad6-4289-a9ae-586dc9b3af8a.gif)
5959

60-
When creating new notes (via `:Telescope papis` or `:PapisOpenNote`), papis.nvim can be set up to format the new note with a custom function. You can, for example, give the note a title that corresponds to the entry's title or provide it with a skeleton structure. Below, in the setup section, there's an example suitable for the `.norg` format.
60+
When creating new notes (via `:Telescope papis` or `:PapisOpenNote`), papis.nvim can be set up to format the new note with a custom function. You can, for example, give the note a title that corresponds to the entry's title or provide it with a skeleton structure. Below, in the setup section, there's an example suitable for the `markdown` format.
6161

6262
## The database
6363

@@ -338,7 +338,7 @@ init_filetypes = { "markdown", "norg", "yaml" },
338338

339339
-- This function runs when first opening a new note. The `entry` arg is a table
340340
-- containing all the information about the entry (see above `data_tbl_schema`).
341-
-- This example is meant to be used with the `.norg` filetype.
341+
-- This example is meant to be used with the `markdown` filetype.
342342
format_notes_fn = function(entry)
343343
-- Some string formatting templates (see above `results_format` option for
344344
-- more details)
@@ -348,24 +348,16 @@ init_filetypes = { "markdown", "norg", "yaml" },
348348
{ "title", "%s", "" },
349349
}
350350
-- Format the strings with information in the entry
351-
local title = require("papis.utils"):format_display_strings(entry, title_format)
351+
local title = require("papis.utils"):format_display_strings(entry, title_format, true)
352352
-- Grab only the strings (and disregard highlight groups)
353353
for k, v in ipairs(title) do
354354
title[k] = v[1]
355355
end
356356
-- Define all the lines to be inserted
357357
local lines = {
358-
"@document.meta",
359-
"title: " .. table.concat(title),
360-
"description: ",
361-
"categories: [",
362-
" notes",
363-
" academia",
364-
" readings",
365-
"]",
366-
"created: " .. os.date("%Y-%m-%d"),
367-
"version: " .. require("neorg.config").version,
368-
"@end",
358+
"---",
359+
"title: Notes -- " .. table.concat(title),
360+
"---",
369361
"",
370362
}
371363
-- Insert the lines

lua/papis/config.lua

+3-11
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,9 @@ local default_config = {
7878
title[k] = v[1]
7979
end
8080
local lines = {
81-
"@document.meta",
82-
"title: " .. table.concat(title),
83-
"categories: [",
84-
" notes",
85-
" academia",
86-
" readings",
87-
"]",
88-
"created: " .. os.date("%Y-%m-%d"),
89-
"updated: " .. os.date("%Y-%m-%d"),
90-
"version: " .. require("neorg.core.config").norg_version,
91-
"@end",
81+
"---",
82+
[[title: "Notes -- ]] .. table.concat(title) .. [["]],
83+
"---",
9284
"",
9385
}
9486
vim.api.nvim_buf_set_lines(0, 0, #lines, false, lines)

0 commit comments

Comments
 (0)