diff --git a/.config/nvim/lua/editor/keymaps.lua b/.config/nvim/lua/editor/keymaps.lua index 3f84c70..45e6fc4 100644 --- a/.config/nvim/lua/editor/keymaps.lua +++ b/.config/nvim/lua/editor/keymaps.lua @@ -45,7 +45,7 @@ vim.keymap.set("n", "#", function() vim.o.relativenumber = not vim.o.relativenumber end) --- go to codeberg/github/tangled/gitlab, go to file/line, or +-- go to URL, go to file, or vim.keymap.set("n", "", function() local path = vim.fn.expand("") local buf = vim.api.nvim_get_current_buf() @@ -58,29 +58,13 @@ vim.keymap.set("n", "", function() return end - if string.find(path, "^[a-zA-Z0-9-_.]*/[a-zA-Z0-9-_.]*$") then - local sources = { - "https://codeberg.org/", - "https://github.com/", - "https://tangled.org/", - "https://gitlab.com/", - } - for _, src in ipairs(sources) do - local url = src .. path - local resp = io.popen("curl -LIs " .. url) - if resp ~= nil then - local status = resp:read("*l") - if string.find(status, "HTTP/[0-9.]+ 200") then - local cmd = "xdg-open" - if vim.fn.has("mac") == 1 then - cmd = "open" - end - vim.fn.jobstart({ cmd, url }, { detach = true }) - return - end - resp:close() - end + if string.match(path, "^https?://") then + local cmd = "xdg-open" + if vim.fn.has("mac") == 1 then + cmd = "open" end + vim.fn.jobstart({ cmd, path }, { detach = true }) + return end return ""