Skip to content

Commit

Permalink
refactor: Extract get_home() function
Browse files Browse the repository at this point in the history
  • Loading branch information
Allaman committed Jul 9, 2024
1 parent 069f41f commit 2fe2f4c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lua/utils/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,19 @@ function M.on_attach(on_attach)
})
end

---load user config file .nvim_config.lua
---@return table
function M.load_user_config()
local home = os.getenv("XDG_CONFIG_HOME")
---get the path of the user's home directory
---@return string
function M.get_home()
return os.getenv("XDG_CONFIG_HOME")
or os.getenv("HOME")
or os.getenv("USERPROFILE")
or (os.getenv("HOMEDRIVE") .. os.getenv("HOMEPATH"))
end

---load user config file .nvim_config.lua
---@return table
function M.load_user_config()
local home = M.get_home()
local config_file = home .. M.path_separator() .. ".nvim_config.lua"
local ok, err = pcall(dofile, config_file)
if not ok then
Expand Down

0 comments on commit 2fe2f4c

Please sign in to comment.