neorg icon indicating copy to clipboard operation
neorg copied to clipboard

Neorg cannot create a folder and throws error while creating a file inside a non existing folder

Open mohitkdas opened this issue 2 years ago • 3 comments

Prerequisites

  • [X] I have read contribution guidelines
  • [X] I am using the latest version of the plugin
  • [X] I am using either 0.6 stable or the latest compiled neovim version

Neovim Version

0.7.2

Neorg setup

require('neorg').setup { load = { ["core.defaults"] = {}, ["core.norg.dirman"] = { config = { workspaces = { home = "~/notes/home", work = "~/notes/work", } } }, ["core.norg.completion"] = { config = { engine = "nvim-cmp", } }, ["core.norg.concealer"] = { config = { icon_preset = "varied" } } } }

Actual behavior

Neorg is unable to create a new folder when a path is provided with a new folder.

Expected behavior

New folder should be automatically created

Steps to reproduce

New folder should be automatically created

Potentially conflicting plugins

No response

Other information

No response

Help

No

Implementation help

No response

mohitkdas avatar Jul 07 '22 13:07 mohitkdas

The statement

New folder should be automatically created

Is a dogma. Can you elaborate why this should be the case ?

danymat avatar Jul 07 '22 13:07 danymat

I created a link to another norg file by {:folder/test:}[test_file] Then I went into the file and added some things. While saving the file, it throws me an error saying: "Can't open file for writing: no such file or directory".

I previously used vimwiki which created a new folder in such cases, and I did not have to think about creating a folder before writing contents to a file.

mohitkdas avatar Jul 07 '22 13:07 mohitkdas

Hmm interesting. @danymat it makes sense for this to be builtin imo. I'll implement this when I can :)

vhyrro avatar Jul 07 '22 13:07 vhyrro

This now seems to be addressed by Neovim itself.

Authors who want this can do :w ++p to ask Neovim to create the folder structure if it doesn't exist. :h :w and :h ++opt in Neovim for more info.

In light of this, is this still something that should be builtin to neorg?

d-r-a-b avatar Apr 26 '23 07:04 d-r-a-b

Yep! Now that this is available by default inside of Neovim making Neorg auto-create these directories is a bit unwarranted in my opinion? It's still a bit of a difficult choice to make, but I think it's best to leave creation of files up to the user to prevent Neorg from creating random files whenever you enter a link by accident. This annoyance is especially amplified when you create a typo in a link, enter the link, and then you not only have to change the link you have to remove the file it created automatically. Closing as wontfix :)

vhyrro avatar Apr 27 '23 17:04 vhyrro