ap / vim-buftabline

Forget Vim tabs – now you can have buffer tabs
http://www.vim.org/scripts/script.php?script_id=5057
MIT License
791 stars 72 forks source link

Mouse support in NeoVim 0.1.2 and newer #32

Closed ap closed 3 years ago

ap commented 7 years ago

This was added in NeoVim 0.1.2:

@ N   For 'tabline': start of execute function label. Use %X or %T to 
      end the label, e.g.: %10@SwitchBuffer@foo.c%X.  Clicking this 
      label runs specified function: in the example when clicking once 
      using left mouse button on "foo.c" "SwitchBuffer(10, 1, 'l', 
      '    ')" expression will be run.  Function receives the 
      following arguments in order:
      1. minwid field value or zero if no N was specified
      2. number of mouse clicks to detect multiple clicks
      3. mouse button used: "l", "r" or "m" for left, right or middle 
         button respectively; one should not rely on third argument 
         being only "l", "r" or "m": any other non-empty string value 
         that contains only ASCII lower case letters may be expected 
         for other mouse buttons
      4. modifiers pressed: string which contains "s" if shift 
         modifier was pressed, "c" for control, "a" for alt and "m" 
         for meta; currently if modifier is not pressed string 
         contains space instead, but one should not rely on presence 
         of spaces or specific order of modifiers: use |stridx()| to 
         test whether some modifier is present; string is guaranteed 
         to contain only ASCII letters and spaces, one letter per 
         modifier; "?" modifier may also be present, but its presence 
         is a bug that denotes that new mouse button recognition was 
         added without modifying code that reacts on mouse clicks on 
         this label.
      Note: to test whether your version of Neovim contains this 
            feature use `has('tablineat')`.
astier commented 4 years ago

Would be cool if it would be possible to assign custom commands to mouse-buttons. For example the user could define in its vimrc that left-click on a buffer in the tabline would select it and right-click would close the buffer.

anihm136 commented 4 years ago

@ap I have a working (but hacky) solution for this in Neovim. Would you be interested in a PR?

ap commented 4 years ago

I’m certainly interested in looking at it! Having a starting point always makes it easier to get going.

If you’re asking about getting it merged – that would require getting it cleaned up. But we can handle that however you prefer.

anihm136 commented 4 years ago

Yeah I'm definitely interested in making it PR-ready if the approach is right. I went through the neovim docs again, and it's not as much of a hack as I thought it was, so I think it should be okay. Shall I make a draft PR for you to review?

ap commented 4 years ago

As I said, I’d love to.

anihm136 commented 4 years ago

Created a draft PR #77

ap commented 4 years ago

Thanks to @anihm136, as of de099655114f636bbffcc9ad24b9933d7d591854, this is now implemented. Share and enjoy 🙂