From a0cf00c81b3a4a352cdc26c94112d9a5827881e1 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Fri, 17 Feb 2023 21:32:25 +0100 Subject: [PATCH] fix(illuminate): always set refernce keymaps on the buffer as well to properly overwrite ftplugin mappings. Fixes #292 --- lua/lazyvim/plugins/editor.lua | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/lua/lazyvim/plugins/editor.lua b/lua/lazyvim/plugins/editor.lua index 9b1699e7..2178cc5a 100644 --- a/lua/lazyvim/plugins/editor.lua +++ b/lua/lazyvim/plugins/editor.lua @@ -261,18 +261,28 @@ return { opts = { delay = 200 }, config = function(_, opts) require("illuminate").configure(opts) + + local function map(key, dir, buffer) + vim.keymap.set("n", key, function() + require("illuminate")["goto_" .. dir .. "_reference"](false) + end, { desc = dir:sub(1, 1):upper() .. dir:sub(2) .. " Reference", buffer = buffer }) + end + + map("]]", "next") + map("[[", "prev") + + -- also set it after loading ftplugins, since a lot overwrite [[ and ]] vim.api.nvim_create_autocmd("FileType", { callback = function() local buffer = vim.api.nvim_get_current_buf() - pcall(vim.keymap.del, "n", "]]", { buffer = buffer }) - pcall(vim.keymap.del, "n", "[[", { buffer = buffer }) + map("]]", "next", buffer) + map("[[", "prev", buffer) end, }) end, - -- stylua: ignore keys = { - { "]]", function() require("illuminate").goto_next_reference(false) end, desc = "Next Reference", }, - { "[[", function() require("illuminate").goto_prev_reference(false) end, desc = "Prev Reference" }, + { "]]", desc = "Next Reference" }, + { "[[", desc = "Prev Reference" }, }, },