Skip to content

(mini.misc) FEATURE: implement setup_mkdir_missing().#555

Closed
yamhab wants to merge 1 commit intonvim-mini:mainfrom
yamhab:mkdir-missing
Closed

(mini.misc) FEATURE: implement setup_mkdir_missing().#555
yamhab wants to merge 1 commit intonvim-mini:mainfrom
yamhab:mkdir-missing

Conversation

@yamhab
Copy link
Copy Markdown
Contributor

@yamhab yamhab commented Nov 6, 2023

If this PR were to be merged, mini.misc will have the setup_mkdir_missing() function which will automatically create any missing directories needed for saving a file. This is similar to the functionality provided by tidy.nvim. I also made sure it didn't break with netrw URLs, and I wrote it some documentation and tests.

@echasnovski
Copy link
Copy Markdown
Member

Thanks for the PR!

Sorry, but I don't think this is a good functionality to have. Both in terms of what it provides (performing the check on every BufWrite is costly and redundant as it can be done several times per minute) and adding it to 'mini.misc' (this is a rather trivial autocommand with almost a one line function). I would suggest instead create a file before starting work in it (for example, with 'mini.files' it is very straightforward).

Please, open an issue to discuss a feature first prior to creating a PR. This way it might lead to less time wasted on your side.

Closing as not planned.

@echasnovski echasnovski closed this Nov 6, 2023
@echasnovski
Copy link
Copy Markdown
Member

I will update 'CHANGELOG.md' to proper mention you for #554, though. Sorry about that.

@yamhab
Copy link
Copy Markdown
Contributor Author

yamhab commented Nov 6, 2023

@echasnovski What if I were to get the autocommand to run only once using the once opts flag for nvim_create_autocmd for better performance? And as for it not being suitable for mini.misc for how short it is, wouldn't the same apply for setup_restore_cursor() because it can mostly just be done with '" in normal mode?

@echasnovski
Copy link
Copy Markdown
Member

@echasnovski What if I were to get the autocommand to run only once using the once opts flag for nvim_create_autocmd for better performance?

It won't work with a simple once as it should create the autocommand on every BufCreate event. Besides, it doesn't address the fact that I don't really want to enable this kind of workflow.

And as for it not being suitable for mini.misc for how short it is, wouldn't the same apply for setup_restore_cursor() because it can mostly just be done with '" in normal mode?

setup_restore_cursor() does a bit more than that (checks if cursor was already placed, checks for proper " register, opens folds, centers window) and does it smartly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants