From afb8bfb786dd87122c9740681e14cedc9a9432e6 Mon Sep 17 00:00:00 2001 From: shadmansaleh <13149513+shadmansaleh@users.noreply.github.com> Date: Thu, 22 Dec 2022 12:51:19 +0600 Subject: [PATCH] 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. --- lua/lualine/utils/loader.lua | 5 +++++ lua/lualine_require.lua | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/lua/lualine/utils/loader.lua b/lua/lualine/utils/loader.lua index 717ee2d..3eba13b 100644 --- a/lua/lualine/utils/loader.lua +++ b/lua/lualine/utils/loader.lua @@ -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 diff --git a/lua/lualine_require.lua b/lua/lualine_require.lua index c8aad79..f315728 100644 --- a/lua/lualine_require.lua +++ b/lua/lualine_require.lua @@ -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