jamesroutley / vim-logbook

🗄 A logbook in the comfort of your own vim
MIT License
30 stars 5 forks source link

Error when used for the first time #1

Open Bivectorfoil opened 6 years ago

Bivectorfoil commented 6 years ago

When first used, If the directory <~/logbook> does not exist, in other words, the logbook directory has not been created, "Can't write to file" error will be reported when using command :Lb.

I suggest to add a conditional judgment in the vim-logbook/autoload/logbook.vim file, like this:

if !isdirectory($HOME . "/logbook")
    call mkdir($HOME . "/logbook", "p")
    let logfile = $HOME . "/logbook/" . strftime("%F") . ".md"
    execute "edit " . logfile
else
    let logfile = $HOME . "/logbook/" . strftime("%F") . ".md"
    execute "edit " . logfile
endif

I am a newbie in vimscript, the suggestions above may seem stupid, looking forward to your improvement: )

Newexplorer commented 6 years ago

I have the same problem. "~/logbook/2018-03015.md" E212: Can't open file for writing.