From 8627feb14838779c745e18b07ff0d2a5828e5098 Mon Sep 17 00:00:00 2001 From: Cian Hughes Date: Mon, 13 Jul 2026 10:29:33 +0100 Subject: [PATCH] Added dedicated lisp mode to config --- lua/config/keys.lua | 43 +++++++++++++++++++++++++++++++++++---- lua/plugins/lang/lisp.lua | 20 ++++++++++++++++++ lua/plugins/ui.lua | 1 + 3 files changed, 60 insertions(+), 4 deletions(-) create mode 100644 lua/plugins/lang/lisp.lua diff --git a/lua/config/keys.lua b/lua/config/keys.lua index f5d08bd..d94bdb1 100644 --- a/lua/config/keys.lua +++ b/lua/config/keys.lua @@ -506,13 +506,48 @@ return { function() local rm_module = require("rainbow-delimiters") rm_module.toggle(0) - if rm_module.is_enabled(0) then - vim.notify("Rainbow Delimiters: ON", vim.log.levels.INFO) + + local active = rm_module.is_enabled(0) + local buf = vim.api.nvim_get_current_buf() + local lisp_filetypes = + { "clojure", "fennel", "scheme", "lisp", "janet", "racket", "hy", "elisp" } + + if vim.tbl_contains(lisp_filetypes, vim.bo[buf].filetype) then + local has_paredit, paredit_config = pcall(require, "nvim-paredit.config") + if has_paredit then + local keys = paredit_config.config.keys + if active then + local has_kb, keybindings = + pcall(require, "nvim-paredit.utils.keybindings") + if has_kb then + keybindings.setup_keybindings({ + keys = keys, + buf = buf, + }) + end + else + for keymap, action in pairs(keys) do + if action then + local mode = action.mode or { "n", "x" } + if type(mode) == "string" then + mode = { mode } + end + for _, m in ipairs(mode) do + pcall(vim.keymap.del, m, keymap, { buffer = buf }) + end + end + end + end + end + vim.notify("Lisp Tooling: " .. (active and "ON" or "OFF"), vim.log.levels.INFO) else - vim.notify("Rainbow Delimiters: OFF", vim.log.levels.INFO) + vim.notify( + "Rainbow Delimiters: " .. (active and "ON" or "OFF"), + vim.log.levels.INFO + ) end end, - desc = "Toggle Rainbow Delimiters", + desc = "Toggle Lisp Tooling (Rainbow & Paredit)", }, }, } diff --git a/lua/plugins/lang/lisp.lua b/lua/plugins/lang/lisp.lua new file mode 100644 index 0000000..724d3f2 --- /dev/null +++ b/lua/plugins/lang/lisp.lua @@ -0,0 +1,20 @@ +return { + { + "julienvincent/nvim-paredit", + ft = { "clojure", "fennel", "scheme", "lisp", "janet", "racket", "hy", "elisp" }, + config = function() + require("nvim-paredit").setup({ + filetypes = { + "clojure", + "fennel", + "scheme", + "lisp", + "janet", + "racket", + "hy", + "elisp", + }, + }) + end, + }, +} diff --git a/lua/plugins/ui.lua b/lua/plugins/ui.lua index 09c0f94..8e25adc 100644 --- a/lua/plugins/ui.lua +++ b/lua/plugins/ui.lua @@ -133,6 +133,7 @@ return { -- UI components and other visual elements are declared here { "HiPhish/rainbow-delimiters.nvim", lazy = true, + ft = { "clojure", "fennel", "scheme", "lisp", "janet", "racket", "hy", "elisp" }, keys = require("config.keys").rainbow_delimiters, config = function() require("rainbow-delimiters.setup").setup({})