martanne / vis

A vi-like editor based on Plan 9's structural regular expressions
Other
4.19k stars 260 forks source link

Can't Change Keymaps #1182

Closed VehementHam closed 2 months ago

VehementHam commented 2 months ago

Problem

When I try to change keymappings, they become very buggy, and do not do what they are supposed to.

Steps to reproduce

Try using Vis with the following config that changes keymappings:

-- ...

vis.events.subscribe(vis.events.INIT, function()
    -- Your global configuration options
end)

vis.events.subscribe(vis.events.WIN_OPEN, function(win) -- luacheck: no unused args
    -- Your per window configuration options e.g.
    vis:command('set theme base16-tomorrow-night')
    vis:command('set number')
    vis:command('set cursorline')
    -- key mappings
    vis:unmap(vis.modes.NORMAL, "d")
    vis:unmap(vis.modes.NORMAL, "h")
    vis:unmap(vis.modes.NORMAL, "t")
    vis:unmap(vis.modes.NORMAL, "n")
    vis:map(vis.modes.NORMAL "d", "<left>")
    vis:map(vis.modes.NORMAL "h", "<down>")
    vis:map(vis.modes.NORMAL "t", "<up>")
    vis:map(vis.modes.NORMAL "n", "<right>")
end)

-- ...

vis version (vis -v)

vis 0.8 +curses +lua +acl

Terminal name/version

foot version: 1.17.2 +pgo +ime +graphemes -assertions

$TERM environment variable

xterm-256color

rnpnr commented 2 months ago

A couple things:

VehementHam commented 2 months ago

Thanks

VehementHam commented 2 months ago
vis.events.subscribe(vis.events.INIT, function()
    -- Your global configuration options
    -- key mappings
    vis:map(vis.modes.NORMAL, "d", "<Left>")
    vis:map(vis.modes.NORMAL, "h", "<Down>")
    vis:map(vis.modes.NORMAL, "t", "<Up>")
    vis:map(vis.modes.NORMAL, "n", "<Right>")
end)