diff options
Diffstat (limited to 'src/nvim/getchar.c')
-rw-r--r-- | src/nvim/getchar.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index b0d06b7a30..2b6c5b9f37 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -34,6 +34,7 @@ #include "nvim/memory.h" #include "nvim/message.h" #include "nvim/misc1.h" +#include "nvim/plines.h" #include "nvim/keymap.h" #include "nvim/garray.h" #include "nvim/move.h" @@ -840,6 +841,14 @@ static void init_typebuf(void) } } +void init_default_mappings(void) +{ + add_map((char_u *)"Y y$", NORMAL, true); + add_map((char_u *)"<C-L> <Cmd>nohlsearch<Bar>diffupdate<CR><C-L>", NORMAL, true); + add_map((char_u *)"<C-U> <C-G>u<C-U>", INSERT, true); + add_map((char_u *)"<C-W> <C-G>u<C-W>", INSERT, true); +} + // Insert a string in position 'offset' in the typeahead buffer (for "@r" // and ":normal" command, vgetorpeek() and check_termcode()) // @@ -1161,7 +1170,7 @@ void may_sync_undo(void) { if ((!(State & (INSERT + CMDLINE)) || arrow_used) && scriptin[curscript] == NULL) - u_sync(FALSE); + u_sync(false); } /* @@ -4356,18 +4365,23 @@ check_map ( } -/* - * Add a mapping "map" for mode "mode". - * Need to put string in allocated memory, because do_map() will modify it. - */ -void add_map(char_u *map, int mode) +/// Add a mapping. Unlike @ref do_map this copies the {map} argument, so +/// static or read-only strings can be used. +/// +/// @param map C-string containing the arguments of the map/abbrev command, +/// i.e. everything except the initial `:[X][nore]map`. +/// @param mode Bitflags representing the mode in which to set the mapping. +/// See @ref get_map_mode. +/// @param nore If true, make a non-recursive mapping. +void add_map(char_u *map, int mode, bool nore) { char_u *s; char_u *cpo_save = p_cpo; p_cpo = (char_u *)""; // Allow <> notation + // Need to put string in allocated memory, because do_map() will modify it. s = vim_strsave(map); - (void)do_map(0, s, mode, FALSE); + (void)do_map(nore ? 2 : 0, s, mode, false); xfree(s); p_cpo = cpo_save; } |