aboutsummaryrefslogtreecommitdiffstats
path: root/plugin/50-transform_text.lua
blob: 4687fef6cdedc4b7152a094d2a4854b13273f643 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
--[[ 50-transform_text.lua — transforms the visual selection in place via dotfiles.selection
(URL-encode / URL-decode).

Keymaps:
  `<Leader>tte`: URL-encode selection
  `<Leader>ttd`: URL-decode selection
]]

local selection = require("dotfiles.selection")

-- URL-encode the visual selection.
local function url_encode_selection()
	selection.transform(vim.uri_encode)
end

-- URL-decode the visual selection.
local function url_decode_selection()
	selection.transform(vim.uri_decode)
end

vim.keymap.set("x", "<Leader>tte", url_encode_selection, { desc = "URL-encode selection" })
vim.keymap.set("x", "<Leader>ttd", url_decode_selection, { desc = "URL-decode selection" })