changeset 579:4e25c3d4470d

handle HOME on windows
author zegervdv <zegervdv@me.com>
date Thu, 24 Mar 2022 09:25:43 +0100
parents 8e3088140ac6
children 23426c0f0e58
files .chezmoitemplates/init.lua
diffstat 1 files changed, 8 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/.chezmoitemplates/init.lua	Thu Mar 24 09:22:08 2022 +0100
+++ b/.chezmoitemplates/init.lua	Thu Mar 24 09:25:43 2022 +0100
@@ -5,6 +5,11 @@
 local execute = vim.api.nvim_command
 local fn = vim.fn
 
+local home = os.getenv('HOME')
+if home == nil then
+  home = os.getenv('USERPROFILE')
+end
+
 -- Bootstrap package manager
 local install_path = fn.stdpath 'data' .. '/site/pack/packer/opt/packer.nvim'
 
@@ -711,14 +716,10 @@
 
 opt.undofile = true -- Persistently remember undos
 opt.undolevels = 1000
-if os.getenv 'HOME' ~= nil then
-  opt.undodir = os.getenv 'HOME' .. '/.config/nvim/tmp/undo//'
-end
+opt.undodir = home .. '/.config/nvim/tmp/undo//'
 opt.swapfile = false -- Disable swap files
 opt.backup = true -- Keep backups
-if os.getenv 'HOME' ~= nil then
-  opt.backupdir = os.getenv 'HOME' .. '/.config/nvim/tmp/backup//'
-end
+opt.backupdir = home .. '/.config/nvim/tmp/backup//'
 
 -- Files to ignore from completion
 opt.wildignore:append {
@@ -943,7 +944,7 @@
   capabilities = capabilities,
   root_dir = root_dir,
   -- Assume esbonio is installed with --user
-  cmd = { os.getenv 'HOME' .. '/.local/bin/esbonio' },
+  cmd = { home .. '/.local/bin/esbonio' },
 }
 
 null_ls.setup {