From 65255618d86b4969b3ca01b3c143dcd853915f27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20La=C3=ADn?= Date: Sat, 23 Dec 2023 02:02:17 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20refactor(nvim):=20search?= =?UTF-8?q?=20in=20the=20internet=20keymap=20function?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .config/nvim/lua/config/keymaps.lua | 30 +++++++---------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/.config/nvim/lua/config/keymaps.lua b/.config/nvim/lua/config/keymaps.lua index 69db0f2b..32db620d 100644 --- a/.config/nvim/lua/config/keymaps.lua +++ b/.config/nvim/lua/config/keymaps.lua @@ -4,29 +4,10 @@ local map = vim.keymap.set local Util = require("lazyvim.util") --- Google current word --- ╭───────────────────────────────────────────────────────────╮ --- │ Credit: June Gunn ?/! | Google it / Feeling lucky │ --- ╰───────────────────────────────────────────────────────────╯ - -vim.g.open_command = vim.g.open_command or "xdg-open" ----@param pat string ----@param lucky boolean -local function google(pat, lucky) - local query = '"' .. vim.fn.substitute(pat, '["\n]', " ", "g") .. '"' - query = vim.fn.substitute(query, "[[:punct:] ]", [[\=printf("%%%02X", char2nr(submatch(0)))]], "g") - vim.fn.system( - vim.fn.printf(vim.g.open_command .. ' "https://www.google.com/search?%sq=%s"', lucky and "btnI&" or "", query) - ) -end - -map("n", "?", function() - google(vim.fn.expand(""), false) -end, { desc = "Google" }) - -map("x", "?", function() - google(vim.fn.getreg("g"), false) -end, { desc = "Google" }) +-- Search current word +local searching_brave = + [[:lua vim.fn.system({'xdg-open', 'https://search.brave.com/search?q=' .. vim.fn.expand("")})]] +map("n", "?", searching_brave, { noremap = true, silent = true, desc = "Search current word on brave search" }) -- Toggle background map("n", "uB", function() @@ -74,6 +55,9 @@ map("n", "cic", "ConformInfo", { desc = "Conform" }) map("n", "cir", "LazyRoot", { desc = "Root" }) map("n", "cie", "LazyExtras", { desc = "Extras" }) +-- U for redo +map("n", "U", "", { desc = "Redo" }) + -- Move to beginning/end of line map("n", "", "_", { desc = "First character of Line" }) map("n", "", "$", { desc = "Last character of Line" })