Skip to content

Commit b431d22

Browse files
authored
fix: prioritize user config for extensions on windows (#1215)
Fixes the second part of: #1213 The same logic fixed in (#1214) is duplicated in the lualine_require module, which appears to be used internally for loading things like extensions. On windows, user defined extensions that overwrite the builtin similarly cannot be loaded due to the same string matching issue. In addition, the number of queried runtime files is always less-than or equal to 1 due to the `all` parameter for `nvim_get_runtime_file` being set to false. Making it impossible to sort the list of files and prioritize ones within the users config path `vim.fn.stdpath("config")`.
1 parent 544dd15 commit b431d22

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lua/lualine_require.lua

+4-3
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,17 @@ function M.require(module)
5454
end
5555

5656
pattern_path = table.concat { 'lua/', module:gsub('%.', '/'), '.lua' }
57-
local paths = vim.api.nvim_get_runtime_file(pattern_path, false)
57+
local paths = vim.api.nvim_get_runtime_file(pattern_path, true)
5858
if #paths <= 0 then
5959
pattern_path = table.concat { 'lua/', module:gsub('%.', '/'), '/init.lua' }
60-
paths = vim.api.nvim_get_runtime_file(pattern_path, false)
60+
paths = vim.api.nvim_get_runtime_file(pattern_path, true)
6161
end
6262
if #paths > 0 then
6363
-- put entries from user config path in front
6464
local user_config_path = vim.fn.stdpath('config')
6565
table.sort(paths, function(a, b)
66-
return vim.startswith(a, user_config_path) or not vim.startswith(b, user_config_path)
66+
local pattern = table.concat { user_config_path, M.sep }
67+
return string.match(a, pattern) or not string.match(b, pattern)
6768
end)
6869
local mod_result = dofile(paths[1])
6970
package.loaded[module] = mod_result

0 commit comments

Comments
 (0)