aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsrdusr <trevorgray@srdusr.com>2023-03-18 23:00:44 +0200
committersrdusr <trevorgray@srdusr.com>2023-03-18 23:00:44 +0200
commit7b730d6b7b016d5cd602f280f879602ab44f59bd (patch)
treebde5dd3b4e5e192e65bb34963e3ba5e9a143bbe8
parent7bf0bc4fab41f035c544e5e8c705804bdbf51094 (diff)
downloaddotfiles-7b730d6b7b016d5cd602f280f879602ab44f59bd.tar.gz
dotfiles-7b730d6b7b016d5cd602f280f879602ab44f59bd.zip
Add URL handling mapping with system awareness
-rw-r--r--lua/user/keys.lua11
1 files changed, 11 insertions, 0 deletions
diff --git a/lua/user/keys.lua b/lua/user/keys.lua
index fe9e3af..e007260 100644
--- a/lua/user/keys.lua
+++ b/lua/user/keys.lua
@@ -177,6 +177,17 @@ map("n", "<leader>cd", ":cd %:p:h<CR>:pwd<CR>")
-- Open the current file in the default program (on Mac this should just be just `open`)
map('n', '<leader>o', ':!xdg-open %<cr><cr>')
+-- URL handling
+if vim.fn.has("mac") == 1 then
+ map("", "gx", '<Cmd>call jobstart(["open", expand("<cfile>")], {"detach": v:true})<CR>', {})
+elseif vim.fn.has("unix") == 1 then
+ map("", "gx", '<Cmd>call jobstart(["xdg-open", expand("<cfile>")], {"detach": v:true})<CR>', {})
+elseif vim.fn.has("wsl") == 1 then
+ map("", "gx", '<Cmd>call jobstart(["wslview", expand("<cfile>")], {"detach": v:true})<CR>', {})
+else
+ map[''].gx = {'<Cmd>lua print("Error: gx is not supported on this OS!")<CR>'}
+end
+
-- Toggle completion
map("n", "<Leader>tc", ":lua require('user.mods').toggle_completion()<CR>")