function GetCurrFileName() local filename = vim.api.nvim_buf_get_name(0) return filename end 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 function SafeCListNav(navdir) -- dir: -- 1 is cnext (forwards) -- -1 is cprev (backwards) local dircmd = '' if navdir == 1 then dircmd = 'cnext' elseif navdir == -1 then dircmd = 'cprev' end local status, result = pcall(vim.cmd, dircmd) if status == false then return nil end end