Closed linrongbin16 closed 1 year ago
hi, @utilyre would you please help review?
Hi! It'd always bothered me to hard code the forward slash, but unfortunately I didn't have any Windows machines to test it on. So thanks for solving it!
There's also another place that the forward slash is being hard coded. I'll fix it using your solution, but would you mind testing it on your Windows machine?
I'll give you the patch here.
Apply these changes by git apply [filename]
:
diff --git a/lua/barbecue/theme.lua b/lua/barbecue/theme.lua
index aeabdbc..b4d3b56 100644
--- a/lua/barbecue/theme.lua
+++ b/lua/barbecue/theme.lua
@@ -62,18 +62,21 @@ local function get_theme(name)
utils.tbl_merge(
found_files,
vim.api.nvim_get_runtime_file(
- string.format("lua/barbecue/theme/%s.lua", name),
+ utils.path_join("lua", "barbecue", "theme", string.format("%s.lua", name)),
true
),
vim.api.nvim_get_runtime_file(
- string.format("lua/barbecue/theme/%s/init.lua", name),
+ utils.path_join("lua", "barbecue", "theme", name, "init.lua"),
true
)
)
if #found_files == 0 then
return dofile(
- vim.api.nvim_get_runtime_file("lua/barbecue/theme/default.lua", false)[1]
+ vim.api.nvim_get_runtime_file(
+ utils.path_join("lua", "barbecue", "theme", "default.lua"),
+ false
+ )[1]
)
end
@@ -87,7 +90,9 @@ local function get_theme(name)
)
for _, found_file in ipairs(found_files) do
- if not found_file:find("barbecue.nvim/lua/barbecue") then
+ if
+ not found_file:find(utils.path_join("barbecue.nvim", "lua", "barbecue"))
+ then
return dofile(found_file)
end
end
diff --git a/lua/barbecue/utils.lua b/lua/barbecue/utils.lua
index dac1563..2523a4e 100644
--- a/lua/barbecue/utils.lua
+++ b/lua/barbecue/utils.lua
@@ -55,4 +55,14 @@ function M.since_nvim(major, minor, patch)
return false
end
+---Join any number of path elements into a single path, separating them with an
+---OS specific separator.
+---
+---@param ... string
+---@return string
+function M.path_join(...)
+ local separator = package.config:sub(1, 1)
+ return table.concat({ ... }, separator)
+end
+
return M
After apply your diff, here's some screenshots in different colorschemes (colorscheme's name is in left,bottom): Tested in Windows 10 + Windows Terminal + nvim 0.8.2.
@linrongbin16 Yep thanks it's working all fine :)
Fix issue: #63 Use more general file path seperator, please see: https://stackoverflow.com/a/14425862/4438921
Manually tested: