diff options
author | talha <talha@talhaamir.xyz> | 2024-01-03 00:46:20 +0500 |
---|---|---|
committer | talha <talha@talhaamir.xyz> | 2024-01-03 00:46:20 +0500 |
commit | 7e1c16b7aefbb253e391dc5b8361621142772e3d (patch) | |
tree | d836d6d408b400ff63d0c6a21ff01dbc8e41f99f /lua/talha | |
parent | 27c1b5b9a5cadf1d1331e4cefeaa9c8a73707b26 (diff) |
Fixed some path issues with windows
Diffstat (limited to 'lua/talha')
-rw-r--r-- | lua/talha/functions.lua | 15 | ||||
-rw-r--r-- | lua/talha/set.lua | 2 |
2 files changed, 16 insertions, 1 deletions
diff --git a/lua/talha/functions.lua b/lua/talha/functions.lua index 946bfd8..e17cada 100644 --- a/lua/talha/functions.lua +++ b/lua/talha/functions.lua @@ -60,3 +60,18 @@ function ToggleSpellCheck() vim.opt.spell = not(vim.opt.spell:get()) vim.opt.spelllang = 'en_us' end + +function GetHomeDir() + -- for linux/mac + local home = os.getenv("HOME") + -- for windows + local user_profile = os.getenv("UserProfile") + + if home ~= nil then + return home + elseif user_profile ~= nil then + return user_profile + end + + return nil +end diff --git a/lua/talha/set.lua b/lua/talha/set.lua index 0366b03..404b1d8 100644 --- a/lua/talha/set.lua +++ b/lua/talha/set.lua @@ -13,7 +13,7 @@ op.wrap = false op.swapfile = false op.backup = false -op.undodir = os.getenv("HOME") .. "/.vim/undodir" +op.undodir = GetHomeDir() .. "/.vim/undodir" op.undofile = true op.hlsearch = false |