Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to put user config in ~/.config/astrovim/lua/user #278

Merged
merged 1 commit into from
Apr 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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