which-key.nvim icon indicating copy to clipboard operation
which-key.nvim copied to clipboard

bug: Command mode prompt doesn't show until user types, when mapping opens command mode

Open dylan-chong opened this issue 1 year ago • 2 comments

Did you check docs and existing issues?

  • [X] I have read all the which-key.nvim docs
  • [X] I have searched the existing issues of which-key.nvim
  • [X] I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

0.9.4

Operating system/version

Ubuntu 22.04.3 LTS

Describe the bug

Command mode prompt is invisible until user types after triggering the mapping, e.g. the example below (which is in the repro lua)

{ ':echo "hello but not pressing enter"', 'example' }

Steps To Reproduce

  1. nvim -u repro.lua
  2. Type <space>%
  3. Nothing will happen.
  4. Type a

Expected Behavior

Command mode should show up at the end of step 2 with cursor at the end of the line

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  { "folke/which-key.nvim", config = true, init = function()
	  require('which-key').register({
		  ['%'] = { ':echo "hello but not pressing enter"', 'example' }
	  }, { prefix = '<space>' })
  end},
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

dylan-chong avatar Dec 10 '23 23:12 dylan-chong

For now, i'm working around the issue by using the command mode buffer

function CopyPath(expand)
  local string = vim.fn.expand(expand)
  vim.fn.setreg('+', string)
  print('Copied: ' .. string)
end
lvim.builtin.which_key.mappings['%'] = {
  ":lua CopyPath('%:p')<Left><Left><Left><C-f>i", -- added <C-f>i
  "Copy file path"
}

dylan-chong avatar Jan 21 '24 05:01 dylan-chong

I have the same issue on MacOS. Workaround also work, but not with Noice unfortunatly. It forces traditional cmd mode.

jonathf avatar Feb 09 '24 18:02 jonathf

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Jul 06 '24 01:07 github-actions[bot]

still an issue

dylan-chong avatar Jul 06 '24 04:07 dylan-chong

I have migrated to v3 just now and unfortunatly the issue stills persists. If there is a new v3 way to get around it, please let us know. If not, would it be prudent to reopen?

jonathf avatar Jul 19 '24 07:07 jonathf

Not exactly the same, but maybe related: 0xAdk/full_visual_line.nvim/issues/4.

jonathf avatar Jul 19 '24 10:07 jonathf