From 9b9e43558ba58b43c20e57cd508a8753239dfe79 Mon Sep 17 00:00:00 2001 From: Johannes Kresner Date: Fri, 13 Nov 2026 13:58:11 +0100 Subject: [PATCH] feat: add keymap for gR (go references) --- lua/core/keymaps.lua | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lua/core/keymaps.lua b/lua/core/keymaps.lua index a77053e..1606fc1 100644 --- a/lua/core/keymaps.lua +++ b/lua/core/keymaps.lua @@ -50,6 +50,16 @@ map({ "n", "x", "o" }, "", function() end end, { desc = "Select child node" }) +-- Go to references: jump directly when there is one, quickfix list otherwise +map("n", "gR", function() + vim.lsp.buf.references(nil, { + on_list = function(o) + vim.fn.setqflist({}, " ", o) + vim.cmd(#o.items == 1 and "cfirst" or "copen") + end, + }) +end, { desc = "Go to references" }) + map("n", "fl", function() local value = vim.fn.fnamemodify(vim.fn.expand("%"), ":~:.") .. ":" .. vim.fn.line(".") vim.fn.setreg("+", value)