From eb9b93b5e025386ec9431c9d35a4a073d6946d1d Mon Sep 17 00:00:00 2001 From: matveyt <35012635+matveyt@users.noreply.github.com> Date: Sun, 17 Jul 2022 14:14:04 +0300 Subject: feat(defaults): mouse=nvi #19290 Problem: Since right-click can now show a popup menu, we can provide messaging to guide users who expect 'mouse' to be disabled by default. So 'mouse' can now be enabled by default. Solution: Do it. Closes #15521 --- runtime/lua/vim/_editor.lua | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'runtime/lua/vim') diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua index 7febad6ef6..c4cc151bca 100644 --- a/runtime/lua/vim/_editor.lua +++ b/runtime/lua/vim/_editor.lua @@ -810,6 +810,44 @@ function vim.deprecate(name, alternative, version, plugin, backtrace) end end +--- Create builtin mappings (incl. menus). +--- Called once on startup. +function vim._init_default_mappings() + -- mappings + + --@private + local function map(mode, lhs, rhs) + vim.api.nvim_set_keymap(mode, lhs, rhs, { noremap = true, desc = 'Nvim builtin' }) + end + + map('n', 'Y', 'y$') + -- Use normal! to prevent inserting raw when using i_. #17473 + map('n', '', 'nohlsearchdiffupdatenormal! ') + map('i', '', 'u') + map('i', '', 'u') + map('x', '*', 'y/\\V"') + map('x', '#', 'y?\\V"') + -- Use : instead of so that ranges are supported. #19365 + map('n', '&', ':&&') + + -- menus + + -- TODO VimScript, no l10n + vim.cmd([[ + aunmenu * + vnoremenu PopUp.Cut "+x + vnoremenu PopUp.Copy "+y + anoremenu PopUp.Paste "+gP + vnoremenu PopUp.Paste "+P + vnoremenu PopUp.Delete "_x + nnoremenu PopUp.Select\ All ggVG + vnoremenu PopUp.Select\ All gg0oG$ + inoremenu PopUp.Select\ All VG + anoremenu PopUp.-1- + anoremenu PopUp.How-to\ disable\ mouse help disable-mouse + ]]) +end + require('vim._meta') return vim -- cgit