LintaoAmons / scratch.nvim

Create temporary playground files effortlessly. Find them later without worrying about filenames or locations.
Other
246 stars 9 forks source link

Maybe scratch_file_dir fix for Windows #2

Closed Jxstxs closed 2 years ago

Jxstxs commented 2 years ago

Instead of vim.env.HOME I would suggest to use vim.fn.stdpath(), because of my Knowledge this is OS independent.

So I would write the scratch files to cache:

require("scratch").setup {
    scratch_file_dir = vim.fn.stdpath("cache") .. "/scratch.nvim"
}

On Linux it should give ~/.cache/nvim/scratch.nvim

and on Windows I think something to APPDATA

LintaoAmons commented 2 years ago

Thx, I'm really don't familiar with nvim API, so the implementation is merely MVP, grab anything that I knew~

So really need more hints like this ~

Jxstxs commented 2 years ago

Feel free to ask when you need help! :smile:

LintaoAmons commented 2 years ago

Feel free to ask when you need help! 😄

Nice ~~ And I have changed the default directory

LintaoAmons commented 2 years ago

But the separator /, is it valid for window? @Jxstxs

Jxstxs commented 2 years ago

I don't know if the above solution would work as it is.

but with vim.loop.os_uname().sysname you can get the os type in nvim. Now you could write a function which returns the specific character for the os ( / or \)