Skip to content

Commit

Permalink
Add ability to put user config in ~/.config/astrovim/lua/user
Browse files Browse the repository at this point in the history
Signed-off-by: Micah Halter <micah@balena.io>
  • Loading branch information
mehalter committed Apr 11, 2022
1 parent ae4ae03 commit 3a9691a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
2 changes: 2 additions & 0 deletions init.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
vim.opt.rtp:append(vim.fn.stdpath "config" .. "/../astrovim")

local impatient_ok, impatient = pcall(require, "impatient")
if impatient_ok then
impatient.enable_profile()
Expand Down
26 changes: 20 additions & 6 deletions lua/core/utils.lua
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
local M = {}

local supported_configs = {
vim.fn.stdpath "config",
vim.fn.stdpath "config" .. "/../astrovim",
}

local g = vim.g

local function file_not_empty(path)
return vim.fn.empty(vim.fn.glob(path)) == 0
end

local function load_module_file(module)
local module_path = vim.fn.stdpath "config" .. "/lua/" .. module:gsub("%.", "/") .. ".lua"
local out = nil
if vim.fn.empty(vim.fn.glob(module_path)) == 0 then
local found_module = nil
for _, config_path in ipairs(supported_configs) do
local module_path = config_path .. "/lua/" .. module:gsub("%.", "/") .. ".lua"
if file_not_empty(module_path) then
found_module = module_path
end
end
if found_module then
local status_ok, loaded_module = pcall(require, module)
if status_ok then
out = loaded_module
found_module = loaded_module
else
vim.notify("Error loading " .. module_path, "error", M.base_notification)
vim.notify("Error loading " .. found_module, "error", M.base_notification)
end
end
return out
return found_module
end

local function load_user_settings()
Expand Down

0 comments on commit 3a9691a

Please sign in to comment.