From 53e233909890cb16cbcd37770c59628ecbd28bfd Mon Sep 17 00:00:00 2001 From: tris203 Date: Thu, 8 Aug 2024 16:00:50 +0100 Subject: [PATCH] fix(utils): blacklisted buffers --- lua/precognition/init.lua | 4 ++-- lua/precognition/utils.lua | 2 +- tests/precognition/blacklist_spec.lua | 16 ++++++++-------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lua/precognition/init.lua b/lua/precognition/init.lua index 79e31fd..fdf804c 100644 --- a/lua/precognition/init.lua +++ b/lua/precognition/init.lua @@ -180,7 +180,7 @@ end ---@return nil local function apply_gutter_hints(gutter_hints, bufnr) bufnr = bufnr or vim.api.nvim_get_current_buf() - if require("precognition.utils").is_blacklisted_buffer(bufnr) then + if require("precognition.utils").is_blacklisted_buffer(bufnr, config.disabled_fts) then return end @@ -229,7 +229,7 @@ end local function display_marks() local utils = require("precognition.utils") local bufnr = vim.api.nvim_get_current_buf() - if utils.is_blacklisted_buffer(bufnr) then + if utils.is_blacklisted_buffer(bufnr, config.disabled_fts) then return end local cursorline = vim.fn.line(".") diff --git a/lua/precognition/utils.lua b/lua/precognition/utils.lua index 26b6505..59eb66d 100644 --- a/lua/precognition/utils.lua +++ b/lua/precognition/utils.lua @@ -35,7 +35,7 @@ function M.char_class(char, big_word) end ---@param bufnr? integer ----@param disabled_fts? string[] +---@param disabled_fts string[] ---@return boolean function M.is_blacklisted_buffer(bufnr, disabled_fts) bufnr = bufnr or vim.api.nvim_get_current_buf() diff --git a/tests/precognition/blacklist_spec.lua b/tests/precognition/blacklist_spec.lua index 7853bf0..f2b1365 100644 --- a/tests/precognition/blacklist_spec.lua +++ b/tests/precognition/blacklist_spec.lua @@ -5,48 +5,48 @@ local eq = assert.are.same describe("blacklist buffers", function() it("a regular buffer is not blacklisted", function() local test_buffer = vim.api.nvim_create_buf(true, false) - eq(utils.is_blacklisted_buffer(test_buffer), false) + eq(utils.is_blacklisted_buffer(test_buffer, {}), false) end) it("hidden buffer is not blacklisted", function() local test_buffer = vim.api.nvim_create_buf(false, false) vim.api.nvim_set_option_value("buftype", "", { buf = test_buffer }) - eq(utils.is_blacklisted_buffer(test_buffer), false) + eq(utils.is_blacklisted_buffer(test_buffer, {}), false) end) it("scratch buffer is blacklisted", function() local test_buffer = vim.api.nvim_create_buf(true, true) - eq(utils.is_blacklisted_buffer(test_buffer), true) + eq(utils.is_blacklisted_buffer(test_buffer, {}), true) end) it("hidden scratch buffer is blacklisted", function() local test_buffer = vim.api.nvim_create_buf(false, true) vim.api.nvim_set_option_value("buftype", "nofile", { buf = test_buffer }) - eq(utils.is_blacklisted_buffer(test_buffer), true) + eq(utils.is_blacklisted_buffer(test_buffer, {}), true) end) it("nofile buffer is blacklisted", function() local test_buffer = vim.api.nvim_create_buf(false, false) vim.api.nvim_set_option_value("buftype", "nofile", { buf = test_buffer }) - eq(utils.is_blacklisted_buffer(test_buffer), true) + eq(utils.is_blacklisted_buffer(test_buffer, {}), true) end) it("prompt buffer is blacklisted", function() local test_buffer = vim.api.nvim_create_buf(false, false) vim.api.nvim_set_option_value("buftype", "prompt", { buf = test_buffer }) - eq(utils.is_blacklisted_buffer(test_buffer), true) + eq(utils.is_blacklisted_buffer(test_buffer, {}), true) end) it("help buffer is blacklisted", function() local test_buffer = vim.api.nvim_create_buf(false, false) vim.api.nvim_set_option_value("buftype", "help", { buf = test_buffer }) - eq(utils.is_blacklisted_buffer(test_buffer), true) + eq(utils.is_blacklisted_buffer(test_buffer, {}), true) end) it("terminal buffer is blacklisted", function() local test_buffer = vim.api.nvim_create_buf(false, false) vim.api.nvim_open_term(test_buffer, {}) - eq(utils.is_blacklisted_buffer(test_buffer), true) + eq(utils.is_blacklisted_buffer(test_buffer, {}), true) end) it("blacklisted buffer by filetype", function()