enhance: explicitly prefer user config dir

when loading components/themes/extensions explicitly prefer users
config dir over plugin dirs instead of relying on sequencing of rtp.
This commit is contained in:
shadmansaleh 2022-12-22 12:51:19 +06:00
parent bfa0d99ba6
commit afb8bfb786
2 changed files with 10 additions and 0 deletions

View File

@ -226,6 +226,11 @@ local function load_theme(theme_name)
-- when only one is found run that and return it's return value
retval = dofile(files[1])
else
-- put entries from user config path in front
local user_config_path = vim.fn.stdpath('config')
table.sort(files, function(a, b)
return vim.startswith(a, user_config_path) or not vim.startswith(b, user_config_path)
end)
-- More then 1 found . Use the first one that isn't in lualines repo
local lualine_repo_pattern = table.concat({ 'lualine.nvim', 'lua', 'lualine' }, sep)
local file_found = false

View File

@ -60,6 +60,11 @@ function M.require(module)
paths = vim.api.nvim_get_runtime_file(pattern_path, false)
end
if #paths > 0 then
-- put entries from user config path in front
local user_config_path = vim.fn.stdpath('config')
table.sort(paths, function(a, b)
return vim.startswith(a, user_config_path) or not vim.startswith(b, user_config_path)
end)
local mod_result = dofile(paths[1])
package.loaded[module] = mod_result
return mod_result