diff options
author | Gregory Anders <greg@gpanders.com> | 2021-08-16 09:31:14 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-16 08:31:14 -0700 |
commit | 0aa8128aaa9e6f714372f7ea7299f4115de0a962 (patch) | |
tree | 4699f46b0c156f06b8d1b8f2bf9d748cc6c40735 /src | |
parent | 7146103be2bc576c273fd9df2f922b6b5ba4c972 (diff) | |
download | rneovim-0aa8128aaa9e6f714372f7ea7299f4115de0a962.tar.gz rneovim-0aa8128aaa9e6f714372f7ea7299f4115de0a962.tar.bz2 rneovim-0aa8128aaa9e6f714372f7ea7299f4115de0a962.zip |
feat(defaults): map CTRL-L to search highlights, update diffs #15385
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/ex_getln.c | 4 | ||||
-rw-r--r-- | src/nvim/getchar.c | 17 | ||||
-rw-r--r-- | src/nvim/normal.c | 3 | ||||
-rw-r--r-- | src/nvim/testdir/setup.vim | 3 |
4 files changed, 18 insertions, 9 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index af8a23f5cc..7cab3eb650 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -6259,8 +6259,8 @@ static int open_cmdwin(void) const int histtype = hist_char2type(cmdwin_type); if (histtype == HIST_CMD || histtype == HIST_DEBUG) { if (p_wc == TAB) { - add_map((char_u *)"<buffer> <Tab> <C-X><C-V>", INSERT); - add_map((char_u *)"<buffer> <Tab> a<C-X><C-V>", NORMAL); + add_map((char_u *)"<buffer> <Tab> <C-X><C-V>", INSERT, false); + add_map((char_u *)"<buffer> <Tab> a<C-X><C-V>", NORMAL, false); } set_option_value("ft", 0L, "vim", OPT_LOCAL); } diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index f955fe8859..63da6f7922 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -4357,18 +4357,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; } diff --git a/src/nvim/normal.c b/src/nvim/normal.c index ae6f3792de..f3869e7e44 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -399,7 +399,8 @@ void init_normal_cmds(void) void init_default_mappings(void) { - add_map((char_u *)"Y y$", NORMAL); + add_map((char_u *)"Y y$", NORMAL, true); + add_map((char_u *)"<C-L> <Cmd>nohlsearch<Bar>diffupdate<CR><C-L>", NORMAL, true); } /* diff --git a/src/nvim/testdir/setup.vim b/src/nvim/testdir/setup.vim index e8f6e74311..4e072ed689 100644 --- a/src/nvim/testdir/setup.vim +++ b/src/nvim/testdir/setup.vim @@ -21,7 +21,10 @@ set undodir^=. set wildoptions= set startofline set sessionoptions+=options + +" Unmap Nvim default mappings. unmap Y +unmap <C-L> " Prevent Nvim log from writing to stderr. let $NVIM_LOG_FILE = exists($NVIM_LOG_FILE) ? $NVIM_LOG_FILE : 'Xnvim.log' |