Add g:mbnotes_rename_on_save

This commit is contained in:
Max Bucknell 2025-01-11 01:44:04 +00:00
parent a9ed31593f
commit de06a2087c
No known key found for this signature in database
6 changed files with 15 additions and 4 deletions

1
.gitignore vendored
View file

@ -1 +1,2 @@
/doc/tags
__pycache__

View file

@ -64,7 +64,7 @@ export def BeforeNoteSave()
var daily_path = g:mbnotes_dir .. "/daily"
# Don't touch daily notes
if daily_path != full_path[0 : len(daily_path) - 1]
if g:mbnotes_rename_on_save && daily_path != full_path[0 : len(daily_path) - 1]
var base = expand('%:t')
var date = base[0 : 9]

View file

@ -130,6 +130,14 @@ If none of the above are defined, and this variable is not set explicitly, then
the render commands (e.g. |:MBNotesRenderPDF|) will not open the output file
after rendering.
g:mbnotes_rename_on_save *g:mbnotes_rename_on_save*
This plugin will attempt to intelligently rename a note based on its title,
which is the first H1 that it finds in the document. Disable this behaviour by
setting this variable to false >vim
let g:mbnotes_rename_on_save = 0
==============================================================================
4. Commands *mbnotes-commands*

View file

@ -41,6 +41,10 @@ if !exists("g:mbnotes_date_format_long")
g:mbnotes_date_format_long = "%A, %-e %B %Y"
endif
if !exists("g:mbnotes_rename_on_save")
g:mbnotes_rename_on_save = 1
endif
import autoload 'mbnotes.vim'
augroup MBNotes

View file

@ -27,6 +27,4 @@ def generate_daily_note(date_offset = 0):
date_format = vim.eval("g:mbnotes_date_format_long")
date = date.strftime(date_format)
author = vim.eval("g:mbnotes_author")
return daily_template.substitute(date=date, author=author)
return daily_template.substitute(date=date)