diff options
| author | srdusr <trevorgray@srdusr.com> | 2023-09-01 10:16:40 +0200 |
|---|---|---|
| committer | srdusr <trevorgray@srdusr.com> | 2023-09-01 10:16:40 +0200 |
| commit | 60ba15bd72f0da554ef645bc2c7a50511b0224d9 (patch) | |
| tree | d486baeb1ab9ae8e555ed180602b00da273b5b11 /lua/user/mods.lua | |
| parent | e5716618f750a9f2d8b33f851406a074ed1f1ae3 (diff) | |
| download | dotfiles-60ba15bd72f0da554ef645bc2c7a50511b0224d9.tar.gz dotfiles-60ba15bd72f0da554ef645bc2c7a50511b0224d9.zip | |
Create the directory if it does not exist for scratch()
Diffstat (limited to 'lua/user/mods.lua')
| -rw-r--r-- | lua/user/mods.lua | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lua/user/mods.lua b/lua/user/mods.lua index 0b7f406..63b3ac0 100644 --- a/lua/user/mods.lua +++ b/lua/user/mods.lua @@ -614,12 +614,16 @@ end -- Function to create or toggle a scratch buffer function M.Scratch() - local scratch_dir = vim.fn.expand('~') + local scratch_dir = vim.fn.expand('~/notes/private') local scratch_date = os.date('%Y-%m-%d') - local scratch_file = 'notes-' .. scratch_date .. '.md' + local scratch_file = 'scratch-' .. scratch_date .. '.md' local scratch_buf = vim.fn.bufnr(scratch_file) local bufinfo = vim.fn.getbufinfo(scratch_buf) + -- Check if the directory exists, and create it if it doesn't + if vim.fn.isdirectory(scratch_dir) == 0 then + vim.fn.mkdir(scratch_dir, 'p') + end if scratch_buf == -1 then -- If the buffer doesn't exist, create it vim.cmd('vsplit ' .. scratch_dir .. '/' .. scratch_file) |
