Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(defaults): enable mouse support#19290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
justinmk merged 2 commits intoneovim:masterfrommatveyt:mouse
Jul 17, 2022
Merged

feat(defaults): enable mouse support#19290

justinmk merged 2 commits intoneovim:masterfrommatveyt:mouse
Jul 17, 2022

Conversation

@matveyt
Copy link
Contributor

Closes#15521

adelarsq reacted with thumbs up emojiteto, adelarsq, and ya2s reacted with hooray emoji
@github-actionsgithub-actionsbot added the defaultsNvim defaults for options, colorscheme/theme, autocmds/events, etc. labelJul 8, 2022
@justinmk
Copy link
Member

justinmk commentedJul 8, 2022
edited
Loading

Can't do this until the full suggestion in#15521 (comment) is implemented.

  1. We need a right-click menu that has things like:
    CopyCutPasteDisable mouse
  2. we needalt+click to temporarilyset mouse= until the next cursor-move. this is an escape-hatch to allow copying screen elements that otherwise aren't copyable

@matveyt
Copy link
ContributorAuthor

Can't do this until the full suggestion in#15521 (comment) is implemented.

As menu functionality has been implemented, do I understand right that we lack few default commands, such as:menu PopUp.Paste "+gP, plus new help topic?

@justinmk
Copy link
Member

As menu functionality has been implemented, do I understand right that we lack few default commands, such as:menu PopUp.Paste "+gP, plus new help topic?

correct

@matveyt
Copy link
ContributorAuthor

@justinmk All done. The menu is embedded into C code to match with default mappings and autocommands.

I also changed the default forset mousemodel=popup_setpos to enable the menu from startup. But now it looks like a problem with functional tests, in particular,this one.

AFAIU, the test emulates mouse clicks in the status line area, but the popup menu shows up unexpectedly. So what's the plan? To reset mousemodel to "extend", or to set it for this test specifically, or to patch popup menu implementation, so it doesn't show up upon a click outside of buffer area?

Copy link
Member

@justinmkjustinmk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This is looking quite good, thanks for putting some thought into this :)

@justinmk

This comment was marked as resolved.

@famiu
Copy link
Member

But now it looks like a problem with functional tests, in particular,this one.
AFAIU, the test emulates mouse clicks in the status line area, but the popup menu shows up unexpectedly. So what's the plan? To reset mousemodel to "extend", or to set it for this test specifically, or to patch popup menu implementation, so it doesn't show up upon a click outside of buffer area?

@famiu does your PR help here?#19252

It should, yeah

@matveyt
Copy link
ContributorAuthor

@justinmk Okay, no problem. Should we also merge default autocmds in? Kind ofinit_default_actions() for everything, except the options?

could instead be done in Lua

I see neither l10n nor menu API but that's not important, I guess. Just going to embed a piece of VimScript into Lua for now.

@justinmk
Copy link
Member

justinmk commentedJul 14, 2022
edited
Loading

Should we also merge default autocmds in? Kind ofinit_default_actions() for everything, except the options?

no, don't want to decide that right now :)

Menus reallyare just mappings. Soinit_default_mappings does not need to be renamed.

Just going to embed a piece of VimScript into Lua for now.

that's fine--thanks!

@matveyt
Copy link
ContributorAuthor

Moved default mappings and menus to Lua. Cleaned up C code.

The functional test fails until PR#19252 merged.

Conflicts with PR#19365 asinit_default_mappings() is about to be removed from mapping.c. So need to port the new mapping to Lua when accepted.

justinmk reacted with heart emoji

@matveytmatveyt requested a review fromjustinmkJuly 15, 2022 11:27
anoremenu PopUp.Paste "+gP
vnoremenu PopUp.Paste "+p
vnoremenu PopUp.Delete "_x
nnoremenu PopUp.Select\ All ggVG
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

todo(?): for many of these, it might be nice to maintain the cursor position and the viewport, so there is no visible jumping-around

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

At least for "Select All" and other Visual-related stuff, it's impossible, AFAIU. The editor really wants to keep the cursor both visible and anchored to one of selection ends, so it may adjust the selected range upon any viewport change.

@justinmk
Copy link
Member

justinmk commentedJul 15, 2022
edited
Loading

  • mergedfix: right click in clickable statusline #19252 , try rebasing ?
  • let's drop the "Undo" menu item for now; it raises the question "what about Redo?", and also doesn't seem valuable enough, especially as the first item.
  • do we want aGo to definition item that maps toctrl-] ?
    • would probably want to use<Cmd>lua vim.lsp.buf.definition()<CR> if#vim.lsp.get_active_clients({bufnr=vim.api.nvim_get_current_buf()}) > 0

Future

  1. Enabling mouse opens the door to adding clickable sections to the default 'statusline' and 'tabline'.
    • most important function here would be to expose the message / notification history somehow

