From 59545fa03fd37ab712a721ff0868f2493e689fcf Mon Sep 17 00:00:00 2001 From: Marcelo Date: Sun, 30 Mar 2025 04:26:45 -0300 Subject: `gx` will open the neovim plugins in github. If `gx` is used over a string of the format "xxx/yyy" when editing a Lua file, a github prefix will be added before opening. Also fixed other Lua specific bindings with `buffer = true`, so that those bindings stop spilling outside lua. --- after/ftplugin/lua.lua | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/after/ftplugin/lua.lua b/after/ftplugin/lua.lua index dca196a..5011d56 100644 --- a/after/ftplugin/lua.lua +++ b/after/ftplugin/lua.lua @@ -1,3 +1,13 @@ -vim.keymap.set("n", "x", "source %", { desc = "Reloads the current config file" }) -vim.keymap.set("n", "x", ".lua", { desc = "Executes the current line" }) -vim.keymap.set("v", "x", "lua", { desc = "Executes the current selection" }) +vim.keymap.set("n", "x", "source %", { buffer = true, desc = "Reloads the current config file" }) +vim.keymap.set("n", "x", ".lua", { buffer = true, desc = "Executes the current line" }) +vim.keymap.set("v", "x", "lua", { buffer = true, desc = "Executes the current selection" }) + +-- Open neovim plugins in github. +vim.keymap.set("n", "gx", function() + local path = vim.fn.expand('') + local url = path:match([[^["']([^/]+/[^/]+)["'],?$]]) + if url then + path = "https://github.com/" .. url + end + vim.ui.open(path) +end, { buffer = true }) -- cgit v1.2.3