jake-stewart/multicursor.nvim

Feature idea: custom `showmode` message

Closed this issue · 6 comments

I was just noticing that the only visual indicator I presently have for whether cursors are enabled or disabled is the highlight group of the cursors themselves (MultiCursorCursor vs MultiCursorDisabledCursor). If I only have like two cursors in a sea of text, it can be hard to spot those.

I personally have showmode on and had the thought, wouldn't it be cool to have metadata there about multicursors? Some things I'd want off the top of my head:

  • different highlights depending on whether cursors are enabled/disabled (e.g., default ModeMsg might be a bit bold for me if cursors are disabled and I'm still in the process of adding them)
  • custom text (e.g., I think the enabled/disabled verbiage would be a bit confusing and would choose an alternative like active/inactive or unlocked/locked, perhaps just using an icon like 🔒)
  • the number of cursors that exist
  • the actual mode I'm in, because multiple cursors don't change whether I'm in visual/insert/normal mode

Offhand, I think it would be pretty simple to provide a user-facing hook in the config so they could construct whatever mode message they want. Then you could invoke that callback from the vim.on_key handler in the InputManager and vim.api.nvim_echo the result (keeping it out of the history and skipping altogether if showmode is off). Though I don't know that Vim exposes the built-in mode message in a particularly customizable way, so this might still interfere with things like macros appending recording @a. If so, I'm not sure if there's much to do about that downstream from neovim itself, but this hook could still at least be a good-enough stopgap.

Thoughts?

I guess maybe this sort of functionality would be easier to do as a statusline thing, but I've never really customized my own, so I'm not sure if it's currently possible with the existing code. E.g., would it be a problem to access the CursorContext from the status-line evaluation via mc.action, knowing that actions are coded so that no two can run at the same time? I might play around with that later if I find the time.

seems like a very important feature.

mc.hasCursors() and mc.cursorsEnabled() do not use an mc.action(). They can be safely used wherever.

I've been playing around with this and mimicking showmode is a bit glitchy. The cursor seems to flicker a lot. I think it's a bit of a hack and vim can't keep up.

However, supplying global functions for rulerformat and statusline seems to work really well. For example vim.o.statusline = "%{MC_NumCursors()}". I'll have to map out the functions and put a decent example in the readme. First however I want to try #37 since it will probably affect this issue.

Screenshot 2024-09-28 at 3 16 10 PM

@ajvondrak To make it extremely obvious when you are in multicursor mode, I think signs work very well. Even when you cannot see any other cursors, the main cursor still has a sign.

EDIT: Thinking this looks nice (disabled cursors are dotted signs, enabled are solid):
Screenshot 2024-09-28 at 4 55 03 PM

added