diff --git a/UltiSnips/mbnotes.snippets b/UltiSnips/mbnotes.snippets index c4d88cd..f91a7ad 100644 --- a/UltiSnips/mbnotes.snippets +++ b/UltiSnips/mbnotes.snippets @@ -45,7 +45,7 @@ endsnippet # Code -snippet `r "R Code Block" b +snippet rcode "R Code Block" b \`\`\`{r} ${1:#| output: ${2:false}} ${3:#| echo: ${4:false}} @@ -53,7 +53,7 @@ ${0:${VISUAL:# code...}} \`\`\` endsnippet -snippet `py "Python Code Block" b +snippet pycode "Python Code Block" b \`\`\`{python} ${1:#| output: ${2:false}} ${3:#| echo: ${4:false}} diff --git a/autoload/mbnotes.vim b/autoload/mbnotes.vim index b86fce1..b5c4b33 100644 --- a/autoload/mbnotes.vim +++ b/autoload/mbnotes.vim @@ -68,10 +68,11 @@ enddef export def BeforeNoteSave() var full_path = expand('%:p') + var directory = expand('%:p:h') var daily_path = g:mbnotes_dir .. "/daily" - # Don't touch daily notes - if g:mbnotes_rename_on_save && daily_path != full_path[0 : len(daily_path) - 1] + # Only rename bona fide notes + if directory != expand(g:mbnotes_dir) var base = expand('%:t') var date = base[0 : 9] @@ -83,7 +84,7 @@ export def BeforeNoteSave() var title_line = search('^#\s\+') if title_line == 0 - throw "Unable to save note: No title found." + return endif var title = substitute(getline(title_line), '^#\s\+', '', '') @@ -97,13 +98,14 @@ export def BeforeNoteSave() normal! `s setpos("'s", original_mark) - b:new_name = date .. "_" .. sanitised .. ".qmd" + b:new_name = fnameescape(expand('%:p:h')) .. "/" .. date .. "_" .. sanitised .. ".qmd" endif enddef export def AfterNoteSave() if exists("b:new_name") - execute "silent Move " .. fnameescape(g:mbnotes_dir) .. "/" .. b:new_name + execute "silent Move " .. b:new_name + unlet b:new_name endif enddef diff --git a/plugin/mbnotes.vim b/plugin/mbnotes.vim index 89fbbdc..0468a75 100644 --- a/plugin/mbnotes.vim +++ b/plugin/mbnotes.vim @@ -16,7 +16,7 @@ if !exists("g:mbnotes_dir") echoerr "MBNotes: Error: g:mbnotes_dir not set." finish else - silent mkdir(fnameescape(g:mbnotes_dir .. "/daily"), "p") + silent mkdir(g:mbnotes_dir .. "/daily", "p") endif if !exists("g:mbnotes_out_dir") diff --git a/python3/mbnotes.py b/python3/mbnotes.py index 4ae196d..a004365 100644 --- a/python3/mbnotes.py +++ b/python3/mbnotes.py @@ -1,12 +1,7 @@ import vim from string import Template from datetime import datetime, timedelta -daily_template = Template("""--- -title: "Daily Note" -date: "$date" ---- - -# $date +daily_template = Template("""# $date ## Daily Note