From 7aa149114c88bffb840be25be2bd764512f2a71a Mon Sep 17 00:00:00 2001 From: NStefan002 Date: Sun, 17 Mar 2024 20:01:45 +0100 Subject: [PATCH] fix(highlights): remove unnecessary hlgroups, don't be limited to 4x4 max value --- lua/2048/highlights.lua | 5 ----- lua/2048/init.lua | 3 ++- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/lua/2048/highlights.lua b/lua/2048/highlights.lua index 5502b61..3099161 100644 --- a/lua/2048/highlights.lua +++ b/lua/2048/highlights.lua @@ -15,11 +15,6 @@ function Highlights.setup() vim.api.nvim_set_hl(ns_id, "2048_Value1024", { fg = "#ffffff", bg = "#edc53f", bold = true }) vim.api.nvim_set_hl(ns_id, "2048_Value2048", { fg = "#ffffff", bg = "#edc22e", bold = true }) vim.api.nvim_set_hl(ns_id, "2048_Value4096", { fg = "#ffffff", bg = "#000000", bold = true }) - vim.api.nvim_set_hl(ns_id, "2048_Value8192", { fg = "#ffffff", bg = "#000000", bold = true }) - vim.api.nvim_set_hl(ns_id, "2048_Value16384", { fg = "#ffffff", bg = "#000000", bold = true }) - vim.api.nvim_set_hl(ns_id, "2048_Value32768", { fg = "#ffffff", bg = "#000000", bold = true }) - vim.api.nvim_set_hl(ns_id, "2048_Value65536", { fg = "#ffffff", bg = "#000000", bold = true }) - vim.api.nvim_set_hl(ns_id, "2048_Value131072", { fg = "#ffffff", bg = "#000000", bold = true }) vim.api.nvim_set_hl(ns_id, "2048_Background", { fg = "#aa9c8f", bg = "#aa9c8f", bold = true }) vim.api.nvim_set_hl(ns_id, "2048_Confirmation", { fg = "#ffffff", bg = "#aa9c8f", bold = true }) end diff --git a/lua/2048/init.lua b/lua/2048/init.lua index 343d7f9..11516a8 100644 --- a/lua/2048/init.lua +++ b/lua/2048/init.lua @@ -689,7 +689,8 @@ function M:draw_square(x, y, i, j, _use_prev_state) else value = self.cs.values[i][j] end - local hl_grp = "2048_Value" .. tostring(value) + value = math.min(value, 4096) + local hl_grp = string.format("2048_Value%s", tonumber(value)) for k = 0, self._square_height - 1 do vim.api.nvim_buf_add_highlight( self.bufnr,