From 32c9626053d174bc938b6a48705074867759002d Mon Sep 17 00:00:00 2001 From: Marcelo Jacobus Date: Thu, 14 Aug 2025 09:59:30 -0300 Subject: [PATCH] Fix gf --- lua/user/keymaps.lua | 13 +++++++++++++ lua/user/options.lua | 2 -- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lua/user/keymaps.lua b/lua/user/keymaps.lua index 3095a3c..f0ae5b2 100644 --- a/lua/user/keymaps.lua +++ b/lua/user/keymaps.lua @@ -155,6 +155,19 @@ map("n", "irc", function() require("mj.ruby_utils").insert_ruby_class_based_on_file_path() end, { desc = "Insert ruby class" }) +-- Fix a quirk with isfname including ":" +-- This vim.opt.isfname:remove(":") may be overwritten on new buffers +map("n", "gf", function() + local raw = vim.fn.expand("") + local file, lnum, col = raw:match("^(.*):(%d+):?(%d*)$") + if file then + vim.cmd.edit(vim.fn.fnameescape(file)) + if lnum then vim.api.nvim_win_set_cursor(0, { tonumber(lnum), math.max(tonumber(col) - 1, 0) }) end + else + vim.cmd.edit(vim.fn.fnameescape(raw)) + end +end, { desc = "goto file (supports file:line[:col])" }) + -- this is not working correctly -- map("v", "irc", function() -- require("mj.ruby_utils").replace_selected_text_with_ruby_class() diff --git a/lua/user/options.lua b/lua/user/options.lua index 71f8b50..c9e042b 100644 --- a/lua/user/options.lua +++ b/lua/user/options.lua @@ -33,8 +33,6 @@ vim.opt.wrap = false vim.opt.ignorecase = true vim.opt.smartcase = true -vim.opt.isfname:remove(":") - -- Diagnostic config -- TODO: Do I still need this? -- vim.diagnostic.config({ virtual_text = false })