From 2b8c7a00a9690f3252b8fa4c437c14ad3e9f1ff8 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Fri, 17 Mar 2023 00:54:34 +0100 Subject: [PATCH] Firenvim website blacklisting --- dotfiles/neovim/lua/my/plugins/firenvim.lua | 43 ++++++++++++--------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/dotfiles/neovim/lua/my/plugins/firenvim.lua b/dotfiles/neovim/lua/my/plugins/firenvim.lua index 6286cea..6272cfa 100644 --- a/dotfiles/neovim/lua/my/plugins/firenvim.lua +++ b/dotfiles/neovim/lua/my/plugins/firenvim.lua @@ -4,23 +4,25 @@ local K = require("my.keymaps") local M = { "glacambre/firenvim", -- vim inside chrome lazy = false, - -- cond = env.firenvim.active(), - cond = true + cond = env.firenvim.active(), } -function M.blacklist(url) - vim.g.firenvim_config.localSettings[url] = { takeover = "never" } +M.localSettings = {} + +local function make_url_regex(url) + return "https?:\\/\\/(?:www\\.)?" .. url .. ".*" +end + +local function blacklist(url) + M.localSettings[make_url_regex(url)] = { takeover = "never", priority = 0 } end function M.config() - vim.g.firenvim_config = { - localSettings = { - [".*"] = { - filename = "/tmp/firenvim_{hostname}_{pathname}_{selector}_{timestamp}.{extension}", - }, - }, + -- {{{ Filename + M.localSettings[".*"] = { + filename = "/tmp/firenvim_{hostname}_{pathname}_{selector}_{timestamp}.{extension}", } - + -- }}} -- {{{ Ctrl-z to expand window K.nmap("", function() vim.opt.lines = 25 @@ -39,15 +41,18 @@ function M.config() vim.opt.laststatus = 0 -- }}} -- {{{ Blacklist websites - local blacklisted = { - "https?://web.whatsapp\\.com/.*", - "https?://twitter\\.com/", - } - - for _, url in ipairs(blacklisted) do - M.blacklist(url) - end + blacklist("web\\.whatsapp\\.com") + blacklist("twitter\\.com") + blacklist("desmos\\.com\\/calculator") + -- }}} + -- {{{ Comitting our config changes + vim.g.firenvim_config = { localSettings = M.localSettings } -- }}} end +function M.setup() + M.config() + print(vim.inspect(M.localSettings)) +end + return M