Closed LintaoAmons closed 4 months ago
This should already be doable. Try the following configuration:
opts = {
filetypes = {
markdown = {
dir_path = function()
return "asset_" .. vim.fn.expand("%:t:r")
end,
},
},
},
Any option can be dynamically configured using Lua functions :)
Oh, that's great, I didn't noticed this in the README doc. You have type hint all the options as string
Oh, one more thing is the dir_path prefix, since the dir_path
is a relative path.
If I remember correctly, the prefix is pwd
, how could I change it to the path where the markdown file is located at.
Oh, one more thing is the dir_path prefix, since the dir_path is a relative path. If I remember correctly, the prefix is pwd, how could I change it to the path where the markdown file is located at.
You can enable the relative_to_current_file
option, i.e.:
opts = {
filetypes = {
markdown = {
relative_to_current_file = true,
dir_path = function()
return "asset_" .. vim.fn.expand("%:t:r")
end,
},
},
},
You have type hint all the options as string
Thanks for pointing that out. I should probably change it to string | func
or similar for clarity.
Is your feature request related to a problem? Please describe. I want move the markdown file from one place to another place. Those images should also go with the markdown files, but since current we put all image inside one
assets
folder, if we have multiple markdown files in same directory, I need to filter out the images for that markdown file manually. So I was thinking maybe thedir_path
could have an option to create specific dir to place the images for that specific markdown file.e.g. I create a markdown file named
test.md
--> when paste an image into thetest.md
file, the image saved tofile_dir/.asset_test
folder. The file_dir is the directory where the markdown file is located(since sometimes people like me would just open another note outside current pwd, so I think it's nice to put it at the same location with the markdown file instead of pwd)