'keymap' now uses :lmap instead of :lnoremap

This means that the major way that :lmap mappings are applied works as
one would expect with macros.
This also means that having a translation with 'keymap' does not
preclude using mappings in insert mode with :imap.
This commit is contained in:
Matthew Malcomson 2018-01-24 13:16:27 +00:00
parent d989051220
commit 3b304fc04a
2 changed files with 80 additions and 80 deletions

View File

@ -1827,12 +1827,12 @@ void ex_loadkeymap(exarg_T *eap)
xfree(line); xfree(line);
} }
// setup ":lnoremap" to map the keys // setup ":lmap" to map the keys
for (int i = 0; i < curbuf->b_kmap_ga.ga_len; ++i) { for (int i = 0; i < curbuf->b_kmap_ga.ga_len; ++i) {
vim_snprintf((char *)buf, sizeof(buf), "<buffer> %s %s", vim_snprintf((char *)buf, sizeof(buf), "<buffer> %s %s",
((kmap_T *)curbuf->b_kmap_ga.ga_data)[i].from, ((kmap_T *)curbuf->b_kmap_ga.ga_data)[i].from,
((kmap_T *)curbuf->b_kmap_ga.ga_data)[i].to); ((kmap_T *)curbuf->b_kmap_ga.ga_data)[i].to);
(void)do_map(2, buf, LANGMAP, FALSE); (void)do_map(0, buf, LANGMAP, FALSE);
} }
p_cpo = save_cpo; p_cpo = save_cpo;

View File

@ -17,94 +17,94 @@ describe("'keymap' / :lmap", function()
feed('gg0') feed('gg0')
end) end)
describe("'keymap' as :lnoremap", function() describe("'keymap' as :lmap", function()
-- Shows that 'keymap' sets language mappings without allowing -- Shows that 'keymap' sets language mappings that allows remapping.
-- remapping of those mappings. -- This equivalence allows us to only test :lmap commands and assert they
-- This equivalence allows us to only test :lmap commands and assert -- behave the same as 'keymap' settings.
-- they behave the same as 'keymap' settings.
-- It does rely on the absence of special code that implements 'keymap' -- It does rely on the absence of special code that implements 'keymap'
-- and :lmap differently but shows mappings from the 'keymap' after -- and :lmap differently but shows mappings from the 'keymap' after
-- typing :lmap. -- typing :lmap.
-- At the moment this is the case.
it("'keymap' mappings are shown with :lmap", function() it("'keymap' mappings are shown with :lmap", function()
command('lmapclear') command('lmapclear')
command('lmapclear <buffer>') command('lmapclear <buffer>')
command('set keymap=dvorak') command('set keymap=dvorak')
command('set nomore') command('set nomore')
local bindings = funcs.nvim_command_output('lmap') local bindings = funcs.nvim_command_output('lmap')
eq(bindings, dedent([[ eq(dedent([[
l " *@_ l " @_
l ' *@- l ' @-
l + *@} l + @}
l , *@w l , @w
l - *@[ l - @[
l . *@v l . @v
l / *@z l / @z
l : *@S l : @S
l ; *@s l ; @s
l < *@W l < @W
l = *@] l = @]
l > *@V l > @V
l ? *@Z l ? @Z
l A *@A l A @A
l B *@X l B @X
l C *@J l C @J
l D *@E l D @E
l E *@> l E @>
l F *@U l F @U
l G *@I l G @I
l H *@D l H @D
l I *@C l I @C
l J *@H l J @H
l K *@T l K @T
l L *@N l L @N
l M *@M l M @M
l N *@B l N @B
l O *@R l O @R
l P *@L l P @L
l Q *@" l Q @"
l R *@P l R @P
l S *@O l S @O
l T *@Y l T @Y
l U *@G l U @G
l V *@K l V @K
l W *@< l W @<
l X *@Q l X @Q
l Y *@F l Y @F
l Z *@: l Z @:
l [ *@/ l [ @/
l \ *@\ l \ @\
l ] *@= l ] @=
l _ *@{ l _ @{
l a *@a l a @a
l b *@x l b @x
l c *@j l c @j
l d *@e l d @e
l e *@. l e @.
l f *@u l f @u
l g *@i l g @i
l h *@d l h @d
l i *@c l i @c
l j *@h l j @h
l k *@t l k @t
l l *@n l l @n
l m *@m l m @m
l n *@b l n @b
l o *@r l o @r
l p *@l l p @l
l q *@' l q @'
l r *@p l r @p
l s *@o l s @o
l t *@y l t @y
l u *@g l u @g
l v *@k l v @k
l w *@, l w @,
l x *@q l x @q
l y *@f l y @f
l z *@; l z @;
l { *@? l { @?
l | *@| l | @|
l } *@+]])) l } @+]]), bindings)
end) end)
end) end)
describe("'iminsert' option", function() describe("'iminsert' option", function()