From a3753a0e92eb0ad44af2b466cfb914d40a2267b4 Mon Sep 17 00:00:00 2001 From: Amirabbas Fazelinia Date: Tue, 7 Mar 2023 21:21:57 +0330 Subject: [PATCH] feat(command): create `DoMatchParen` and `NoMatchParen` user commands --- lua/sentiment.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lua/sentiment.lua b/lua/sentiment.lua index fa1685f..3775a7f 100644 --- a/lua/sentiment.lua +++ b/lua/sentiment.lua @@ -1,8 +1,26 @@ local manager = require("sentiment.config.manager") local autocmds = require("sentiment.autocmds") +local ui = require("sentiment.ui") local M = {} +---Create matchparen.vim style user commands. +local function create_user_commands() + vim.api.nvim_create_user_command("NoMatchParen", function() + if not autocmds.renderer:exists() then return end + + autocmds.renderer:remove() + ui.clear() + end, {}) + + vim.api.nvim_create_user_command("DoMatchParen", function() + if autocmds.renderer:exists() then return end + + ui.render() + autocmds.renderer:create() + end, {}) +end + ---Load and setup the plugin with an optional config table. --- ---NOTE: Calling this disables the builtin matchparen plugin. @@ -13,6 +31,7 @@ function M.setup(cfg) manager.apply(cfg or {}) autocmds.renderer:create() + create_user_commands() end return M