aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authormatveyt <35012635+matveyt@users.noreply.github.com>2022-07-17 14:14:04 +0300
committerGitHub <noreply@github.com>2022-07-17 04:14:04 -0700
commiteb9b93b5e025386ec9431c9d35a4a073d6946d1d (patch)
tree4b371f7cf93aab052770590b9b995f94c8662fbd /runtime
parentaae11865e1f74678a6415703ce1e076d195a2c26 (diff)
downloadrneovim-eb9b93b5e025386ec9431c9d35a4a073d6946d1d.tar.gz
rneovim-eb9b93b5e025386ec9431c9d35a4a073d6946d1d.tar.bz2
rneovim-eb9b93b5e025386ec9431c9d35a4a073d6946d1d.zip
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
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/gui.txt13
-rw-r--r--runtime/doc/options.txt6
-rw-r--r--runtime/doc/starting.txt2
-rw-r--r--runtime/doc/vim_diff.txt26
-rw-r--r--runtime/lua/vim/_editor.lua38
5 files changed, 81 insertions, 4 deletions
diff --git a/runtime/doc/gui.txt b/runtime/doc/gui.txt
index 5badd954d9..776ff228d6 100644
--- a/runtime/doc/gui.txt
+++ b/runtime/doc/gui.txt
@@ -441,6 +441,19 @@ You can define the special menu "PopUp". This is the menu that is displayed
when the right mouse button is pressed, if 'mousemodel' is set to popup or
popup_setpos.
+The default "PopUp" menu is: >
+ aunmenu PopUp
+ 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 <C-Home><C-O>VG
+ anoremenu PopUp.-1- <Nop>
+ anoremenu PopUp.How-to\ disable\ mouse <Cmd>help disable-mouse<CR>
+<
Showing What Menus Are Mapped To *showing-menus*
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index 74ba353e0a..0f1c2051a6 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -4086,7 +4086,7 @@ A jump table for the options with a short description can be found at |Q_op|.
listing continues until finished.
*'mouse'*
-'mouse' string (default "")
+'mouse' string (default "nvi")
global
Enables mouse support. For example, to enable the mouse in Normal mode
@@ -4158,7 +4158,7 @@ A jump table for the options with a short description can be found at |Q_op|.
The mouse pointer is restored when the mouse is moved.
*'mousemodel'* *'mousem'*
-'mousemodel' 'mousem' string (default "extend")
+'mousemodel' 'mousem' string (default "popup_setpos")
global
Sets the model to use for the mouse. The name mostly specifies what
the right mouse button is used for:
@@ -4184,7 +4184,7 @@ A jump table for the options with a short description can be found at |Q_op|.
middle click paste paste
In the "popup" model the right mouse button produces a pop-up menu.
- You need to define this first, see |popup-menu|.
+ Nvim creates a default |popup-menu| but you can redefine it.
Note that you can further refine the meaning of buttons with mappings.
See |mouse-overview|. But mappings are NOT used for modeless selection.
diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt
index 108a47c522..d57a85423c 100644
--- a/runtime/doc/starting.txt
+++ b/runtime/doc/starting.txt
@@ -407,7 +407,7 @@ accordingly, proceeding as follows:
Nvim started with |--embed| waits for the UI to connect before
proceeding to load user configuration.
-4. Setup |default-mappings| and |default-autocmds|.
+4. Setup |default-mappings| and |default-autocmds|. Create |popup-menu|.
5. Enable filetype and indent plugins.
This does the same as the command: >
diff --git a/runtime/doc/vim_diff.txt b/runtime/doc/vim_diff.txt
index bacf160206..a74149d050 100644
--- a/runtime/doc/vim_diff.txt
+++ b/runtime/doc/vim_diff.txt
@@ -52,6 +52,8 @@ centralized reference of the differences.
- 'langremap' is disabled
- 'laststatus' defaults to 2 (statusline is always shown)
- 'listchars' defaults to "tab:> ,trail:-,nbsp:+"
+- 'mouse' defaults to "nvi"
+- 'mousemodel' defaults to "popup_setpos"
- 'nrformats' defaults to "bin,hex"
- 'ruler' is enabled
- 'sessionoptions' includes "unix,slash", excludes "options"
@@ -78,6 +80,30 @@ centralized reference of the differences.
- |g:vimsyn_embed| defaults to "l" to enable Lua highlighting
+Default Mouse ~
+ *default-mouse* *disable-mouse*
+By default the mouse is enabled. The right button click opens |popup-menu|
+with standard actions, such as "Cut", "Copy" and "Paste".
+
+If you don't like this you can add to your |config| any of the following:
+
+- ignore mouse completely >
+ set mouse=
+<
+- no |popup-menu| but the right button extends selection >
+ set mousemodel=extend
+>
+- pressing ALT+LeftMouse releases mouse until main cursor moves >
+ nnoremap <M-LeftMouse> <Cmd>
+ \ set mouse=<Bar>
+ \ echo 'mouse OFF until next cursor-move'<Bar>
+ \ autocmd CursorMoved * ++once set mouse&<Bar>
+ \ echo 'mouse ON'<CR>
+<
+Also, mouse is not in use in |command-mode| or at |more-prompt|. So if you
+need to copy/paste with your terminal then just pressing ':' makes Nvim to
+release the mouse cursor temporarily.
+
Default Mappings ~
*default-mappings*
Nvim creates the following default mappings at |startup|. You can disable any
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! <C-L> to prevent inserting raw <C-L> when using i_<C-O>. #17473
+ map('n', '<C-L>', '<Cmd>nohlsearch<Bar>diffupdate<Bar>normal! <C-L><CR>')
+ map('i', '<C-U>', '<C-G>u<C-U>')
+ map('i', '<C-W>', '<C-G>u<C-W>')
+ map('x', '*', 'y/\\V<C-R>"<CR>')
+ map('x', '#', 'y?\\V<C-R>"<CR>')
+ -- Use : instead of <Cmd> so that ranges are supported. #19365
+ map('n', '&', ':&&<CR>')
+
+ -- 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 <C-Home><C-O>VG
+ anoremenu PopUp.-1- <Nop>
+ anoremenu PopUp.How-to\ disable\ mouse <Cmd>help disable-mouse<CR>
+ ]])
+end
+
require('vim._meta')
return vim