Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nill value when try to get vim undo directory #77

Open
waleedrana777 opened this issue May 30, 2023 · 2 comments
Open

Nill value when try to get vim undo directory #77

waleedrana777 opened this issue May 30, 2023 · 2 comments

Comments

@waleedrana777
Copy link

I try to copy Prime's config from YT tutorial, When I try to :so the set.lua file, it gives me the following error on windows:

Error detected while processing :source (no file):
E5108: Error executing lua [string ":source (no file)"]:17: attempt to concatenate a nil value
stack traceback:
        [string ":source (no file)"]:17: in main chunk

Line number 17 is:
vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir"

Also I have a question: why Prime doesn't have autosave enabled as some one coming from vscode, it has autosave, so I am wondering if there is some kind of advantage to that?! If so what is it?

If not, why Prime doesn't talk about autosave, what's the easiest way to enable autosave without going into plugins, I explored options like autowrite and autowritedelay but couldn't get them to work!

Will I lose all my work if I forget to save it without autosave, I understand buffers keep your text but even after machine restart?

Sorry for asking too many question! I am just a newbie!

@mrs4ndman
Copy link

I also followed a few weeks ago the tutorial, and the undo history has worked with this set of options (it is also on my dotfiles):

vim.o.swapfile = false
vim.o.backup = false
vim.o.undodir = os.getenv("HOME") .. "/.vim/undodir"
vim.o.undofile = true

If you are on Windows, you could try inverting the slashes on /.vim/undodir and see if It makes a difference.
About the autosave, you could bind Leader + Q to write and then quit all buffers (:wqa).
I have found a solution that allows me to create sessions that auto-save them when I need to, and load with a keybind. The cool thing is that, after created, they auto-save!
The plugin I used: rmagatti/auto-session
The code I used: here and the following keybinds (the first is from my dashboard plugin):

dashboard.button( "v", "    Source session",        ":SessionRestore<CR>"),

vim.keymap.set("n", "<leader>sd", "<cmd>SessionDelete<CR>", { desc = "Saved current session" })
vim.keymap.set("n", "<leader>sr", "<cmd>SessionRestore<CR>", { desc = "Restore session for CWD" })
vim.keymap.set("n", "<leader>ss", "<cmd>SessionSave<CR>", { desc = "Saved current session" })

Hope this helps! :)

@S3cBar0n
Copy link

To fix the "attempt to concatenate a nil value" on Windows, you need to create an environment variable set to your home directory; I recommend you make this under your User environment variables rather than System environment variables.

Something like "C:\Users\waleedrana777". Once you have the "HOME" environment variable set, you can restart your terminal, and it will work just fine. You don't need to create the "/.vim/undodir" folder either; once your HOME env variable is set, nvim will automatically create those folders for you.

In case you haven't worked with environment variables in Windows before, I recommend following this video to accomplish what I described above: https://www.youtube.com/watch?v=5BTnfpIq5mI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants