Skip to content

Commit

Permalink
Fix handling spaces in configured vault directory (#78)
Browse files Browse the repository at this point in the history
Co-authored-by: Pete <[email protected]>
  • Loading branch information
gplusplus314 and epwalsh authored Jan 9, 2023
1 parent 708589b commit 6ad9379
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Made more robust to unexpected types in frontmatter.
- Fixed edge case where frontmatter consisting of exactly one empty field would raise an exception.
- Fixed `:ObsidianFollowLink` not creating a new note when following a dangling link; matches behavior in the official Obsidian app.
- Fixed handling spaces in configured vault directory.
- Fixed `:ObsidianFollowLink` not considering the vault's root directory.

## [v1.6.1](https://github.com/epwalsh/obsidian.nvim/releases/tag/v1.6.1) - 2022-10-17
Expand Down
1 change: 1 addition & 0 deletions lua/obsidian/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ config.ClientOpts.normalize = function(opts)
opts = vim.tbl_extend("force", config.ClientOpts.default(), opts)
opts.completion = vim.tbl_extend("force", config.CompletionOpts.default(), opts.completion)
opts.daily_notes = vim.tbl_extend("force", config.DailyNotesOpts.default(), opts.daily_notes)
opts.dir = vim.fs.normalize(tostring(opts.dir))
return opts
end

Expand Down
6 changes: 3 additions & 3 deletions lua/obsidian/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,18 @@ obsidian.setup = function(opts)

-- Ensure directories exist.
self.dir:mkdir { parents = true, exists_ok = true }
vim.cmd("set path+=" .. tostring(self.dir))
vim.cmd("set path+=" .. vim.fn.fnameescape(tostring(self.dir)))

if self.opts.notes_subdir ~= nil then
local notes_subdir = self.dir / self.opts.notes_subdir
notes_subdir:mkdir { parents = true, exists_ok = true }
vim.cmd("set path+=" .. tostring(notes_subdir))
vim.cmd("set path+=" .. vim.fn.fnameescape(tostring(notes_subdir)))
end

if self.opts.daily_notes.folder ~= nil then
local daily_notes_subdir = self.dir / self.opts.daily_notes.folder
daily_notes_subdir:mkdir { parents = true, exists_ok = true }
vim.cmd("set path+=" .. tostring(daily_notes_subdir))
vim.cmd("set path+=" .. vim.fn.fnameescape(tostring(daily_notes_subdir)))
end

-- Register commands.
Expand Down

0 comments on commit 6ad9379

Please sign in to comment.