aboutsummaryrefslogtreecommitdiff
path: root/config.dot/luakit.link/keys.lua
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2017-09-21 16:14:31 -0300
committerSilvio Rhatto <rhatto@riseup.net>2017-09-21 16:14:31 -0300
commit49c05a4f1b369675883d8037312a26ead4893a5c (patch)
treee20b057071599f4bcf6967690cf517d26f24e0e7 /config.dot/luakit.link/keys.lua
parente1f2e7910602df6aad5c0f6a82e8458d54e61280 (diff)
downloadluakit-49c05a4f1b369675883d8037312a26ead4893a5c.tar.gz
luakit-49c05a4f1b369675883d8037312a26ead4893a5c.tar.bz2
Major update compatible with current upstream
Diffstat (limited to 'config.dot/luakit.link/keys.lua')
-rw-r--r--config.dot/luakit.link/keys.lua86
1 files changed, 86 insertions, 0 deletions
diff --git a/config.dot/luakit.link/keys.lua b/config.dot/luakit.link/keys.lua
new file mode 100644
index 0000000..d1f16c7
--- /dev/null
+++ b/config.dot/luakit.link/keys.lua
@@ -0,0 +1,86 @@
+--
+-- Custom keybindings
+--
+
+-- Requirements
+local modes = require "modes"
+local window = require "window"
+
+-- Remove some default bindings
+modes.remove_binds("normal", { "y" })
+
+-- Add custom binds
+modes.add_binds("normal", {
+ { "h", "New blank tab", function (w)
+ w:new_tab('luakit://newtab')
+ end},
+})
+
+-- Add custom Yank bindings
+modes.add_binds("normal", {
+ -- Yank URL
+ { "^yy$", function (w)
+ local uri = string.gsub(w.view.uri or "", " ", "%%20")
+ luakit.selection.primary = uri
+ luakit.selection.clipboard = uri
+ w:notify("Yanked uri: " .. uri)
+ end},
+
+ -- Yank title
+ { "^yt$", function (w)
+ local title = w.view.title
+ luakit.selection.primary = title
+ luakit.selection.clipboard = uri
+ w:notify("Yanked title: " .. title)
+ end},
+
+ -- Yank URL and title as a Markdown link
+ { "^ym$", function (w)
+ local title = w.view.title
+ local uri = string.gsub(w.view.uri or "", " ", "%%20")
+ local link = '[' .. title .. '](' .. uri .. ')'
+ luakit.selection.primary = link
+ luakit.selection.clipboard = link
+ w:notify("Yanked as markdown link: " .. link)
+ end},
+
+ -- Yank URL and title as a reStructuredText link
+ { "^yr$", function (w)
+ local title = w.view.title
+ local uri = string.gsub(w.view.uri or "", " ", "%%20")
+ local link = '`' .. title .. '` <' .. uri .. '>`_'
+ luakit.selection.primary = link
+ luakit.selection.clipboard = link
+ w:notify("Yanked as reStructuredText link: " .. link)
+ end},
+
+ -- Yank URL and title as a Trac link
+ { "^yc$", function (w)
+ local title = w.view.title
+ local uri = string.gsub(w.view.uri or "", " ", "%%20")
+ local link = '[' .. uri .. ' ' .. title .. ']'
+ luakit.selection.primary = link
+ luakit.selection.clipboard = link
+ w:notify("Yanked as Trac link: " .. link)
+ end},
+
+ -- Yank URL and title as an HTML link
+ { "^yh$", function (w)
+ local title = w.view.title
+ local uri = string.gsub(w.view.uri or "", " ", "%%20")
+ local link = '<a href="' .. uri .. '">' .. title .. '</a>'
+ luakit.selection.primary = link
+ luakit.selection.clipboard = link
+ w:notify("Yanked as HTML link: " .. link)
+ end},
+
+ -- Yank URL and title as a shareable link
+ { "^ys$", function (w)
+ local title = w.view.title
+ local uri = string.gsub(w.view.uri or "", " ", "%%20")
+ local link = title .. ' - ' .. uri
+ luakit.selection.primary = link
+ luakit.selection.clipboard = link
+ w:notify("Yanked as shareable link: " .. link)
+ end},
+})