Skip to content

Commit

Permalink
feat(char): support alternative f/F/t/T/;/, keymaps (fix #96) (#99)
Browse files Browse the repository at this point in the history
* Support alternative f/F/t/T/;/, keymaps (fix #96)

* refactor(char): merge maps and keys functionality

* refactor: removed maps

---------

Co-authored-by: Folke Lemaitre <[email protected]>
  • Loading branch information
j-hui and folke authored Jun 29, 2023
1 parent 40b2bcb commit c0c006a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,9 @@ Install the plugin with your preferred package manager:
-- when to show jump labels
jump_labels = function(motion)
-- never show jump labels by default
-- return false
return false
-- Always show jump labels for ftFT
return vim.v.count == 0 and motion:find("[ftFT]")
-- return vim.v.count == 0 and motion:find("[ftFT]")
-- Show jump labels for ftFT in operator-pending mode
-- return vim.v.count == 0 and motion:find("[ftFT]") and vim.fn.mode(true):find("o")
end,
Expand All @@ -292,6 +292,8 @@ Install the plugin with your preferred package manager:
label = { exclude = "hjkliardc" },
-- by default all keymaps are enabled, but you can disable some of them,
-- by removing them from the list.
-- If you rather use another key, you can map them
-- to something else, e.g., { [";"] = "L", [","] = H }
keys = { "f", "F", "t", "T", ";", "," },
search = { wrap = false },
highlight = { backdrop = true },
Expand Down
2 changes: 2 additions & 0 deletions lua/flash/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ local defaults = {
label = { exclude = "hjkliardc" },
-- by default all keymaps are enabled, but you can disable some of them,
-- by removing them from the list.
-- If you rather use another key, you can map them
-- to something else, e.g., { [";"] = "L", [","] = H }
keys = { "f", "F", "t", "T", ";", "," },
search = { wrap = false },
highlight = { backdrop = true },
Expand Down
10 changes: 8 additions & 2 deletions lua/flash/plugins/char.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,15 @@ end
function M.setup()
Repeat.setup()

local keys = {}

for k, v in pairs(Config.modes.char.keys) do
keys[type(k) == "number" and v or k] = v
end

for _, key in ipairs({ "f", "F", "t", "T", ";", "," }) do
if vim.tbl_contains(Config.modes.char.keys, key) then
vim.keymap.set({ "n", "x", "o" }, key, function()
if keys[key] then
vim.keymap.set({ "n", "x", "o" }, keys[key], function()
M.jumping = true
local autohide = Config.modes.char.autohide and Config.modes.char.autohide(key)
if Repeat.is_repeat then
Expand Down

0 comments on commit c0c006a

Please sign in to comment.