Open avastmick opened 2 months ago
Sorry, update, the behaviour is now regardless of the number of wiki locations: I thought it was working for one, but it was actually creating files in the wrong place.
Hi @avastmick! Thanks for reporting this issue. I have two questions though.
Hi @avastmick! Thanks for reporting this issue. I have two questions though.
- Is the index file created in the correct location for these two wiki locations?
- This path trimming is failing only when the notes are created from the wiki note?
Firstly, yes, an index.md
is created.
Secondly, yes, when I create a new note the path is duplicated as per the screenshot in the OP.
I spent a bit of time trying to reproduce and when I create two empty wiki, the path handling is consistent with your GH README. In fact, I thought that the issue was resolved and all good. However, when I return to either wiki with an index.md
created (say in a new nvim
session), any new pages show the path duplication issue.
The path issue only occurs on an existing wiki. The behaviour is consistent. Have an index.md
, create a new page, and the page is created in a nonexistent path that is duplicated.
Could this be a plugin clash? My list of plugins are as follows:
.
├── alpha-nvim.lua
├── cmp.lua
├── db-ui.lua
├── harpoon.lua
├── init.lua
├── kiwi.lua
├── leap.lua
├── lsp.lua
├── lualine.lua
├── neogit.lua
├── no-neck-pain.lua
├── noice.lua
├── oil.lua
├── rustaceanvim.lua
├── surround.lua
├── telescope.lua
├── themes.lua
├── todo-comments.lua
├── treesitter.lua
├── undotree.lua
└── which-key.lua
Thanks for the work on this and getting back so promptly on the issue I raised. The issue may be found between the computer and the chair 😀
Thank you for the details! I could reproduce the issue. Will update the plugin soon! And to answer your questions,
Thanks for resolving. Great stuff!
@avastmick
It seems the variable "relative_path" includes "config.path", which is the absolute path to each wiki, such as "path like path = '/Users/testuser/personal-wiki'" on Mac. Therefore, "relative_path" works as an absolute path.
To bypass this issue for now, I overwrote the method "utils.get_relative_path" as shown below in "init.vim". (Of course, you can simplify it further by returning empty strings without an if clause.)
lua << EOF
-- https://github.com/serenevoid/kiwi.nvim/issues/21
local utils = require'kiwi.utils'
local is_windows = vim.loop.os_uname().version:match('Windows')
utils.get_relative_path = function (config)
local relative_path = vim.fs.dirname(vim.fn.expand('%:p'))
if is_windows then
-- For Windows, replace backslashes with forward slashes in the config path
return relative_path:gsub(config.path:gsub("\\", "/"), "")
else
-- For macOS, return the relative path directly
return ""
end
end
EOF
@avastmick @tarurata I have added a new commit for fixing this issue. Please have a look when you find time. Hope to hear from you soon.
The latest change broke my setup using Obsidian and iCloud. I think this line in ensure_directories
:
props.path = props.path:gsub("$HOME", get_home()):gsub("~", get_home())
conflicts with my config:
local wikiPath = '/Users/mwarner/Library/Mobile Documents/iCloud~md~obsidian/Documents/my_notes'
require('kiwi').setup({
{
name = 'personal',
path = wikiPath,
},
})
@mlwarner Thanks for your response. I have rolled back the plugin. Please try updating the plugin again. If update fails, try reinstalling the plugin.
Thanks! I unpinned the commit and it is working as expected.
I think you are looking for path expansion here rather than a substitution. Quick scan through vim help docs has vim.fn.expand
. Testing with :lua =vim.fn.expand("/Users/mwarner/Library/Mobile Documents/iCloud~md~obsidian/Documents/my_notes")
yields the same path, and :lua =vim.fn.expand("~/wiki")
also works as expected.
While this plugin looks promising, I cannot get it work as expected with more than one notes location.
My configuration:
Usage:
I open the, I get the following path (see the status line)
personal
and add in a line 'Daily Plan', select words andI hit
Ctrl+o
to return toindex.md
, hovered link does not show duplicated path elements:If I remove the leading navigates to a new file in the directory I opened
./
from the new link,nvim
.