Open jblyberg opened 6 months ago
Good evening and thank you for the suggestion!
This could be easily implemented. A little note of historical relevance: when I initially started developing and using the plugin for myself only, I did in fact defaulted the behaviour to automatically create a directory/file path if the current specified location is empty. However, when I decided to expose it to a larger audience, I came to the conclusion that such behaviour might be a little risky and may open the flood gates for all possible misuses (accidental or malicious): a third party plugin should not create a path on the users' computer - creating paths may require/circumvent users' permissions and be possible only for root users on certain machines and so forth; I decided that at most we create a session file provided the user already has the path, i. e. provided the user already consented to create the path on their own machine by doing so themselves (a vim session file contains little to nothing that can be maliciously injected, hence that is fine to create).
As I said, I am somehow "technically" open to the idea but I am not convinced this is the right direction for the scope of a plugin. Let us keep the issue open in case other users chip in, if the vast majority are fine and do not really care about creating/deleting paths automatically I am more than happy to re-default back to auto-creation if the path does not exist :)
Thanks for the thoughtful response. I understand where you're coming from. There might be some ways to address your concern though, like providing a configuration option that users can set to indicate that they would like the config path to be auto-created. The benefit of doing it that way would be that it would have to be done explicitly with the implicit understanding that the plugin would touch the filesystem.
I added this to my lazy config and it seems to work:
build = function()
local sessions_path = vim.fn.stdpath("data") .. "/sessions"
if vim.fn.isdirectory(sessions_path) == 0 then
vim.uv.fs_mkdir(sessions_path, 511) -- 0777
end
end,
Great plugin--just what I needed.
I have a request that it automatically creates the session path if it doesn't exists. I periodically clear out my
.local/share/nvim
folder and I'd rather not have to manually recreate the session folder. I know I can store it somewhere else, but it would be nice to keep it all together in the same directory tree.