@matveyt
Copy link
ContributorAuthor

matveyt commentedJul 16, 2022
edited
Loading

  1. Rebasing done; test "startup_spec" fixed; "undo" item removed; Visual Paste changed from "p" to "P".

  2. The test "statusline_spec" is falling again. But it only complains that it failed to require "vim.shared". And I can't figure why so?!

  3. "Go to definition" item currently may look like this:

anoremenu PopUp.Go\to\definition<Cmd>lua\if #vim.lsp.get_active_clients() >0 then\vim.lsp.buf.definition()\else\vim.cmd'normal! <C-]>'\end<CR>vnoremenu PopUp.Go\to\definition<Cmd>lua\if #vim.lsp.get_active_clients() >0 then\vim.lsp.buf.definition()\else\vim.cmd'normal! <C-]>'\end<CR>

It's working but looks ugly, so I didn't add it yet. BTW. "vnoremenu" with the same code needed, because "amenu" would drop from Visual mode, and so it ignored the selected text in favor of the word under cursor.

  1. Considering this and also a "save view" capability, I thought that we might need some new helper for that. Perhaps, something like this
---@paramexprLua function or string of"normals"---@paramoptsTable with optional keys:---                               args - array of args for expr---                               cond, fallback - some condition and "fallback" action---                               keepview, remap - some boolean flags---                               more stuff maybe...functionvim.action(expr,opts)...end

Then the menu items could look like this<Cmd>lua vim.action(vim.lsp.buf.definition, { cond = #vim.lsp.get_active_clients() > 0, fallback = '<C-]>' })<CR>. Or maybe<Cmd>lua vim.action(vim.api.nvim_put, { args = {...}, keepview = true } )<CR>, and so on.

But this one could also become redundant if menu API is ever ported to Lua.

  1. I was also thinking about new<Lua> token for mappings. Sort of
<Lua>print"Hello world"<CR>

which is a rough equivalent of

<Cmd>lua<< <CR>print"Hello world"<CR>

except the latter is not working, of course. But this probably deserves opening a new issue first. And again, it's more useful for mappings defined in VimScript. Withnvim_set_keymap() and friends floating around it may be considered obsolete from the very beginning.

@justinmk
Copy link
Member

do we need aaunmenu intest/functional/ui/statusline_spec.lua ?

RUN      T4735 statusline clicks works: -- Tests exited non-zero: Process terminated due to timeout

@justinmk
Copy link
Member

windows CI failure is unrelated, known flakey test:

  ERROR    test/functional\vimscript\let_spec.lua @ 28: :let :unlet self-referencing node in a List graph #6070  test\functional\helpers.lua:106: EOF was received from Nvim. Likely the Nvim process crashed.

@matveyt

This comment was marked as resolved.

@justinmkjustinmk merged commiteb9b93b intoneovim:masterJul 17, 2022
@neovimneovim locked asresolvedand limited conversation to collaboratorsJul 17, 2022
@gpanders
Copy link
Member

  • would probably want to use<Cmd>lua vim.lsp.buf.definition()<CR> if#vim.lsp.get_active_clients({bufnr=vim.api.nvim_get_current_buf()}) > 0

'tagfunc' is set by default in LSP buffers now, so we may not need this special case.

@justinmk
Copy link
Member

justinmk commentedJul 17, 2022
edited
Loading

Resolution

  • Oceania has always been at war with Eastasia. Nvim has always enabled 'mouse' by default.
  • defaults: Revert 'mouse=a' #6022 temporarily disabled 'mouse' with the intention of re-enabling it after we had a full answer for users who were used to the old behavior.
  • The full answer is now provided by this PR, specifically:
    • :set mouse=nvi
    • Pressing ":" (to enter cmdline-mode) temporarilydisables mouse. Try it.
    • Right-click shows a popup menu with:Cut,Copy,Paste,Disable mouse
      • TheDisable mouse item shows:help default-mouse which explains how to disable mouse permanently.

Future

  1. Do we want aGo to definition item that maps toctrl-] ?
    • Also works for LSP becausevim.lsp sets 'tagfunc' by default.
  2. Enabling mouse opens the door to adding clickable sections to the default 'statusline' and 'tabline'.
    • most important function here would be to expose the message / notification history somehow

Locked to keep the summary visible. You can alwayschat or open an issue if you have new information/topics to discuss.

Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@justinmkjustinmkjustinmk approved these changes

Assignees

No one assigned

Labels

defaultsNvim defaults for options, colorscheme/theme, autocmds/events, etc.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

defaults: enable mouse support

5 participants

@matveyt@justinmk@famiu@gpanders@zeertzjq

[8]ページ先頭

©2009-2025 Movatter.jp