diff --git a/.gitignore b/.gitignore index 929091c..3b281c5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ deps **.DS_Store -.ci +.ci/** diff --git a/lua/no-neck-pain/colors.lua b/lua/no-neck-pain/colors.lua index ff592ec..0d35fd3 100644 --- a/lua/no-neck-pain/colors.lua +++ b/lua/no-neck-pain/colors.lua @@ -66,8 +66,8 @@ function C.matchAndBlend(colorCode, factor) ) end - if Co.INTEGRATIONS[colorCode] ~= nil then - colorCode = Co.INTEGRATIONS[colorCode] + if Co.THEMES[colorCode] ~= nil then + colorCode = Co.THEMES[colorCode] end local hexPattern = "^#" .. "[abcdef0-9]" .. ("[abcdef0-9]"):rep(5) .. "$" diff --git a/lua/no-neck-pain/state.lua b/lua/no-neck-pain/state.lua index 7c0aa92..b58d6ce 100644 --- a/lua/no-neck-pain/state.lua +++ b/lua/no-neck-pain/state.lua @@ -1,5 +1,5 @@ local A = require("no-neck-pain.util.api") -local C = require("no-neck-pain.util.constants") +local Co = require("no-neck-pain.util.constants") local D = require("no-neck-pain.util.debug") local State = { enabled = false, activeTab = A.getCurrentTab(), tabs = nil } @@ -194,7 +194,7 @@ function State:isSupportedIntegration(scope, win) return self.isSupportedIntegration(self, scope, wins[1]) end - local registeredIntegrations = tab ~= nil and tab.wins.integrations or C.integrations + local registeredIntegrations = tab ~= nil and tab.wins.integrations or Co.INTEGRATIONS for name, integration in pairs(registeredIntegrations) do if vim.startswith(string.lower(fileType), integration.fileTypePattern) then @@ -218,7 +218,7 @@ end ---@private function State:scanIntegrations(scope) local wins = self.getUnregisteredWins(self) - local unregisteredIntegrations = vim.deepcopy(C.integrations) + local unregisteredIntegrations = vim.deepcopy(Co.INTEGRATIONS) for _, win in pairs(wins) do local supported, name, integration = self.isSupportedIntegration(self, scope, win) @@ -493,7 +493,7 @@ function State:setTab(id) right = nil, }, splits = nil, - integrations = vim.deepcopy(C.integrations), + integrations = vim.deepcopy(Co.INTEGRATIONS), }, } self.activeTab = id diff --git a/lua/no-neck-pain/util/constants.lua b/lua/no-neck-pain/util/constants.lua index 3521546..78f8156 100644 --- a/lua/no-neck-pain/util/constants.lua +++ b/lua/no-neck-pain/util/constants.lua @@ -1,14 +1,14 @@ -local C = {} +local Co = {} ---Sides where the buffers are created. --- ---@private -C.SIDES = { "left", "right" } +Co.SIDES = { "left", "right" } ---Available color integrations aliases. --- ---@private -C.INTEGRATIONS = { +Co.THEMES = { ["catppuccin-frappe"] = "#303446", ["catppuccin-frappe-dark"] = "#292c3c", ["catppuccin-latte"] = "#eff1f5", @@ -33,7 +33,10 @@ C.INTEGRATIONS = { ["tokyonight-storm"] = "#1f2335", } -C.integrations = { +---Supported integrations in order to properly interact with the buffers. +--- +---@private +Co.INTEGRATIONS = { NvimTree = { fileTypePattern = "nvimtree", close = "NvimTreeClose", @@ -66,4 +69,9 @@ C.integrations = { }, } -return C +---Dashboards filetypes that delays the plugin enable step until next buffer entered. +--- +---@private +Co.DASHBOARDS = { "dashboard", "alpha" } + +return Co diff --git a/lua/no-neck-pain/util/event.lua b/lua/no-neck-pain/util/event.lua index ca5ef30..608dbe6 100644 --- a/lua/no-neck-pain/util/event.lua +++ b/lua/no-neck-pain/util/event.lua @@ -1,4 +1,5 @@ local A = require("no-neck-pain.util.api") +local Co = require("no-neck-pain.util.constants") local S = require("no-neck-pain.state") local E = {} @@ -52,12 +53,12 @@ function E.skipEnable() return true end - local isSupportedIntegration = S.isSupportedIntegration(S, "E.skipEnable", nil) - if isSupportedIntegration or vim.bo.filetype == "dashboard" then + -- dashboards delays the plugin enable step until next buffer entered + if vim.tbl_contains(Co.DASHBOARDS, vim.bo.filetype) then return true end - return false + return S.isSupportedIntegration(S, "E.skipEnable", nil) end return E diff --git a/tests/test_API.lua b/tests/test_API.lua index 1aba520..630b472 100644 --- a/tests/test_API.lua +++ b/tests/test_API.lua @@ -236,7 +236,7 @@ T["enable"]["(single tab) sets state"] = function() Helpers.expect.state_type(child, "tabs[1].wins.integrations", "table") - Helpers.expect.state(child, "tabs[1].wins.integrations", Co.integrations) + Helpers.expect.state(child, "tabs[1].wins.integrations", Co.INTEGRATIONS) end T["enable"]["(multiple tab) sets state"] = function() @@ -264,7 +264,7 @@ T["enable"]["(multiple tab) sets state"] = function() Helpers.expect.state_type(child, "tabs[1].wins.integrations", "table") - Helpers.expect.state(child, "tabs[1].wins.integrations", Co.integrations) + Helpers.expect.state(child, "tabs[1].wins.integrations", Co.INTEGRATIONS) -- tab 2 child.cmd("tabnew") @@ -288,7 +288,7 @@ T["enable"]["(multiple tab) sets state"] = function() Helpers.expect.state_type(child, "tabs[2].wins.integrations", "table") - Helpers.expect.state(child, "tabs[2].wins.integrations", Co.integrations) + Helpers.expect.state(child, "tabs[2].wins.integrations", Co.INTEGRATIONS) end T["disable"] = MiniTest.new_set() diff --git a/tests/test_colors.lua b/tests/test_colors.lua index 1157296..8f1af2a 100644 --- a/tests/test_colors.lua +++ b/tests/test_colors.lua @@ -224,7 +224,7 @@ end T["color"] = MiniTest.new_set() T["color"]["map integration name to a value"] = function() - for integration, value in pairs(Co.INTEGRATIONS) do + for integration, value in pairs(Co.THEMES) do child.lua(string.format( [[ require('no-neck-pain').setup({ buffers = { diff --git a/tests/test_tabs.lua b/tests/test_tabs.lua index 8b73517..b7865b1 100644 --- a/tests/test_tabs.lua +++ b/tests/test_tabs.lua @@ -191,7 +191,7 @@ T["tabnew/tabclose"]["doesn't keep closed tabs in state"] = function() }, scratchPadEnabled = false, wins = { - integrations = Co.integrations, + integrations = Co.INTEGRATIONS, main = { curr = 1000, left = 1001, @@ -212,7 +212,7 @@ T["tabnew/tabclose"]["doesn't keep closed tabs in state"] = function() }, scratchPadEnabled = false, wins = { - integrations = Co.integrations, + integrations = Co.INTEGRATIONS, main = { curr = 1000, left = 1001, @@ -228,7 +228,7 @@ T["tabnew/tabclose"]["doesn't keep closed tabs in state"] = function() }, scratchPadEnabled = false, wins = { - integrations = Co.integrations, + integrations = Co.INTEGRATIONS, main = { curr = 1003, left = 1004, @@ -248,7 +248,7 @@ T["tabnew/tabclose"]["doesn't keep closed tabs in state"] = function() }, scratchPadEnabled = false, wins = { - integrations = Co.integrations, + integrations = Co.INTEGRATIONS, main = { curr = 1000, left = 1001, @@ -275,7 +275,7 @@ T["tabnew/tabclose"]["keeps state synchronized between tabs"] = function() }, scratchPadEnabled = false, wins = { - integrations = Co.integrations, + integrations = Co.INTEGRATIONS, main = { curr = 1000, left = 1001, @@ -299,7 +299,7 @@ T["tabnew/tabclose"]["keeps state synchronized between tabs"] = function() }, scratchPadEnabled = false, wins = { - integrations = Co.integrations, + integrations = Co.INTEGRATIONS, main = { curr = 1000, left = 1001, @@ -315,7 +315,7 @@ T["tabnew/tabclose"]["keeps state synchronized between tabs"] = function() }, scratchPadEnabled = false, wins = { - integrations = Co.integrations, + integrations = Co.INTEGRATIONS, main = { curr = 1003, left = 1004, @@ -335,7 +335,7 @@ T["tabnew/tabclose"]["keeps state synchronized between tabs"] = function() }, scratchPadEnabled = false, wins = { - integrations = Co.integrations, + integrations = Co.INTEGRATIONS, main = { curr = 1000, left = 1001, @@ -355,7 +355,7 @@ T["tabnew/tabclose"]["keeps state synchronized between tabs"] = function() }, scratchPadEnabled = false, wins = { - integrations = Co.integrations, + integrations = Co.INTEGRATIONS, main = { curr = 1000, left = 1001, @@ -371,7 +371,7 @@ T["tabnew/tabclose"]["keeps state synchronized between tabs"] = function() }, scratchPadEnabled = false, wins = { - integrations = Co.integrations, + integrations = Co.INTEGRATIONS, main = { curr = 1003, left = 1006, @@ -392,7 +392,7 @@ T["tabnew/tabclose"]["keeps state synchronized between tabs"] = function() }, scratchPadEnabled = false, wins = { - integrations = Co.integrations, + integrations = Co.INTEGRATIONS, main = { curr = 1000, left = 1001, @@ -408,7 +408,7 @@ T["tabnew/tabclose"]["keeps state synchronized between tabs"] = function() }, scratchPadEnabled = false, wins = { - integrations = Co.integrations, + integrations = Co.INTEGRATIONS, main = { curr = 1003, left = 1006, @@ -449,7 +449,7 @@ T["tabnew/tabclose"]["does not pick tab 1 for the first active tab"] = function( }, scratchPadEnabled = false, wins = { - integrations = Co.integrations, + integrations = Co.INTEGRATIONS, main = { curr = 1001, left = 1002, @@ -521,7 +521,7 @@ T["tabnew/tabclose"]["does not pick tab 1 for the first active tab"] = function( }, scratchPadEnabled = false, wins = { - integrations = Co.integrations, + integrations = Co.INTEGRATIONS, main = { curr = 1001, left = 1002, @@ -558,7 +558,7 @@ T["tabnew/tabclose"]["keep state synchronized on second tab"] = function() }, scratchPadEnabled = false, wins = { - integrations = Co.integrations, + integrations = Co.INTEGRATIONS, main = { curr = 1001, left = 1002, @@ -588,7 +588,7 @@ T["tabnew/tabclose"]["keep state synchronized on second tab"] = function() }, scratchPadEnabled = false, wins = { - integrations = Co.integrations, + integrations = Co.INTEGRATIONS, main = { curr = 1001, left = 1002,